Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eigen convert dense matrix to sparse one

How to convert an Eigen::Matrix<double,Dynamic,Dynamic> to an Eigen::SparseMatrix<double> ? I'm looking for a better way instead of iterate through the dense matrix

like image 596
Alberto Avatar asked Oct 23 '12 15:10

Alberto


1 Answers

you can use the sparseView() method for that:

sparse = dense.sparseView();

and even specify a tolerance:

sparse = dense.sparseView(epsilon,reference);

like image 116
ggael Avatar answered Sep 28 '22 09:09

ggael