MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Sorting Eigenvalues/EigenVectors

  • To: mathgroup at
  • Subject: [mg8214] Re: Sorting Eigenvalues/EigenVectors
  • From: "Tom Chwastyk" <chwastyk at>
  • Date: Tue, 19 Aug 1997 21:11:52 -0400
  • Organization: US Naval Research Laboratory
  • Sender: owner-wri-mathgroup at

Joseph C. Slater <jslater at> wrote in article
<5sopua$gc6 at>...
> Is there an easy way to sort the results of EigenSystem so that the
> eigenvalues are in increasing order? I can pull them out of the results
> sort them, but the association of the eigenvalues with the eigenvectors
> lost. 

One easy way is to transpose the eigensystem from 




, sort the transpose, then transpose back. The sort goes by first
differences - it doesn't even look at the vectors unless the eigenvalues
are exactly equal, and then it goes by first differences in the vectors. 

Remember, if your eigenvalues are complex, the default sort is not by
complex magnitude but by first differences on the real and then complex
parts. You can add an order function to Sort to change that if you like.

This same problem bothered me when I first came to MMa from APL; I wanted
to get a permutation vector like that resulting from the APL primitives
grade up or grade down, then subscript the parts of the eigensystem result
by that permutation vector to get a sorted eigensystem result. It took a
while to just relax and do it the way it's more natural in MMa.

The example below generates a random positive semidefinite matrix, then
changes two of the eigenvalues to be equal, just to demonstrate that the
sorting works as described for the real case...


Tom Chwastyk ["Fosdick". Polish: CH='H, W=F (here),
A=AH, Y=I. Soften strict 'HFAH-stik.... :-) ]
Naval Research Laboratory Code 6383
Wash. DC 20375-5343    (202) 767 2567

  • Prev by Date: Re: Saving graphics in Mma 3.0.1
  • Next by Date: Re: Converting Excel table to Mathematica matrix.
  • Previous by thread: Re: Sorting Eigenvalues/EigenVectors
  • Next by thread: Re: Sorting Eigenvalues/EigenVectors