Block operations on Sparse Matrices- Eigen Toolbox- C++

匿名 (未验证) 提交于 2019-12-03 01:58:03

问题:

Block operations for sparse matrices - Eigen Toolbox - C++    #include "Eigen/Dense" #include "Eigen/Sparse" #include  using namespace std; using namespace Eigen;      int main()     {     MatrixXd silly(6, 3);     silly  sparse_silly,temp;         sparse_silly= Eigen::SparseMatrix(6, 3);         temp = Eigen::SparseMatrix(6, 3);         sparse_silly = silly.sparseView();          std::cout 

In the above code, the block operations for sparse matrices are not working using Eigen toolbox. I want a assign a block from a sparse_silly to a block in temp matrix. The output printed is zero for the temp matrix.Can anyone help me if i missed something conceptually. The recent documentation says block operations are availble for sparse matrices.

回答1:

Blocks of sparse matrices in Eigen are not all writable. Certain ones are (e.g. .col(Index) in a column major matrix) but the generic .block(Index, Index, Index, Index) is not. The documentation is quite confusing on that matter, but if you look closely, all the examples are with dense matrices and not sparse ones. The col() documentation uses a dense matrix example as well, but if you try it, you'll see that it works.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!