Registered Member
|
Hi all,
I'm looking for a sparse eigen solver. I installed Eigen3 and created a sparse matrix and now I'm trying to use some of the eigensolvers for my matrix. But I think Eigen3 can still not handle to calculate eigenvalues and eigenvectors for a sparse matrix, am I right? Which sparse eigen solver in C++ would you suggest to me or do you know how to get the eigenvalues and eigenvectors with Eigen? Thank's for your help! Ann |
Moderator
|
http://code.google.com/p/redsvd/wiki/English is based on Eigen.
|
Registered Member
|
I don't have python on my windows computer, so I can't compile redsvd.
I can find no good explanation how to enter the values of a sparse matrix. With the redsvdTest.cpp in the sparse example, I can't understand how the function REDSVD::SMatrixXf works... const int row = 10; const int col = 10; REDSVD::SMatrixXf A(row, col); REDSVD::RedSVD svdOfA(A); MatrixXf newA = svdOfA.matrixU() * svdOfA.singularValues().asDiagonal() * svdOfA.matrixV().transpose(); Is there any other possibility to find an eigensolver for sparse matrixes? I would just need three eigenvalues and vectors next to the value 0. |
Registered Member
|
ben,
I don't use redsvd, but to answer a part of your question -- "SMatrixXf" is just a type alias: typedef Eigen::SparseMatrix<float, Eigen::RowMajor> SMatrixXf; so you don't have to type "Eigen::SparseMatrix<float, Eigen::RowMajor>" all the time, but be able to use the shorter synonym "SMatrixXf" instead. // In case you don't know what "typedef" is: http://www.cplusplus.com/doc/tutorial/other_data_types/ So, this line: REDSVD::SMatrixXf A(row, col); constructs a sparse matrix "A" of type "SMatrixXf" (recall, type "SMatrixXf" is just an alias for "Eigen::SparseMatrix<float, Eigen::RowMajor>"), which has "row" rows and "col" columns. The next line: REDSVD::RedSVD svdOfA(A); constructs an object "svdOfA" containing the singular value decomposition (SVD) of the previously-defined sparse matrix "A". You can access all the components of the SVD by calling the appropriate member-functions of this object: "matrixU", "singularValues", and "matrixV" -- just as illustrated in the line computing "newA". Since you're interested in the eigendecomposition, class "RedSymEigen" in the example below might of more use to you: http://code.google.com/p/redsvd/source/ ... redsvd.hpp http://code.google.com/p/redsvd/source/ ... redsvd.cpp Notice, how it's used in the sparse case: REDSVD::fileProcess<REDSVD::SMatrixXf, REDSVD::RedSymEigen>(input, output, rank); http://code.google.com/p/redsvd/source/ ... vdMain.cpp |
Registered Member
|
All that sounds quite good, but I still can't compile redsvd. I guess I need an Mingw-python combinition on my windows computer, but this seems to be more difficult then expected...
Do you have maybe any suggestions what I could try to get this fixed? Best, Ann |
Moderator
|
it seems there are only two relevant files: redsvd.hpp and redsvd.cpp, so simply import them in your project...
|
Registered Member
|
It seems that the code of RedSVD is quite short based on Eigen. Why doesn't Eigen develop a similar function for sparse matrix? It looks like only a one-week job for an experienced Eigen developer. SVD for sparse matrix is very common and useful.
|
Moderator
|
yes, integrating redSVD into Eigen is not difficult at all. The problem is that after some experiments by myself and others, this randomized algorithm is only usable in some very specific cases. In most cases, the results are very approximate.
|
Registered Member
|
Can you elaborate about those specific cases in sparse matrix. |
Moderator
|
All the details are here: http://arxiv.org/pdf/0909.4061.pdf
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]