Reputation: 601
I have this situation: m is an NxN sparse matrix, and p is plain C++ vector, that contains a NxN matrix. I want to make the product m*p and store the result in a plain C++ array, of course, in a dense format.
SparseMatrix m;
double*p;
Map mp(p,dim1,dim2);
SparseTimeDenseProduct< Eigen::SparseMatrix, Eigen::Map< Eigen::Matrix< double, -1, -1> > > r = m*mp;
I have this code, but I don't know if is correct. And if is correct, I don't know how to ""extract"" the plain array of the SparseTimeDenseProduct. How can I do it?
Upvotes: 1
Views: 1100
Reputation: 29205
No need to deal with Eigen's internal class. Simply do:
SparseMatrix<double> A(dim1,dim2);
double* p, res;
Map<const MatrixXd> mp(p,dim2,dim3);
Map<MatrixXd> mres(res,dim1,dim3);
mres = A * mp;
Upvotes: 4