[Numpy-discussion] Question about numpy.max(<complex matrix>)
Robert Kern
robert.kern at gmail.com
Fri Sep 21 15:02:52 EDT 2007
Stuart Brorson wrote:
> Hi guys,
>
> As a NumPy newbie, I am still learning things about NumPy which I didn't
> expect. Today I learned that for a matrix of complex numbers,
> numpy.max() returns the element with the largest *real* part, not the
> element with the largest *magnitude*.
There isn't a single, well-defined (partial) ordering of complex numbers. Both
the lexicographical ordering (numpy) and the magnitude (Matlab) are useful, but
the lexicographical ordering has the feature that
(not (a < b)) and (not (b < a)) implies (a == b)
This is not the case for using the magnitude.
You can get the element of maximum magnitude like so:
a.flat[absolute(a.flat).argmax()]
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion
mailing list