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

Power method to find largest Eigenvalue?

Tags: None
(comma "," separated)
bravegag
Registered Member
Posts
52
Karma
0
Hello,

This may be relevant to some people. At the moment I use the Eigenvalue decomposition implemented in Eigen (or MKL ?GEES) but I just need to find the largest Eigenvalue. This can be done a lot more efficiently using the Power Method or Power Iteration method e.g.
http://www-stat.stanford.edu/~susan/cou ... ode40.html
http://en.wikipedia.org/wiki/Power_iteration

Is this supported in Eigen? otherwise it would be quite useful because often people just need the largest Eigenvalue and it is a waste to compute all just to get the largest. I am implementing it for my project but I think it perhaps would be a needed addition to Eigen.

Best regards,
Giovanni
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Yes, at some point we should provide a reference and generic implementation in Eigen supporting both dense and sparse matrices.
bravegag
Registered Member
Posts
52
Karma
0
Here a reference implementation (ported to Eigen from http://www-stat.stanford.edu/~susan/cou ... ode40.html):

Code: Select all
// Power Method to approximate the largest Eigenvalue
double computeLargestEigenvalue(const MatrixXd& A) {
   double dd = 1.0;
   VectorXd x = VectorXd::Random(A.rows()).transpose();
   double lambda = 10.0;
   const double kEpsilon = 1e-1;
   VectorXd y;
   while (dd > kEpsilon) {
      y = A*x;
      dd = abs(x.norm() - lambda);
      lambda = x.norm();
      x = y / lambda;
   }
   // lambda contains the largest Eigenvalue while x the corresponding Eigenvector
   return lambda;
}
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
yes, there were some other starts there: viewtopic.php?f=74&t=108033#p251878
nikopic
Registered Member
Posts
3
Karma
0
Hi There,
I only need the left eigenvector corresponding the largest eigenvalue of some matrix like 10*10. Is there any fast approach to reach it?

Thanks,


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot]