Search code examples
c++sparse-matrixeigen

Eigen: Use SparseMatrix's selfAdjointView


According to the Eigen documentation, I would expect the following to work:

#include "Eigen/Dense"
#include "Eigen/Sparse"
SparseMatrix<double> mymatrix = SomeFunctionReturningASparseMatrix();

SparseMatrix<double> test = mymatrix.selfadjointView<Lower>();

However, I get the compile-time-error

conversion from 'Eigen::SparseSelfAdjointView<Eigen::SparseMatrix<double>, 2u>' to 
non-scalar type 'Eigen::SparseMatrix<double>' requested

What am I doing wrong? Missing include?

Second question: As far as I was able to find, Eigen does not yet support multiplication of SparseSelfadjointViews with SparseMatrices. Am I missing something, or is this in fact not implemented?


Solution

  • The member ggael in the Eigen forum was able to answer my question. For completeness, I will cite his answer here:


    For the first issue, the following should do the job:

     SparseMatrix<double> test; 
     test = mymatrix.selfadjointView<Lower>();
    

    For te second, you are right, such product is not supported.


    The original question was posted and answered here.