Man*_*nam 4 c++ sparse-matrix eigen
Block operations for sparse matrices - Eigen Toolbox - C++
#include "Eigen/Dense"
#include "Eigen/Sparse"
#include <iostream>
using namespace std;
using namespace Eigen;
int main()
{
MatrixXd silly(6, 3);
silly << 0, 1, 2,
0, 3, 0,
2, 0, 0,
3, 2, 1,
0, 1, 0,
2, 0, 0;
SparseMatrix<double> sparse_silly,temp;
sparse_silly= Eigen::SparseMatrix<double>(6, 3);
temp = Eigen::SparseMatrix<double>(6, 3);
sparse_silly = silly.sparseView();
std::cout << "Whole Matrix" << std::endl;
std::cout << sparse_silly << std::endl;
temp.block(0, 0, 2, 2)=sparse_silly.block(0, 0, 2, 2);
std::cout << "block of matrix" << std::endl;
std::cout << temp.block(0, 0, 2, 2) << std::endl;
getchar();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,稀疏矩阵的块运算无法使用 Eigen 工具箱进行。我想要将稀疏愚蠢的块分配给临时矩阵中的块。临时矩阵的打印输出为零。如果我在概念上遗漏了某些内容,任何人都可以帮助我。最近的文档称块操作可用于稀疏矩阵。
| 归档时间: |
|
| 查看次数: |
2974 次 |
| 最近记录: |