Re: Sorting Eigenvalues/EigenVectors
- To: mathgroup at smc.vnet.net
- Subject: [mg8393] Re: Sorting Eigenvalues/EigenVectors
- From: murray at math.umass.edu (Murray Eisenberg)
- Date: Tue, 26 Aug 1997 20:41:33 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Colin, perhaps your "yuck" was justified -- but there WAS a typo in my original posting, shown below. The phrase "undoubtedly the most elegant" should have been "undoubtedly NOT [emphasis added] the most elegant". Sorry about that. However, the solution seems straightforward enough: determine the desired permutation of the eigenvalues -- use any ordering function you want -- and then index into them and the eigenvectors with that permutation. Isn't that the way you would think about it? (Even if you can resort to some sort of witchcraft to code it more elegantly or succinclty.) Colin Rose (crose at c2.telstra-mm.net.au) wrote: : murray at math.umass.edu (Murray Eisenberg) wrote: : : > Here's one way -- undoubtedly the most elegant. : > a = {{16,19,1},{18,10,20},{10,5,3}}; : > esys = N[Eigensystem[a]] : > evals = esys[[1]]; evect = esys[[2]] : > (* Sort[evals] gives the sorted list. That's not all you want. *) : > where = Flatten[Map[Position[Sort[evals], #]&, evals]] : > evals[[where]] : > evects[[where]] : Yuck. : -- : Colin Rose : tr(I) - Theoretical Research Institute : ______________________________________ : crose at c2.telstra-mm.net.au : http://www.usyd.edu.au/su/tri/ -- Murray Eisenberg Internet: murray at math.umass.edu Mathematics & Statistics Dept. Voice: 413-545-2859 (W) University of Massachusetts 413-549-1020 (H) Amherst, MA 01003 Fax: 413-545-1801