[英]How to convert sparse matrix to dense matrix in Eigen
Is there some easy and fast way to convert a sparse matrix to a dense matrix of doubles? 是否有一些简单快速的方法将稀疏矩阵转换为密集的双精度矩阵?
Because my SparseMatrix
is not sparse any more, but became dense after some matrix products. 因为我的
SparseMatrix
不再稀疏,但在一些矩阵产品之后变得密集。
Another question I have: The Eigen library has excellent performance, how is this possible? 我有另一个问题:Eigen库具有出色的性能,这怎么可能? I don't understand why, because there are only header files, no compiled source.
我不明白为什么,因为只有头文件,没有编译源。
Let's declare two matrices: 让我们声明两个矩阵:
SparseMatrix<double> spMat;
MatrixXd dMat;
Sparse to dense: 稀疏到密集:
dMat = MatrixXd(spMat);
Dense to sparse: 稀疏密集:
spMat = dMat.sparseView();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.