[Numpy-discussion] Getting the indexes of the myarray.min()

Álvaro Tejero Cantero alvaro at antalia.com
Wed May 12 14:23:06 EDT 2004


Hello,

> To find the index of ONE minimum value is easy, 
> though it is buried in the nd_image sub-package 
> (where many users might miss it):
> numarray.nd_image.minimum_position

It works great... but what about efficiency? If I do times.min() and
then numarray.nd_image.minimum_positioan(times) I am running twice
essentially the same extremum-finding routine, which is prohibitibe for
large N..., am I right?

Which makes me thing of a more general question: I know that some of the
array functions are coded in C for speed, but what about the classical
python-for loop, as in (r Nx3 array of particle positions)

[ [r[i]-r[j] for i in arange(N)] for j in arange(N)]

is this handled to C code?


> I do not know a clean way to find all locations 
> of the minimum value. I hope somebody else does.

Yes... although for the problem at hand that motivated my query, my
times matrix is symmetric... I don't really need all the minima, but
does numarray have any special datatype for symmetric matrixes, that
prevents storage of unneded (e.g. supradiagonal) elements?.


Thank you very much, I'm on my way to get some beautiful code out of old
fortranisms 

á.
-- 
Álvaro Tejero Cantero

http://alqua.org    --	documentos libres
			free documents





More information about the NumPy-Discussion mailing list