小编Man*_*nam的帖子

稀疏矩阵上的块运算 - Eigen Toolbox - C++

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 << …
Run Code Online (Sandbox Code Playgroud)

c++ sparse-matrix eigen

4
推荐指数
1
解决办法
2974
查看次数

标签 统计

c++ ×1

eigen ×1

sparse-matrix ×1