This project has moved. For the latest updates, please go here.

Eigenvalues sorted

Jul 16, 2012 at 9:00 PM

Hi, is possible to get the eigenvalues of a matrix sorted in descending order? Thanks.

Jul 17, 2012 at 5:56 PM

I have created a bug on this (, whcih collects some of the arguments for and against. If you have a symmetric matrix (so the eigenvalues are real) and don't need eigenvectors (so you don't need to worry about re-ordering them as you re-order the eigenvalues), you can do this trivially in your own code:

SymmetricMatrix matrix;
// populate matrix
double[] eigenvalues = matrix.Eigenvalues();

If you need eigenvectors too, you will need to do an auxiluary sort instead: sort an array a[] of integers i using Eigenvalue(i) as the comparer, then look up Eigenvalue(a[i]) to get the ith eigenvalue and Eigenvector(a[i]) to get the ith eigenvector. If you have a non-symmetric matrix, and therefore (possibly) complex eigenvalues, you will need to specify how you want to order the complex numbers.