bugGNU Octave - Bugs: bug #50947, angle of -0-0i should be 0

 
 

bug #50947: angle of -0-0i should be 0

Submitted by:  Ceral Paquet <octavebugs>
Submitted on:  Thu 04 May 2017 02:05:29 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: WTF, Matlab?!?
Status: Wont FixAssigned to: None
Originator Name: Open/Closed: Closed
Release: 4.2.1Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Fri 15 Sep 2017 08:18:58 PM UTC, comment #13:

Marking as "Won't Fix" and closing.

Rik <rik5>
Project Administrator
Tue 05 Sep 2017 04:49:12 AM UTC, comment #12:

Is there anything that we want to change in Octave for this bug report, or should it be marked "Won't Fix"?.

Rik <rik5>
Project Administrator
Sun 07 May 2017 06:12:20 AM UTC, comment #11:

Yes.

Although these results are still significantly different from MATLAB.

>> atan2 (0, -0)

ans = 3.1416

>> angle(-0-0i)

ans = 3.1416

>>

Ceral Paquet <octavebugs>
Thu 04 May 2017 07:17:01 PM UTC, comment #10:

Yeah, so Matlab doesn't throw away the signed zero, it just doesn't display it. And then it uses it inconsistenly.

I think it's a bug in Octave that the constant 0-0i is narrowed to a real value. That seems bad to me, but most people don't seem to care about that.

John W. Eaton <jwe>
Project Administrator
Thu 04 May 2017 06:50:54 PM UTC, comment #9:
Ceral Paquet <octavebugs>
Thu 04 May 2017 06:49:33 PM UTC, comment #8:

>> x = -1/Inf


x =

0

Ceral Paquet <octavebugs>
Thu 04 May 2017 06:48:47 PM UTC, comment #7:

I just found this web page that discusses signed zeros in MATLAB. It's not very encouraging.

https://www.advanpix.com/2016/04/28/branch-cuts-and-signed-zeros-in-matlab/

So this is probably more a WTF!? MATLAB issue than a bug.

Ceral Paquet <octavebugs>
Thu 04 May 2017 06:48:18 PM UTC, comment #6:

Finally, what does Matlab do for the following:

John W. Eaton <jwe>
Project Administrator
Thu 04 May 2017 05:54:00 PM UTC, comment #5:

Response using myatan2 mex:

MATLAB

Ceral Paquet <octavebugs>
Thu 04 May 2017 05:50:31 PM UTC, comment #4:

Response using myfunc mex:

MATLAB

Ceral Paquet <octavebugs>
Thu 04 May 2017 04:20:27 PM UTC, comment #3:

Also, with the attached MEX file myatan2.c, please try the following with Matlab and report back what it displays:

(file #40581)

John W. Eaton <jwe>
Project Administrator
Thu 04 May 2017 04:15:41 PM UTC, comment #2:

I think this is more of an issue about automatic narrowing and whether Matlab keeps the sign bit on an IEEE 0.

Because storing complex numbers requires double the amount of storage (real and imaginary 8-byte numbers), Octave automatically tries to compact to a real array whenever the complex part is equal to zero. Try the failing code in two steps:

In the first stage, Octave compacts the value to '-0'. And the angle of -0 is pi. Does Matlab keep the signbit for zero values? What does the following return in Matlab?

In Octave

Rik <rik5>
Project Administrator
Thu 04 May 2017 04:13:14 PM UTC, comment #1:

Could someone please take the attached MEX file, myfunc.c, and try it with Matlab and report back what it displays for the following:

(file #40580)

John W. Eaton <jwe>
Project Administrator
Thu 04 May 2017 02:05:29 PM UTC, original submission:

Octave 4.2.1

MATLAB

Ceral Paquet <octavebugs>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #40581:  myatan2.c added by jwe (333B - text/x-csrc)
file #40580:  myfunc.c added by jwe (337B - text/x-csrc)

 

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 jwe (Updated the item)
  • -unavailable- added by octavebugs (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 9 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 15 Sep 2017 08:18:58 PM UTCrik5StatusNone=>Wont Fix
      Open/ClosedOpen=>Closed
    Thu 04 May 2017 07:17:01 PM UTCjweItem GroupNone=>WTF, Matlab?!?
    Thu 04 May 2017 04:20:27 PM UTCjweAttached File-=>Added myatan2.c, #40581
      Item GroupMatlab Compatibility=>None
      Summaryangle of -0-0i should be 0 for Matlab compatibility=>angle of -0-0i should be 0
    Thu 04 May 2017 04:15:41 PM UTCrik5Item GroupNone=>Matlab Compatibility
      Summaryangle of -0-0i should be 0=>angle of -0-0i should be 0 for Matlab compatibility
    Thu 04 May 2017 04:13:14 PM UTCjweAttached File-=>Added myfunc.c, #40580

    Back to the top


    Powered by Savane 3.1-cleanup1