[Numpy-discussion] Max on Complex Array
Thu Dec 6 17:23:37 CST 2007
Tom Johnson wrote:
> What is the meaning of numpy's maximum on a complex-valued array?
We impose a lexicographical ordering on the complex space. Complex numbers are
compared first by their real component and then, if the real components are
equal, by their imaginary component.
In : from numpy import *
In : c = random.randint(0, 5, 10) + random.random(10)*1j
In : c
array([ 0.+0.68448275j, 1.+0.97849291j, 3.+0.22114928j, 4.+0.65409519j,
3.+0.91550523j, 4.+0.50667105j, 1.+0.34576644j, 4.+0.97286048j,
In : c.sort()
In : c
array([ 0.+0.52885086j, 0.+0.68448275j, 1.+0.07268317j, 1.+0.34576644j,
1.+0.97849291j, 3.+0.22114928j, 3.+0.91550523j, 4.+0.50667105j,
"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