Fix left scalar multiplication for TriangularView and SparseSelfAdjointView

libeigen/eigen!2400

Closes #1398 and #1536
This commit is contained in:
Florian Maurin
2026-04-16 13:36:51 -07:00
committed by Rasmus Munk Larsen
parent 6ea522323c
commit 2aaea06c33
6 changed files with 125 additions and 3 deletions
+21 -3
View File
@@ -796,10 +796,28 @@ void sparse_basic(const SparseMatrixType& ref) {
m3 -= m2.template selfadjointView<Lower>();
VERIFY_IS_APPROX(m3, refMat3);
Scalar s2 = internal::random<Scalar>();
refMat3 = DenseMatrix(refMat2.template selfadjointView<Upper>());
refMat3 *= s2;
SparseMatrixType m4 = s2 * m2.template selfadjointView<Upper>();
VERIFY_IS_APPROX(m4, refMat3);
refMat3 = DenseMatrix(refMat2.template selfadjointView<Upper>());
refMat3 *= s2;
m4 = m2.template selfadjointView<Upper>() * s2;
VERIFY_IS_APPROX(m4, refMat3);
refMat3 = DenseMatrix(refMat2.template selfadjointView<Lower>());
refMat3 *= s2;
m4 = s2 * m2.template selfadjointView<Lower>();
VERIFY_IS_APPROX(m4, refMat3);
refMat3 = DenseMatrix(refMat2.template selfadjointView<Lower>());
refMat3 *= s2;
m4 = m2.template selfadjointView<Lower>() * s2;
VERIFY_IS_APPROX(m4, refMat3);
// selfadjointView only works for square matrices:
SparseMatrixType m4(rows, rows + 1);
VERIFY_RAISES_ASSERT(m4.template selfadjointView<Lower>());
VERIFY_RAISES_ASSERT(m4.template selfadjointView<Upper>());
SparseMatrixType m5(rows, rows + 1);
VERIFY_RAISES_ASSERT(m5.template selfadjointView<Lower>());
VERIFY_RAISES_ASSERT(m5.template selfadjointView<Upper>());
}
// test sparseView