bugGNU Octave - Bugs: bug #41065, Single precision matrix inverse...

 
 

bug #41065: Single precision matrix inverse gives bogus singular matrix warning

Submitter:  None
Submitted:  Thu 02 Jan 2014 02:25:17 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  jordigh
Originator Name:  Zsbán Ambrus Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 08 Jan 2014 03:11:14 AM UTC, comment #5: 

Thinking about this a little more, I'm not sure the fix is the right thing to do.  We want to test rcond+1 == 1 but in float precision for floats and double precision for doubles.  What we are doing instead is always doing the test as a double.  I think that's wrong.  For example:


octave:2> x = eps ('single')
x =  1.1921e-07
octave:3> x = eps ('single') / 2
x =  5.9605e-08
octave:4> x + 1 == 1
ans =  1
octave:5> double (x) + 1 == 1
ans = 0


I also think this is worth applying to stable.  It seems bad if Octave can't even invert a simple float matrix without issuing a warning.  I checked in the following change on stable and merged it with gui-release and default:

  http://hg.savannah.gnu.org/hgweb/octave/rev/36057e2411f8

John W. Eaton <jwe>
Group administrator
Tue 07 Jan 2014 11:17:14 PM UTC, comment #4: 

The patch looked good so I committed it here (http://hg.savannah.gnu.org/hgweb/octave/rev/c0f036b5e292).  Closing report.

Rik <rik5>
Group administrator
Thu 02 Jan 2014 03:52:55 PM UTC, comment #3: 

Thank you for the patch Jordi, works perfect for me.

>> inv (single (eye (3) + 0))

ans =

   1  -0  -0
   0   1  -0
   0   0   1

No warnings occur.

Kai Torben Ohlhus <siko1056>
Group Member
Thu 02 Jan 2014 03:13:40 PM UTC, comment #2: 

Does this proposed patch fix the problem?

(file #30148)

Jordi Gutiérrez Hermoso <jordigh>
Group Member
Thu 02 Jan 2014 02:36:22 PM UTC, comment #1: 

This bug can be reproduced in the current development version too.

>> ver

----------------------------------------------------------------------
GNU Octave Version 4.1.0+
GNU Octave License: GNU General Public License
Operating System: Linux 3.11.0-14-generic #21-Ubuntu SMP Tue Nov 12 17:04:55 UTC 2013 x86_64
----------------------------------------------------------------------
no packages installed.

>> inv(single(1))

warning: inverse: matrix singular to machine precision, rcond = 0
ans =  1

Kai Torben Ohlhus <siko1056>
Group Member
Thu 02 Jan 2014 02:25:17 PM UTC, original submission:  

Dear octave devs,

It appears that the inv function can give a bogus warning about the input being a singular matrix even when I use a single precision matrix that is very far from singular.  The resulting inverse matrix I get seems to be correct, only the warning is wrong. 

Here is a transcript for the bug.


e:\ambrus\f\stereo\tmp\m>octave --no-init-file
GNU Octave, version 3.6.2
Copyright (C) 2012 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "i686-pc-mingw32".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.

 - Use `pkg list' to see a list of installed packages.
 - MSYS shell available (C:\Program Files (x86)\Octave-3.6.2\msys).
 - Graphics backend: qt.

octave-3.6.2.exe:1> inv(single(eye(3)+0))
warning: inverse: matrix singular to machine precision, rcond = 0
ans =

   1  -0  -0
   0   1  -0
   0   0   1

octave-3.6.2.exe:2>



Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #30148:  inv.patch added by jordigh (734B - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jordigh (Updated the item)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by None (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.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-01-07 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2014-01-02 jordigh Attached File- Added inv.patch, #30148
        StatusConfirmed Patch Submitted
        Assigned toNone jordigh
    2014-01-02 mtmiller StatusNone Confirmed
        Release3.6.2 dev
        Operating SystemMicrosoft Windows Any

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code