bugGNU Octave - Bugs: bug #61689, inv of scalar emits a singular...

 
 

bug #61689: inv of scalar emits a singular matrix warning

Submitter:  None
Submitted:  Fri 17 Dec 2021 12:50:53 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  rik5
Originator Name:  guillaume Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 7.0.90
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 03 Jan 2022 04:13:02 PM UTC, comment #9: 

Given the latest comments, this seems to be working as expected now.

Closing as fixed.

Markus Mützel <mmuetzel>
Group administrator
Wed 29 Dec 2021 04:14:46 PM UTC, comment #8: 

Regarding comment #7, I also had checked with Matlab before committing the changeset.  I think they went the wrong way on this so there is no need to copy them.

Rik <rik5>
Group administrator
Wed 29 Dec 2021 09:17:18 AM UTC, comment #7: 

FWIW matlab R2021b treats inv(0) and 1/0 differently:


inv(0)
warning: matrix is singular to working precision
Ans = Inf

1/0
Ans = Inf


A.R. Burgers <arb>
Tue 28 Dec 2021 03:32:40 PM UTC, comment #6: 

@Markus: Yes, that was intentional.  I made the choice that "inv (scalar)" should behave as the equivalent division operator "1 / scalar".

Rik <rik5>
Group administrator
Tue 28 Dec 2021 11:28:39 AM UTC, comment #5: 

There is no longer a warning for `inv(0)`. Was that intentional?

Markus Mützel <mmuetzel>
Group administrator
Sun 26 Dec 2021 03:20:19 AM UTC, comment #4: 

Of course this was quite a bit more involved than it first appeared.  I checked in a change that fixed this issue as well as some Matlab compatibility issues with exceptional scalar values such as Inf or NaN in this changeset: http://hg.savannah.gnu.org/hgweb/octave/rev/117ebe363f56

Marking as Ready for Test.

Rik <rik5>
Group administrator
Thu 23 Dec 2021 01:05:16 AM UTC, comment #3: 

Hmm, that's silly.  I did a lot of work on bug #52285; I'll take a look.

Rik <rik5>
Group administrator
Sat 18 Dec 2021 01:03:17 PM UTC, comment #2: 

See also bug #52285 and the changeset mentioned there http://hg.savannah.gnu.org/hgweb/octave/rev/98400baa509f

A.R. Burgers <arb>
Sat 18 Dec 2021 07:56:58 AM UTC, comment #1: 

same result for:


octave:1> inv(diag(2))
warning: matrix singular to machine precision
ans = 0.5000


Consistent with that comments in the source code indicate scalars are treated as diagonal matrices in this context.

The problem I think is in this bit in liboctave/array/dMatrix.cc around line 644 where the rcon argument is not adjusted


  if (typ == MatrixType::Diagonal)  // a scalar is also classified as Diagonal.
    ret = 1 / (*this);


rcon is left at the 0 initial value set in libinterp/corefcn/inv.cc around line 81. m.inverse is called at line 170 in inv.cc

Then later in inv.cc rcond_plus_one_eq_one will be true, and the warning will be triggered.


rcond_plus_one_eq_one = xrcond + 1.0 == 1.0;


A.R. Burgers <arb>
Fri 17 Dec 2021 12:50:53 PM UTC, original submission:  


octave:1> inv (2)
warning: matrix singular to machine precision
ans = 0.5000


Anonymous

 

(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 mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by arb (Posted a comment)
  •  

    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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-01-03 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2021-12-26 rik5 StatusConfirmed Ready For Test
        Releasedev 7.0.90
    2021-12-23 rik5 StatusNone Confirmed
        Assigned toNone rik5

    Back to the top

    Powered by Savane 3.13-aa77.
    Corresponding source code