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

Fastest way to get first singular value of matrix

Tags: None
(comma "," separated)
matriza
Registered Member
Posts
17
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
3447
Karma
19
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
17
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.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]