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


Coordinator
Jul 17, 2012 at 5:56 PM

I have created a bug on this (http://metanumerics.codeplex.com/workitem/7038), 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 reordering them as you reorder the eigenvalues), you can do this trivially in your own code:
SymmetricMatrix matrix;
// populate matrix
double[] eigenvalues = matrix.Eigenvalues();
Array.Sort(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 nonsymmetric matrix, and therefore (possibly) complex eigenvalues, you will need to specify how you want to order the complex numbers.

