octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63445] inv (NaN) produces different results f


From: Rik
Subject: [Octave-bug-tracker] [bug #63445] inv (NaN) produces different results for Matlab & Octave
Date: Tue, 29 Nov 2022 13:19:41 -0500 (EST)

URL:
  <https://savannah.gnu.org/bugs/?63445>

                 Summary: inv (NaN) produces different results for Matlab &
Octave
                 Project: GNU Octave
               Submitter: rik5
               Submitted: Tue 29 Nov 2022 10:19:39 AM PST
                Category: Libraries
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: Confirmed
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: dev
         Discussion Lock: Any
        Operating System: Any
           Fixed Release: None
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Tue 29 Nov 2022 10:19:39 AM PST By: Rik <rik5>
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










    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63445>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]