[SciPy-dev] Sorted Eigenvalues/vectors
Tue Jul 10 14:37:56 CDT 2007
Generally the answer is "no" when the functionality in question requires so
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]
On 7/11/07, Jeremy Conlin <firstname.lastname@example.org> 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?
> On 7/9/07, Bill Baxter <email@example.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 <firstname.lastname@example.org> 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
> > Scipyemail@example.com
> > http://projects.scipy.org/mailman/listinfo/scipy-dev
> Scipy-dev mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Scipy-dev