Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding eigenvector corresponding to smallest eigenvalue

Tags:

matlab

I want to find the corresponding eigenvector of the eigenvalue of minimum magnitude of a matrix U. What is the easiest way to do this?

Currently I am using the algorithm

[evecs, D] = eigs(U);
evals = diag(D);
smallesteig = inf;
for k = 1:length(evals)
    if (evals(k) < smallesteig)
        smallesteig = evals(k);
        vec = evecs(:, k);
    end
end

Is there a more efficient way of doing this?

like image 412
user3701257 Avatar asked Oct 20 '25 14:10

user3701257


1 Answers

There is a very simple shorthand for this: [V,D] = eigs(U,1,'SM').

If you look at the eigs documentation, it states:

EIGS(A,K,SIGMA) and EIGS(A,B,K,SIGMA) return K eigenvalues. If SIGMA is:
   'LM' or 'SM' - Largest or Smallest Magnitude
For real symmetric problems, SIGMA may also be:
   'LA' or 'SA' - Largest or Smallest Algebraic
   'BE' - Both Ends, one more from high end if K is odd
For nonsymmetric or complex problems, SIGMA may also be:
   'LR' or 'SR' - Largest or Smallest Real part
   'LI' or 'SI' - Largest or Smallest Imaginary part

So, [V,D] = eigs(U,1,'SM') returns the eigenvector and value for the 1st eigenvalue of U when sorted by Smallest Magnitude.

like image 161
Nitish Avatar answered Oct 23 '25 06:10

Nitish