[Numpy-discussion] max argmax combo
Charles R Harris
charlesr.harris at gmail.com
Tue Sep 19 14:58:03 CDT 2006
On 9/19/06, Bill Baxter <wbaxter at gmail.com> wrote:
> On 9/20/06, Francesc Altet <faltet at carabos.com> wrote:
> > A Dimarts 19 Setembre 2006 19:21, Charles R Harris va escriure:
> > >
> > > Do you want both the indexes and index sorted array returned, or just
> > > the array using indexes, i.e., something like
> > >
> > > a.sort(kind="quicksort", method="indirect")
> > Uh, I don't understand what do you mean by "sort the array using
> > sorry.
> I think he meant do an argsort first, then use fancy indexing to get
> the sorted array.
> For a 1-d array that's just
> ind = A.argsort()
> Asorted = A[ind]
> That should be O(N lg N + N), aka O(N lg N)
> For A >1-d, you need an indexing expression that's a little more
> complicated, hence the discussion about making an "extract" function
> for that purpose. Then you could say:
> ind = A.argsort(axis=d)
> Asorted = A.extract(ind,axis=d)
I'm also thinking of the name argtake.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion