Reply to topic

Fastest way to get first singular value of matrix

matriza
Registered Member
Posts
15
Karma
0
Hi,

I've got a dense matrix of doubles 5000x500,000, and I'd like to get its first singular value. I don't need the singular vectors.

Currently I'm using
Code: Select all
JacobiSVD<MatrixXd> s(X);
double s0 = s.singularValues().maxCoeff();


which takes something like 40min on a 2Ghz Intel Xeon (gcc 4.6, -O3, -DNDEBUG).

Are there any "shortcuts" to speed it up?

Thanks
User avatar ggael
Moderator
Posts
2195
Karma
15
OS
JacobiSVD is not designed for such large matrices. Since you only want the largest one, you might compute A = X X^T and extract its largest eigenvalue implementing Power iterations (4 lines of code) or using Eigen's interface to ARPACK (in de devel branch, in unsupported/Eigen/ folder).
matriza
Registered Member
Posts
15
Karma
0
Thanks, I found viewtopic.php?f=74&t=108033 which implements power iterations.

The ARPACK support doesn't seem to build on the latest devel, the code looks for ArpackGeneralizedSelfAdjointEigenSolver.h, but the file is actually called ArpackSelfAdjointEigenSolver.h.

 
Reply to topic

Bookmarks



Who is online

Registered users: AGB, anli, Baidu [Spider], bilbo, Bing [Bot], bshah, Exabot [Bot], garthecho, Google [Bot], google01103, Hans, jensreuterberg, jsirek, jstaniek, koriun, metzman, MiceAreVeryNice, MSNbot Media, paulus3005, pedrorodriguez, Sentynel, vascobasque, Yahoo [Bot]