bugGNU Octave - Bugs: bug #49690, inv(inf) behaves differently from...

 
 

bug #49690: inv(inf) behaves differently from inf^-1, 1/inf, inf\1

Submitter:  None
Submitted:  Thu 24 Nov 2016 08:06:58 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  3 - Low Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 30 Nov 2016 12:47:44 AM UTC, comment #7: 

Thanks for checking.  I pushed a cset to fix this here (http://hg.savannah.gnu.org/hgweb/octave/rev/1d242ae72240).

Closing report.

Rik <rik5>
Group administrator
Tue 29 Nov 2016 09:59:32 PM UTC, comment #6: 

MATLAB's result:


>> x = complex (1, inf);
>> 1 / x
ans =
     0


which is also mathematically correct in complex plane.

Eddy <count>
Tue 29 Nov 2016 01:37:19 AM UTC, comment #5: 

The trouble was actually buried in liboctave where we are changing the matrix to all Inf if the reciprical condition number is 0.

I've fixed things for the ordinary cases.  But what does Matlab do for


x = complex (1, inf);
1 / x


When I have the answer for that I can make inverse(x) and 1 / x yield the same result across all inputs.

Rik <rik5>
Group administrator
Sat 26 Nov 2016 04:03:18 AM UTC, comment #4: 

I think it should be properly handled in liboctave because inv.cc is part of the interpreter and there is no reason someone might not write their own C++ file and link to liboctave to have access to Arrays and matrix functions.  An obvious case would be someone writing a .oct file.

Rik <rik5>
Group administrator
Fri 25 Nov 2016 05:37:24 PM UTC, comment #3: 

The inv function has a special case for diagonal matrices, a special case for permutation matrices, and then the general case. Unfortunately a scalar is not recognized as a diagonal matrix here, so it falls into the general case which uses a different algorithm.

It might be nice to add another special case to inv.cc to handle a scalar directly without going to the Array library.

Mike Miller <mtmiller>
Group Member
Fri 25 Nov 2016 03:50:23 AM UTC, comment #2: 

Besides, inv() returns incorrect result only for scalar Inf.
All of them return correct results for matrices:

octave:1>  inv(diag([inf inf]))
ans =

Diagonal Matrix

   0   0
   0   0

octave:2>  inv([inf 0;0 inf])
warning: matrix singular to machine precision
ans =

   0   0
   0   0

octave:3>  diag([inf inf])^-1
ans =

Diagonal Matrix

   0   0
   0   0

octave:4>  [inf 0;0 inf]^-1
ans =

   0   0
   0   0

octave:5>  diag([inf inf])\eye(2)
ans =

Diagonal Matrix

   0   0
   0   0

octave:6>  [inf 0;0 inf]\eye(2)
warning: matrix singular to machine precision
ans =

   0   0
   0   0

octave:7>  eye(2)/diag([inf inf])
ans =

Diagonal Matrix

   0   0
   0   0

octave:8>  eye(2)/[inf 0;0 inf]
warning: matrix singular to machine precision
ans =

   0   0
   0   0


Anonymous
Thu 24 Nov 2016 02:37:32 PM UTC, comment #1: 

Confirmed on 4.2.0.  It's not a big deal--the inv function is really meant for matrices rather than scalars--but it would be nice to get the same results out of all of the different operators.

Rik <rik5>
Group administrator
Thu 24 Nov 2016 08:06:58 AM UTC, original submission:  


octave:1>  inv(inf)
warning: matrix singular to machine precision
ans = Inf
octave:2>  inf^-1
ans = 0
octave:3>  inf\1
ans = 0
octave:4>  1/inf
ans = 0


I'm not sure whether this is a bug since "inf" is not a finite value, and I'm not sure whether it is required that inv() should behave exactly as ()^-1 .
Also, I'm sorry that I have no Octave 4.2.0 installed so I could not help to test this on the new released version.

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 count (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-30 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-11-25 mtmiller Priority5 - Normal 3 - Low
        Release4.2.0 dev
    2016-11-24 rik5 StatusNone Confirmed
        Release4.0.3 4.2.0

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code