views:

153

answers:

2

I need to compute the largest eigenvalue of a (sparse) matrix. I implemented the power iteration method, but it is too slow to converge, so I'd like to use a package for it. Does anyone have a recommendation?

What is the best C++ eigenvalue computation package? Preferably one that is small and easy to compile.

A: 

At least if memory serves, one possibility would be Boost::uBlas. While Boost as a whole is pretty big, uBlas by itself is quite a bit more reasonable. Moreover, if memory serves it's a header-only library, so using it is pretty easy (you don't have to build the library first, set anything up for the linker, etc.)

Edit: I should add that computing Eigenvalues/vectors in general is pretty slow, even with fairly optimized code. Depending on exactly what you're doing, it's often worthwhile to look into methods that (for one example) let you get by with computing the Eigenvalue of only a subset of the matrix (e.g., Landmark Multidimensional Scaling).

Jerry Coffin
Thanks, but does it have a function to return the largest eigenvalue? I did not see it in the documentation.
Erin
+1  A: 

I can't offer you any details as I haven't used it myself, but I think ARPACK could be of help, and especially ARPACK++ which is a C++ adaption as the original package is in Fortran77. I think the MATLAB function eigs() uses this to find the greatest eigenvalue (and corresponding eigenvector). From what I hear t should be able to interface with STL as well.

MATLAB uses the Fortran77 routines DSAUPD, DSEUPD, DNAUPD, DNEUPD, ZNAUPD, and ZNEUPD. They seem like the ones to look for in ARPACK++.

Check it out here.

Staffan E