2

I have a list of matrices and want to obtain a list of eigenvectors and eigenvalues for each matrix, both sorted by the size of the eigenvalue. If I write system={eigenvalues, eigenvectors}, where eigenvalues is a list of lists of eigenvalues for each of the matrices, I would like to sort the eigenvectors by writing

Map[Sort[#, #1[[1]] < #2[[1]]] &, Transpose[system]] 

of some sort, but this does nothing useful.

joe8
  • 67
  • 4

1 Answers1

4
Ordering[Norm /@ Last @ N[Eigensystem[system]]];

gives you the ordering by norm. You can apply this on your eigenvalues and eigenvectors, e.g.

Eigenvectors[system][[%]]

EDIT

To apply this on a list of matrices:

(# &@Ordering[Norm /@ N[#]]) & /@ Eigenvectors[#] & /@ {mat1,mat2,...,matn}
Sander
  • 1,866
  • 11
  • 15
  • this solutions seems to work for a single matrix, but not for a list of several matrices. I am unable to generalize it to my problem. – joe8 Oct 13 '14 at 20:58
  • I guess the questions then is whether Ordering can be used on sublists only. – joe8 Oct 13 '14 at 21:06
  • That should not be a huge problem; you can wrap the above in a function and then apply that to your list of matrices, but before I update my answer, please clarify if you want to sort the eigenvectors per matrix, or the matrixes based on their eigenvector norms. If the latter, can I assume sorting is based on largest eigenvector norm? – Sander Oct 13 '14 at 23:59
  • I want to sort per matrix. – joe8 Oct 14 '14 at 11:59
  • updated to accommodate per matrix sorting. – Sander Oct 14 '14 at 12:34
  • I modified this to use it to sort by size of eigenvalue, as originally intended. Passing the output of Ordering to Part, as in Eigenvectors[system][[%]] requires something like MapThread[Part[#1, #2] &, {eigenvectors, %}]. Many thanks! – joe8 Oct 14 '14 at 14:18