8

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.

Erin
  • 181
  • 1
  • 4

2 Answers2

3

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
  • 415
  • 2
  • 12
  • Indeed, ARPACK is one of the best ones out there (+1). Can't vouch for its C++ interface though. – ev-br Jan 21 '12 at 16:30
0

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
  • 476,176
  • 80
  • 629
  • 1,111
  • Thanks, but does it have a function to return the largest eigenvalue? I did not see it in the documentation. – Erin Jun 28 '10 at 12:41
  • there's no LAPACK function to return the largest eigenvalue. You can do a brute force matrix diagonalization which gives you all eigenvalues, but that's going to choke much quicker than if you were to use specialized Lanzos solvers. – ev-br Jan 21 '12 at 16:27