[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #59890] inf+1i*inf gives nan+1i*inf
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #59890] inf+1i*inf gives nan+1i*inf |
Date: |
Thu, 4 Feb 2021 13:40:41 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36 |
Update of bug #59890 (project octave):
Priority: 5 - Normal => 3 - Low
Item Group: Incorrect Result => Matlab Compatibility
Status: None => Confirmed
_______________________________________________________
Follow-up Comment #9:
The decision comes down to whether it is worth the programmer time to
implement an exception for scalar multiplication of complex numbers. I
believe (and jwe wrote this in comment #1) that we just forward scalar
multiplication to the C++ math library. There, the rules for scalar
multiplication say that 0 x Inf = NaN so a complex scalar value with a 0 real
becomes NaN. Matlab, by contrast, seems to not perform multiplications when
one of the values is zero.
For vectors and matrices, Matlab is equivalent to Octave and just forwards to
a BLAS library. Taking jwe's example,
x = [i,2,3], y = Inf(3,1), x*y
Matlab: NaN + NaNi
Octave: NaN - NaNi
Aside from a difference in the sign of the complex value, this is the same
result. However, now change to using scalar multiplication which because of
the orientation of the vectors also results in broadcasting.
x = [i,2,3], y = Inf(3,1), x.*y
Matlab:
[ 0 + Infi, Inf + 0i, Inf + 0i
0 + Infi, Inf + 0i, Inf + 0i
0 + Infi, Inf + 0i, Inf + 0i ]
Octave:
[ NaN + Infi, Inf - NaNi, Inf - NaNi
[ NaN + Infi, Inf - NaNi, Inf - NaNi
[ NaN + Infi, Inf - NaNi, Inf - NaNi ]
At the core of the difference are these four multiplications which in Matlab
result in
complex (0,0) * Inf
ans = NaN
complex (0,1) * Inf
ans = 0 + Infi
complex (1,0) * Inf
ans = Inf
complex (1,1) * Inf
ans = Inf + Infi
In Octave the results are
complex (0,0) * Inf
ans = NaN - NaNi
complex (0,1) * Inf
ans = NaN + Infi
complex (1,0) * Inf
ans = Inf - NaNi
complex (1,1) * Inf
ans = Inf + Infi
I'm changing the Item Group to Matlab Compatibility since we are different in
this regard, and marking as Confirmed. But I'm lowering the priority since I
think there are more interesting bugs to fix ahead of this one.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?59890>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/