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

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

[Octave-bug-tracker] [bug #46103] inversion of a singular diagonal matri


From: jan
Subject: [Octave-bug-tracker] [bug #46103] inversion of a singular diagonal matrix A produces inv(A)==A
Date: Sat, 03 Oct 2015 06:42:08 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0

Follow-up Comment #14, bug #46103 (project octave):

Thank you everybody for quick replies. Still some comments: 

Indeed, diagonal (and e.g. permutation) matrices are one of the few, but
important, classes that (mathematically) preserve the very sparsity they
posess under inversion. In fact diagonal matrices form a group, so all
algebraic operations preserve this structure. I think this should be respected
in the code.  


Now, I, too, tried this in matlab with the following finndings

1) diag() produces a full matrix, i.e. no respective diagonal class exists.  

2) Under the  inversion of the sparse matrix a sparse result is produced. 

3)  the inversion of a spoarse matrix seems to be some Gaussian type of
elimimination with potential divisions by zero producing inf and divisions by
inf nan, without any warnings. This makes sense and I don't think this is a
bad solution. 


I would be more forgiving to matlab.  As a matter of principle: Producing infs
and nans as a natural product of (elementwise) operations (when feasible)
follows the principle of "least loss of information" and indeed makes the
debugging of operations in the code easiest. So I would still keep my vote for
alternative (a) in post #6. 

 



8.5.0.197613 (R2015a)

>> diag(0:2)           

ans =

     0     0     0
     0     1     0
     0     0     2

>> inv(sparse(diag(0:2)))           
Warning: Matrix is singular to working precision. 

ans =

   (1,1)          Inf
   (1,2)          NaN
   (2,2)       1.0000
   (1,3)          NaN
   (3,3)       0.5000

>> full(ans)

ans =

       Inf       NaN       NaN
         0    1.0000         0
         0         0    0.5000





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?46103>

_______________________________________________
  Meddelandet skickades via/av Savannah
  http://savannah.gnu.org/




reply via email to

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