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

wrong type conversion double vs. int in sparseatrixproduct

Tags: None
(comma "," separated)
medic123
Registered Member
Posts
25
Karma
0
OS
Hi,

I encountered a problem with the sparsematrix-multiplication. Simple code example:

Code: Select all
Eigen::Sparsematrix<double> smd1 smd2;
Eigen::SparseMatrix<int> smi;
fill smd1, smi ....

/*In the fllowing product the rhs is evaluated in a SparseMatrix<int> and therefore all entries smaller than 1 are pruned.*/
smd2 = smi * smd1 * Eigen::Sparsematrix<int>(smi.transpose());


I tried a few things but only making smi also a Sparsematrix<double> helped. But for more clearness and less memory usage I would like to have smi filled with integers. Is there a workaround?

greetings, medic
manuels
Registered Member
Posts
47
Karma
0
did you try
Code: Select all
smd2 = smi.cast<double>() * smd1 * smi.transpose().cast<double>();
medic123
Registered Member
Posts
25
Karma
0
OS
Nope, apparantly not. It works perfect, thank you very much!


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell