bugGNU Octave - Bugs: bug #61715, Inconsistent NaN results for...

 
 

bug #61715: Inconsistent NaN results for exponential function (0+0i)^0 with libc++ and libstdc++

Submitter:  Jinchuan Tang <jinchuantang>
Submitted:  Wed 22 Dec 2021 02:18:57 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Jinchuan Tang Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 23 Dec 2021 07:23:00 AM UTC, comment #6: 

Re requiring to mandatory use libstdc++ when building Octave: I don't think that this would be a viable "solution". IIUC, it can be problematic to (statically) link a combination of libraries that are linked to libstdc++ and libc++. (That might be causing the issues with SPQR and GraphhicsMagick++ when linking with libc++ on Ubuntu.)
Most Linux distribution use libstdc++ by default. All libraries that can be installed with their respective package managers are linked against that version of the C++ standard libraries. MacOS uses libc++ by default.
Theoretically, it would be possible to re-built all dependencies of Octave (and their dependencies) on macOS using libstdc++. You'd probably end-up with a "consistent" build in that case. But that seems overly complicated. Instead, we should try and support building Octave with the "native" C++ standard libraries.

Markus Mützel <mmuetzel>
Group administrator
Thu 23 Dec 2021 05:17:43 AM UTC, comment #5: 
Dmitri A. Sergatskov <dasergatskov>
Thu 23 Dec 2021 01:20:49 AM UTC, comment #4: 

I tested this with Octave 8 (hg id: 74fe77faf861) and got the correct result 1 for all the tests 0^0, 0.^0, (0+0i)^0, and (0+0i).^0. This was the behavior whether Octave was compiled with gcc or with clang. Running ldd on both Octave binaries gave the same results, and said they were linked against libstdc++. I have both libstdc++ and libc++ available but configure picked libstdc++ for both compilers.

Do you have to do something special to link against libc++ or does it happen automatically on some platforms like Mac? Is it a viable solution to require Octave to link against libstdc++ instead of libc++ for all platforms, or is that infeasible for Mac?

Arun Giridhar <arungiridhar>
Group Member
Wed 22 Dec 2021 04:21:52 PM UTC, comment #3: 

as a compatibility note Matlab 2021b on windows produces 1

Nicholas Jankowski <nrjank>
Group Member
Wed 22 Dec 2021 03:56:55 PM UTC, comment #2: 

If these bugs are in the standard library, then we could possibly work around them in Octave itself, but we can't fix all the library code out there that might also use std::pow.

John W. Eaton <jwe>
Group administrator
Wed 22 Dec 2021 03:28:13 PM UTC, comment #1: 

Might be related to bug #57908.

I checked with Octave on Ubuntu Linux. When it is linked with libstdc++, `complex(0).^0` is `1`. When it is linked with libc++, `complex(0) .^0` is `NaN - NaNi`.
So this might indeed be another case of the standard libraries implementing `std::pow` differently.


Still an issue on the default branch.

Markus Mützel <mmuetzel>
Group administrator
Wed 22 Dec 2021 02:18:57 PM UTC, original submission:  

Dear Octave team,
I tried both Homebrew and Octave.app, it all give a different result when compared with Windows. I don't know if this is related to OpenBlas or something else. Please have a look. Many thanks!

>> bbb = complex(0+0i)

bbb =  0 + 0i

>> bbb.^2

ans = 0

>> bbb.^0

ans =  NaN - NaNi

For windows, bbb.^0 will produce ans = 1 instead of NaN - NaNi.

Best wishes,
Jinchuan

Jinchuan Tang <jinchuantang>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by arungiridhar (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by jinchuantang (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-12-22 mmuetzel CategoryOctave Function Interpreter
        StatusNone Confirmed
        Release6.4.0 dev
        Operating SystemMac OS Any
        SummaryInconsistent NaN results when calculating exponential function (0+0i)^0 with Apple Silicon M1 Inconsistent NaN results for exponential function (0+0i)^0 with libc++ and libstdc++

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code