RE: Sorting Eigenvalues/EigenVe
- To: mathgroup at smc.vnet.net
- Subject: [mg8158] RE: [mg8099] Sorting Eigenvalues/EigenVe
- From: Ersek_Ted%PAX1A at mr.nawcad.navy.mil
- Date: Sat, 16 Aug 1997 11:51:02 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Dr. Slater wrote: |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 and |sort them, but the association of the eigenvalues with the eigenvectors is |lost. The code below should help. It's a version of routine by Wouter (see [mg6402] from Mar 97) In[1]:= ColumnSort[m_?MatrixQ, colm_Integer/; ( colm<=Dimensions[m][[2]] )]:= Sort[m, OrderedQ[{#1[[colm]] ,#2[[colm]] }]&] In[2]:= m=Table[Random[Integer, 25], {8}, {3}]; MatrixForm[m] Out[2]= (*** A Random Matrix of Integers ***) In[3]:= ColumnSort[m, 1]//MatrixForm Out[3]= (****** The Matrix above after sorting the rows according to the element in the first column. ********) Ted Ersek