[SciPy-dev] Sorted Eigenvalues/vectors

Bill Baxter wbaxter@gmail....
Tue Jul 10 14:37:56 CDT 2007


Generally the answer is "no" when the functionality in question requires so
little code.
I think once you get more familiar with how numpy works you'll be writing
things like that in your sleep.

BTW Maybe you actually wanted to sort by magnitude, not value?
   ix = numpy.argsort(abs(eigvals))
   sorted_eigvals = eigvals[ix]
   sorted_eigvecs = eigvecs[:,ix]


--bb

On 7/11/07, Jeremy Conlin <jeremit0@gmail.com> wrote:
>
> I have used argsort in my code, but certainly not as efficiently as
> you have.  That's nice, thanks.  I guess my question is: should this
> be more obvious in scipy/numpy by creating a method specifically for
> sorting eigenpairs?
>
> Thanks,
> Jeremy
>
> On 7/9/07, Bill Baxter <wbaxter@gmail.com> wrote:
> > Sounds like you're looking for argsort.  Something like:
> >
> >   ix = numpy.argsort(eigvals)
> >   sorted_eigvals = eigvals[ix]
> >   sorted_eigvecs = eigvecs[:,ix]
> >
> > --bb
> >
> >
> > On 7/10/07, Jeremy Conlin <jeremit0@gmail.com> wrote:
> > > I have a need to have the eigenvalues/vectors calculated in my code
> > > returned sorted by eigenvalue.  Of course this necessitates sorting
> > > the eigenvectors accordingly.  If I understand correctly, a method for
> > > this doesn't exist in the current distribution so I wrote a simple one
> > > myself.  Is this something that the community is interested in?
> > > Should a method like this be included in the scipy distribution?  It
> > > is small, but I think very useful.
> > >
> > > Thanks,
> > > Jeremy Conlin
> > >
> > >
> >
> > _______________________________________________
> > Scipy-dev mailing list
> > Scipy-dev@scipy.org
> > http://projects.scipy.org/mailman/listinfo/scipy-dev
> >
> >
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-dev/attachments/20070711/a9c5ceb2/attachment.html 


More information about the Scipy-dev mailing list