[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #43313] Complex number relation operators (=,
From: |
Dan Sebald |
Subject: |
[Octave-bug-tracker] [bug #43313] Complex number relation operators (=, <, >) yield two logical trues |
Date: |
Sun, 28 Sep 2014 03:02:44 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0 SeaMonkey/2.15 |
URL:
<http://savannah.gnu.org/bugs/?43313>
Summary: Complex number relation operators (=, <, >) yield
two logical trues
Project: GNU Octave
Submitted by: sebald
Submitted on: Sun 28 Sep 2014 03:02:43 AM GMT
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any
_______________________________________________________
Details:
This was first discovered by R. in the sort() routine, in which complex
numbers are first sorted by modulus and then angle.
The relational operators (=, <, >) for complex numbers in which the real
portion is negative and the imaginary portion is -0 for one value and +0 for
the other value show two cases that evaluate to true:
octave:137> complex(-1,0) == complex(-1,-0)
ans = 1
octave:138> complex(-1,0) > complex(-1,-0)
ans = 1
octave:139> complex(-1,0) < complex(-1,-0)
ans = 0
I believe only equality should be true, because the similar test for the
floating point scenario behaves that way:
octave:143> -0 == 0
ans = 1
octave:144> -0 > 0
ans = 0
octave:145> -0 < 0
ans = 0
First modulus is compared and if the two numbers have equal modulus then angle
is compared. Given the behavior of atan2(), i.e.,
octave:152> atan2(0,-1)
ans = 3.1416
octave:153> atan2(-0,-1)
ans = -3.1416
the non-unique angle for the same number makes one of the inequality tests
pass. It's best to use the principle argument, which is created by mapping
-pi of atan2() to pi before performing the test.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?43313>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #43313] Complex number relation operators (=, <, >) yield two logical trues,
Dan Sebald <=