octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #52919] comparison of complex values


From: Michael Leitner
Subject: [Octave-bug-tracker] [bug #52919] comparison of complex values
Date: Wed, 17 Jan 2018 06:06:19 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

URL:
  <http://savannah.gnu.org/bugs/?52919>

                 Summary: comparison of complex values
                 Project: GNU Octave
            Submitted by: mleitner
            Submitted on: Wed 17 Jan 2018 11:06:17 AM UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: mleitner
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.0.3
        Operating System: GNU/Linux

    _______________________________________________________

Details:

According to the documentation: 
For complex numbers, the following ordering is defined: z1 < z2 if and only
if

  abs (z1) < abs (z2)
  || (abs (z1) == abs (z2) && arg (z1) < arg (z2))

However, consider the following situation:

a=-rand(10,1);
b=-rand(10,1);
b(10)+=1i;

then

(a<b)(1)

gives a different result from

a(1)<b(1)

At least, this violates the principle of least surprise (and cost me a few
hours tracking to another problem). Matlab's comparison of only the real part
would of course solve this problem. I do not want to argue to make such a
fundamental change.

Is there a viable solution? One could check in complex matrix comparisons
whether the two numbers are actually real, but this would be less efficient
and would also give inconsistencies within the matrix comparison. 

Actually, I think that the Matlab way would be best, because then the ordering
is transitive when real numbers are seen as special cases of complex numbers
(I would rather redefine min, max and sort). But again, I see that this would
be a very fundamental change.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?52919>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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