octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting complex values


From: Daniel J Sebald
Subject: Re: Sorting complex values
Date: Sat, 27 Sep 2014 15:29:38 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 09/27/2014 02:25 PM, Ben Abbott wrote:

On Sep 27, 2014, at 2:43 PM, Daniel J Sebald<address@hidden>  wrote:

The one thing that concerns me a bit is that -1 - 0i produces an angle of -pi.

I'm confident this behavior is correct. There is a branch along the negative 
real axis ... i.e. a phase of +pi and -pi are both correct, but only one of 
them is proper by IEEE standards.  To determine the phase it is necessary to 
determine if the imaginary part is positive or negative.  The default is to 
assume the imaginary part is positive. In the case, of 1 - 0i, the default has 
been over-ridden.

There's a branch cut in the complex plane for the arc-tangent function. But here it is just numbers represented as modulus and angle

z = |z|e^jTHETA
  = |z|e^jTHETA +- N 2pi

where THETA is the principle argument. |z|e^jpi and |z|e^-jpi are the same number. Treating the argument as the principle argument or not, and sorting on it is basically arbitrary.

I actually prefer to use the principle argument because then the +0/-0 phenomenon has no bearing on order, in light of sorting of non-complex numbers which produces:

octave:70> x = [0 -0 0 -0 0 -0]'
x =

   0
  -0
   0
  -0
   0
  -0

octave:71> [s i] = sort(x)
s =

   0
  -0
   0
  -0
   0
  -0

i =

   1
   2
   3
   4
   5
   6

If the +/-0 is meaningless in non-complex sort, then it probably should be meaningless in the complex sort.

Dan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]