Eigen cannot add outer product to sparse row major matrix

38 Views Asked by At

The following code compiles without issues:

#include <Eigen/Sparse>
int main(){
    typedef Eigen::SparseMatrix<double> SpMat; 
    typedef Eigen::SparseVector<double> SpVec; 
    SpMat m (5,5);
    SpVec v (5);
    m+=v * v.transpose();
}

However, when I change

typedef Eigen::SparseMatrix<double> SpMat;

to

typedef Eigen::SparseMatrix<double, Eigen::RowMajor> SpMat;

I get an error message which includes

/usr/include/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h:48:13: error: static assertion failed: THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH

I tried changing the definition of SparseVector to make it Row/Column Major, but it did not seem to fix the issue. Does anybody know what should I do? I need to have RowMajor sparse matrix as I need quick access to rows.

0

There are 0 best solutions below