Created attachment 344 [details] Test for multiplying a vector as diagonal with a sparse matrix. Dear Eigen developers, when trying to multiply a vector as diagonal matrix with a sparse matrix from the left the code does not compile, while multiplying it from the right works. The same code works when a dense matrix is considered.
Works with a DiagonalMatrix: DiagonalMatrix<double,Eigen::Dynamic>(d.asDiagonal()) * A I'm investigating why it doesn't with a DiagonalWrapper.
https://bitbucket.org/eigen/eigen/commits/2b1e3e6f9e2b/ Changeset: 2b1e3e6f9e2b User: ggael Date: 2013-06-28 17:10:53 Summary: Fix bug 611: fix const qualifier in cwiseProduct(sparse,dense) and SparseDiagonalProduct::InnerIterator
Dear Gael, thank you for your patch! I can confirm that both SparseMatrix<double> A2=DiagonalMatrix<double,Eigen::Dynamic>(d.asDiagonal()) * A; and the short version SparseMatrix<double> A2=d.asDiagonal()*A; are working now. Unfortunately, this does not yet fix the problem, because SparseMatrix<double> A3=d.asDiagonal()*A*d.asDiagonal(); and SparseMatrix<double> A3=DiagonalMatrix<double,Eigen::Dynamic>(d.asDiagonal()) * A * DiagonalMatrix<double,Eigen::Dynamic>(d.asDiagonal()); still do not compile. The error message in both cases is Eigen/src/SparseCore/SparseCwiseUnaryOp.h:30:62: error: no type named 'ReverseInnerIterator' in 'Eigen::CwiseUnaryOpImpl<Eigen::internal::scalar_multiple_op<double>, const Eigen::SparseDiagonalProduct<Eigen::DiagonalMatrix<double, -0x00000000000000001>, Eigen::SparseMatrix<double> >, Eigen::Sparse>::_MatrixTypeNested {aka const class Eigen::SparseDiagonalProduct<Eigen::DiagonalMatrix<double, -0x00000000000000001>, Eigen::SparseMatrix<double> >}' Could you please have a look at the problem again? Thank you in advance!
re-opened because original bug still exists. (Inefficient) work-around is to add an (...).eval() around one of the products.
Another workaround: A.cwiseProduct(d*d.transpose())
https://bitbucket.org/eigen/eigen/commits/742a401329e6/ Changeset: 742a401329e6 User: ggael Date: 2013-07-05 22:42:46 Summary: Fix bug 611: diag * sparse * diag
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/611.