Registered Member
|
I am trying to multiply a sparse matrix by a dense one:
#include <Eigen/Dense> #include <Eigen/Sparse> using namespace Eigen; int main() { SparseMatrix<double> s; s.resize(3,3); MatrixXf d(3,3); MatrixXf d2(3,3); // gives an error s*d; // doesn't give an error d*d2; } This MWE compiles perfectly without s*d, but with s*d there are many template errors... Any ideas how to do that? Thanks. |
Moderator
|
you are mixing float and double! Either use MatrixXd or a SparseMatrix<float> to ensure compatible scalar types. You can also explicitly cast to a given scalar type using d.cast<double>(), e.g.:
s * d.cast<double>() |
Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]