bugGNU Octave - Bugs: bug #63445, inv (NaN) produces different...

 
 

bug #63445: inv (NaN) produces different results for Matlab & Octave

Submitter:  Rik <rik5>
Submitted:  Tue 29 Nov 2022 06:19:39 PM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 29 Nov 2022 06:19:39 PM UTC, original submission:  

This is a small discrepancy, but calling inv() for the exceptional value of NaN produces different results in Matlab and Octave.  In my opinion, Matlab is more consistent in always returning a NaN result.  Octave will return Inf occasionally, which seems incorrect because the input has been changed from Not-a-Number to a numerical value (Inf).

In Octave:


octave:13> x = nan (2,2)
x =

   NaN   NaN
   NaN   NaN

octave:14> y = inv (x)
warning: matrix singular to machine precision, rcond = nan
y =

   NaN   NaN
   NaN   NaN

octave:15> y = inv (single (x))
warning: matrix singular to machine precision, rcond = nan
y =

   NaN     0
   NaN   NaN

octave:16> y = inv (complex (single (x), ones (2,2)))
warning: matrix singular to machine precision
y =

   Inf   Inf
   Inf   Inf

octave:17> y = inv (complex (x, ones (2,2)))
warning: matrix singular to machine precision
y =

   Inf   Inf
   Inf   Inf


In Matlab R2022a:


>> x = nan (2,2)

x =

   NaN   NaN
   NaN   NaN

>> y = inv (x)
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.


y =

   NaN   NaN
   NaN   NaN

>> inv (single (x))
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.


ans =

  2×2 single matrix

   NaN   NaN
   NaN   NaN

>> inv (complex (single (x), ones (2,2)))
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.


ans =

  2×2 single matrix

      NaN +    NaNi      NaN +    NaNi
      NaN +    NaNi      NaN +    NaNi

>> inv (complex (x, ones (2,2)))
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.


ans =

      NaN +    NaNi      NaN +    NaNi
      NaN +    NaNi      NaN +    NaNi



Rik <rik5>
Group administrator

 

(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 rik5 (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.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.14-8eb0.
    Corresponding source code