noalias += Row Major Sparse Matrix multiplication
Submitted by mat..@..ria.fr
Assigned to Nobody
Link to original bugzilla bug (#650)
Version: 3.3 (current stable)
Description
Hello.
Sometimes using .noalias() += does not perform a += but only a =.
I do not know if it is the only case, but I found that adding the multiplication of a SparseRowMajor matrix with a vector is bugging:
v.noalias() += sparseRowMajorMatrix * w;
The multiplication with a col major matrix seems to correctly perform the addition.
typedef Eigen::Matrix< double, Eigen::Dynamic, 1 > Vec;
typedef Eigen::SparseMatrix<double,Eigen::RowMajor> SparseRowMatrix;
typedef Eigen::SparseMatrix<double,Eigen::ColMajor> SparseColMatrix;
Vec test(3); test.fill(3.0);
Vec result(3);
SparseRowMatrix MSparseRow(3,3); MSparseRow.setIdentity();
SparseColMatrix MSparseCol(3,3); MSparseCol.setIdentity();
result.setOnes();
result.noalias() += test; // OK
std::cerr<<result<<std::endl<<std::endl; // 4 4 4
result.setOnes();
result.noalias() += MSparseRow * test; // KO
std::cerr<<result<<std::endl<<std::endl; // 3 3 3
result.setOnes();
result.noalias() += MSparseCol * test; // OK
std::cerr<<result<<std::endl<<std::endl; // 4 4 4