New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong eigenvalues order in OrderedEigenDecomposition #253
Comments
This is true for |
This is much more difficult than I first thought. This becomes difficult when reordering. Look for example at the matrix (extracted from one of the test cases), written as a complex decomposition: One clearly sees that the first two columns of the The decomposition using real matrices (which is what We see that the two conjugate complex eigenvalues appear in the real decomposition as a 2x2 block in the upper left of the If we were to sort the eigenvalues using the Is this what we want? |
I have fixed this in master branch.
So I split these two different mathematical problems in two different classes: With the split performed, ordering becomes natural in the symmetric case where all eigenvalues are real numbers, so I just added a boolean so users can select increasing/decreasing order for eigenvalues. I did not provide any ordering capabilities in the non-symmetric case as it is really awkward. In fact, as per the example above, one can insert one real eigenvalue between two conjugate eigenvalues and in this case the D matrix is even farther from a diagonal matrix, having non-zero elements up to the corners, and the real and imaginary parts of the eigenvectors would be separated. This means that the real matrices V and D are not really useful anymore. So in this case, I would recommend just converting the initial matrix to complex form and use |
If the input matrix has null eigenvalues, the order in which they are returned by
OrderedEigenDecomposition
might be wrong. As an example, with the input matrixextracting the main diagonal of
OrderedEigenDecomposition#getD()
returnswhile it should return
I acknowledge that if more than one eigenvalue is null, then there is an ambiguity in the order of the corresponding eigenvectors.
It would also be nice to expose the
epsilon
parameter for internal checks in the class constructor, and have the possibility to choose among ascending/descending order (or is a descending order guaranteed by the "standard"EigenDecomposition
?).I would also expect the arrays
realEigenvalues
andimagEigenvalues
to be sorted in the same wayD
is.The text was updated successfully, but these errors were encountered: