diff options
author | Gael Guennebaud <g.gael@free.fr> | 2013-07-05 22:42:46 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2013-07-05 22:42:46 +0200 |
commit | 4f14b3fa726e25b14f1f06522353ee56707c2872 (patch) | |
tree | c22848d6267a5dab03f857586b748b66b9581a8b | |
parent | 9b9177f1ce0f6017976b841f88d0842ee3c823a2 (diff) |
Fix bug #611: diag * sparse * diag
-rw-r--r-- | Eigen/src/SparseCore/SparseDiagonalProduct.h | 6 | ||||
-rw-r--r-- | test/sparse_product.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/Eigen/src/SparseCore/SparseDiagonalProduct.h b/Eigen/src/SparseCore/SparseDiagonalProduct.h index 3e314bcfc..1bb590e64 100644 --- a/Eigen/src/SparseCore/SparseDiagonalProduct.h +++ b/Eigen/src/SparseCore/SparseDiagonalProduct.h @@ -78,7 +78,11 @@ class SparseDiagonalProduct EIGEN_SPARSE_PUBLIC_INTERFACE(SparseDiagonalProduct) typedef internal::sparse_diagonal_product_inner_iterator_selector - <_LhsNested,_RhsNested,SparseDiagonalProduct,LhsMode,RhsMode> InnerIterator; + <_LhsNested,_RhsNested,SparseDiagonalProduct,LhsMode,RhsMode> InnerIterator; + + // We do not want ReverseInnerIterator for diagonal-sparse products, + // but this dummy declaration is needed to make diag * sparse * diag compile. + class ReverseInnerIterator; EIGEN_STRONG_INLINE SparseDiagonalProduct(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp index 51eed428b..664e33887 100644 --- a/test/sparse_product.cpp +++ b/test/sparse_product.cpp @@ -161,6 +161,8 @@ template<typename SparseMatrixType> void sparse_product() VERIFY_IS_APPROX(m3=v2.asDiagonal()*m2, refM3=v2.asDiagonal()*refM2); VERIFY_IS_APPROX(m3=v1.asDiagonal()*m2.transpose(), refM3=v1.asDiagonal()*refM2.transpose()); + VERIFY_IS_APPROX(m3=v2.asDiagonal()*m2*v1.asDiagonal(), refM3=v2.asDiagonal()*refM2*v1.asDiagonal()); + // evaluate to a dense matrix to check the .row() and .col() iterator functions VERIFY_IS_APPROX(d3=m2*d1, refM3=refM2*d1); VERIFY_IS_APPROX(d3=m2.transpose()*d2, refM3=refM2.transpose()*d2); |