Registered Member
|
I am an Eigen newbie, and am trying to play with sparse matrices and vectors. The following expression does not compile with Eigen 3.1.0: sv.dot(SM*sv), where sv is a sparse vector and SM is a sparse matrix.
I get the following error: ./Eigen/src/SparseCore/SparseDot.h:66: error: no type named ‘InnerIterator’ in ‘class Eigen::SparseSparseProduct<const Eigen::SparseMatrix<double, 0, int>&, const Eigen::SparseVector<double, 0, int>&>’ Can someone please let me know what went wrong? Also, SM is a self-adjoint matrix (fully specified). Is there a way to use this infromation for speed-up or better numerical accuracy of the result? The compiler does not like the use of selfadjointView<>() in this case. Thanks! |
Registered Member
|
Turns out that SM*sv does not compile either: I get this error -
./Eigen/src/SparseCore/SparseMatrixBase.h:282: error: no type named ‘InnerIterator’ in ‘class Eigen::SparseSparseProduct<const Eigen::SparseMatrix<double, 0, int>&, const Eigen::SparseVector<double, 0, int>&>’ SM is SparseMatrix<double> and sv is SparseVector<double>. |
Registered Member
|
More info on the same...
/* my code ********************/ SparseMatrix<double> M(4,4); SparseVector<double> v(4); // insert values into M and v... (M is symmetric) cout << "M*v = " << M*v; // does not compile SparseVector<double> u = M*v; // compiles, but fails assertion at runtime SparseMatrix<double> U = M*v; // compiles and runs ok double s = v.transpose()*M*v; // does not compile double r = (v.transpose()*M*v).coeff(0,0); // does not compile SparseMatrix<double> vMv = v.transpose()*M*v; // compiles and runs ok double t = vMv.coeff(0,0); // compiles and runs ok /******************************/ Can someone please help me with the above compilation and runtime failures. And is vMv -> t the best way to compute v'*M*v? Thanks. |
Moderator
|
I'm looking at it.
In the meantime you can use a one column SparseMatrix instead of a SparseVector. |
Moderator
|
ok, the SparseVector<double> r = M * v; is fixed now. Same for v.dot(M*v), and u = M * v; For the other expression, you have to evaluate the product to get access to coeff:
double s = (v.transpose()*M*v).eval().coeff(0,0); v.transpose()*M*v returns a 1x1 dense matrix. |
Registered Member
|
Awesome, thanks! Great job with eigen, love using it!
|
Registered Member
|
Now a truly newbie question: how do I download the fixed code?
|
Registered Member
|
Eigen uses bitbucket. Here is the link: https://bitbucket.org/eigen/eigen/overview
You can use mercurial to clone the repository (hg clone https://bitbucket.org/eigen/eigen) or use the get source link on the page. You can also follow the changes here: https://bitbucket.org/eigen/eigen/changesets
'And all those exclamation marks, you notice? Five? A sure sign of someone who wears his underpants on his head.' ~Terry Pratchett
'It's funny. All you have to do is say something nobody understands and they'll do practically anything you want them to.' ~J.D. Salinger |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]