[SciPy-User] get best few of many: argsort( few= ) using std::partial_sort ?
denis
denis-bz-gg at t-online.de
Thu Jul 8 13:17:51 EDT 2010
Folks,
to get the best few of a large number of objects,
e.g. vectors near a given one, or small distances in
spatial.distance.cdist or .pdist,
argsort( bigArray )[: a few ] is not so hot. It would be nice if
argsort( bigArray, few= )
did this -- faster, save mem too. Would anyone else find this useful ?
I recently stumbled across partial_sort in stl; fwiw,
std:partial_sort( A, A + sqrt(N), A + N ) is ~ 10 times faster than
std:sort
on my old mac ppc, even for N 100.
Also fwiw, nth_element alone is ~ twice as slow as partial_sort --
odd.
cheers
-- denis
More information about the SciPy-User
mailing list