bugGNU Octave - Bugs: bug #43313, Complex number relation operators...

 
 

bug #43313: Complex number relation operators (=, <, >) yield two logical trues

Submitted by:  Dan Sebald <sebald>
Submitted on:  Sun 28 Sep 2014 03:02:43 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 27 Jan 2015 06:33:46 PM UTC, comment #3:

I applied your patch to the development branch in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/bdf90710dddf). I'm not sure exactly why, but we have a different set of sort comparison functions for use with issorted. So I updated those so that sort and issorted both agree on this new definition. Finally I added a new file in the test/ directory to check the behavior of these two routines.

Rik <rik5>
Project Administrator
Mon 29 Dec 2014 05:58:29 AM UTC, comment #2:

A related bug appears to be bug #42301.

Rik <rik5>
Project Administrator
Sat 04 Oct 2014 07:23:31 AM UTC, comment #1:

The arg()/carg() function of the C math library has a range of [-pi,pi], i.e., -pi inclusive. Attached is a changeset that will map -pi to pi. This appears to fix complex(-1,0) > complex(-1,-0) case and sorting.

The change to the header file touches pretty much the whole tree, so before compiling make sure there's agreement with the logic of the conditionals.

(file #32221)

Dan Sebald <sebald>
Sun 28 Sep 2014 03:02:43 AM UTC, original submission:

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:

I believe only equality should be true, because the similar test for the floating point scenario behaves that way:

First modulus is compared and if the two numbers have equal modulus then angle is compared. Given the behavior of atan2(), i.e.,

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.

Dan Sebald <sebald>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #32221:  octave-complex_operators-2014oct03.patch added by sebald (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by sebald (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 27 Jan 2015 06:33:46 PM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Mon 29 Dec 2014 04:42:53 PM UTCrik5StatusNone=>Confirmed
    Sat 04 Oct 2014 07:23:31 AM UTCsebaldAttached File-=>Added octave-complex_operators-2014oct03.patch, #32221

    Back to the top


    Powered by Savane 3.1-cleanup1