This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Assigning a Sparse Matrix-Matrix product to a Dense Matrix

Tags: None
(comma "," separated)
dubmarauder
Registered Member
Posts
14
Karma
0
OS
Hi Everyone,

Let's say I have a sparse matrix M and a dense vector v. The following works:

VectorXd p = M*v;

If I have a a sparse matrix M and a sparse matrix G, the following fails:

MatrixXd Q = G.transpose()*M*G;

The following, however, works:

SparseMatrix<double> Qsparse = G.transpose()*M*G;
MatrixXd Qdense = Qsparse;


Any thoughts as to what I'm doing incorrectly?

Thanks!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
hi, the product of a sparse and dense matrix is dense while the product of two sparse matrices is unlikely to be dense, that's why it is implemented to be evaluated into a sparse matrix.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]