Reputation: 45
I could just look for the lowest non-zero eigenvalue and then get the corresponding eigenvector.
Do you know of any other cleaner method to get this?
lowindex from eigen() is apparently ignored in the current implementation :(
Upvotes: 1
Views: 1078
Reputation: 26259
As it says in the documentation:
eigenvalues – output vector of eigenvalues of the same type as src; the eigenvalues are stored in the descending order.
and
eigenvectors – output matrix of eigenvectors; it has the same size and type as src; the eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues
So the lowest eigenvalue is simply the last element in the eigenvalues vector and the corresponding eigenvector is the last row of the eigenvectors matrix.
If the last eigenvalue is zero (i.e. your input is singular), you need to search up from the last entry if you want the lowest non-zero.
Upvotes: 2