How to get eigenvalues to take the same order as in Matlab

Since AFAIK Matlab doesn’t document what ordering they use, and in general the ordering of eigenvalues can be arbitrary in any case, it doesn’t seem possible to come up with an algorithm that is guaranteed to reproduce it. (For Hermitian matrices, most numerical eigensolvers default to ascending order since that’s what LAPACK does.)

If you are trying to detect eigenvalue crossings, you should probably use a more reliable algorithm than “give it to Matlab and hope it does what I want”.

Normally, eigenvalue crossings arise when there is some symmetry commuting with your matrix. If you can identify the symmetry group of your problem, you can block-diagonalize your matrix and separate the eigenvalues robustly into eigenvalues within each block (equivalently, label the eigenvectors according to the irreps of the symmetry group that fall into).

5 Likes