bugGNU Octave - Bugs: bug #63082, eig(NaN) and eig(Inf) emit an...

 
 

bug #63082: eig(NaN) and eig(Inf) emit an error in Octave while Matlab returns NaN

Submitter:  Johannes Pfeifer <jpfeifer>
Submitted:  Tue 20 Sep 2022 10:16:25 AM UTC
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Johannes Pfeifer Open/Closed:  * Open
Release:  * dev Operating System:  * Any
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Tue 20 Sep 2022 10:08:31 PM UTC, comment #4: 

Confirmed.  I changed the Summary to reflect that this is merely a Matlab Compatibility difference.  In the cases I tried, Matlab always returns a vector of all NaNs whenever the input contains even one Inf or NaN value.

We could choose to make Octave do the same thing.  The code is in the directory liboctave/numeric/ and in the files EIG.cc and fEIG.cc.  There are four init() routines in each file which have a check similar to this one

  if (a.any_element_is_inf_or_nan ())
    (*current_liboctave_error_handler)
      ("EIG: matrix contains Inf or NaN values");

Rik <rik5>
Project Administrator
Tue 20 Sep 2022 04:24:14 PM UTC, comment #3: 

Sorry, the second one should be:

eig ([1, Inf; 0, 2])

ans =

   NaN
   NaN

Johannes Pfeifer <jpfeifer>
Tue 20 Sep 2022 04:22:58 PM UTC, comment #2: 

For nonfinite matrices, the result in Matlab is a NaN-vector:

eig ([1, NaN; 0, 1])
ans =

   NaN
   NaN

and


eig ([1, NaN; 0, 1])

ans =

   NaN
   NaN

Johannes Pfeifer <jpfeifer>
Tue 20 Sep 2022 04:18:23 PM UTC, comment #1: 

In Matlab, is this just a special case for scalar inputs?  What happens for things like

eig ([1, Inf; 0, 2])
eig ([1, NaN, 0, 1])

?

John W. Eaton <jwe>
Project Administrator
Tue 20 Sep 2022 10:16:25 AM UTC, original submission:  

In Matlab

eig(Inf)
+verbatim+
and
+verbatim+
eig(NaN)
+verbatim+
return NaN. In Octave, the code will instead crash with

> error: EIG: matrix contains Inf or NaN values

This requires to add an additional exception handling layer.

Johannes Pfeifer <jpfeifer>

 

(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 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by jpfeifer (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 project members can vote.

     

     

     

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-09-20 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        Item GroupUnexpected Error or Warning Matlab Compatibility
        StatusNone Confirmed
        Release7.2.0 dev
        Operating SystemMicrosoft Windows Any
        Summaryeig(NaN) and eig(Inf) triggers a hard error instead of returning NaN eig(NaN) and eig(Inf) emit an error in Octave while Matlab returns NaN
    2022-09-20 jwe Item GroupMatlab Compatibility Unexpected Error or Warning

    Back to the top


    Powered by Savane 3.9