稀疏矩阵上的块操作 - 特征工具箱 - C++
Block operations on Sparse Matrices- 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 << "block of matrix" << std::endl;
std::cout << temp.block(0, 0, 2, 2) << std::endl;
getchar();
return 0;
}
在上面的代码中,稀疏矩阵的块操作无法使用特征工具箱。我想要将一个块从sparse_silly分配给临时矩阵中的块。对于临时矩阵,打印的输出为零。如果我在概念上错过了一些东西,谁能帮助我。最近的文档说块操作可用于稀疏矩阵。
特征矩阵
中的稀疏矩阵块并不都是可写的。某些是(例如 .col(Index)
列主矩阵中),但通用.block(Index, Index, Index, Index)
不是。文档在这个问题上非常令人困惑,但如果你仔细观察,所有的例子都是密集矩阵而不是稀疏矩阵。col()
文档也使用密集矩阵示例,但如果您尝试一下,您会发现它有效。
相关文章:
- 为什么在popback()操作之后,它仍然打印完整的矢量
- 重载操作程序时出错>>用于类中的字符串 memebr
- 如何声明特征矩阵,然后通过嵌套循环初始化它
- 特征 3.3.x:如何在所有行中操作 lamba?
- 确保特征将 AVX 矢量化用于特定操作
- 标量类型的特征模板无法编译固定大小的子矩阵操作
- 特征库,简单的线性代数操作,具有稀疏的矩阵,增加了其分配的尺寸
- 如果矩阵密集且不对称,特征库矩阵/矢量操作是否比 .net 矩阵/向量操作更快?
- 从MATLAB到C 特征矩阵操作 - 矢量归一化
- 采用 DenseBase 的模板化函数中的 c++ 特征块操作
- 具有未签名类型的特征操作
- 在特征阵列上执行布尔操作
- C++ 特征 - 如何将广播和元素操作结合起来
- 特征矩阵库系数明智操作
- 稀疏矩阵上的块操作 - 特征工具箱 - C++
- 特征多线程操作
- 无循环的特征元素操作
- 特征矩阵库的一个块操作的补充
- 特征C++:稀疏矩阵操作的性能
- 特征矩阵库索引操作