[Numpy-discussion] Question about numpy.max(<complex matrix>)

Stuart Brorson sdb@cloud9....
Fri Sep 21 21:33:14 CDT 2007


On Fri, 21 Sep 2007, David Goldsmith wrote:

> Not to be snide, but I found this thread very "entertaining," as,
> precisely because there is no single, well-defined (partial) ordering of
> C, I regard it as poor coding practice to rely on whatever partial
> ordering the language you're using may (IMO unwisely) provide: if you
> want max(abs(complex_array)), then you should write that so that future
> people reading your code have no doubt that that's what you intended;
> likewise, even if numpy provides it as a default, IMO, if you want
> max(real(complex_array)), then you should write that, 
[snip]

Yea, I kind of thought that too.  However, the problem with that is:

max(real(complex_array)) returns only the *real* part of the max value found.

Numpy returns the *complex* value with the largest *real* part.  So the
return is conceptually muddled.

More specifically, Numpy doesn't return max(real(complex_array)).
Rather, it does something like (in pseudocode)

idx1 = index( max_all(real(complex_array)) )
idx2 = index( max(imag(complex_array[idx1])) )
return complex_array[idx2]

Stuart



More information about the Numpy-discussion mailing list