[SciPy-user] Bug in inverse matrix calculation for "scipy_core-0.8.4.win32-py2.3.exe"

Randewijk P-J <pjrandew@sun.ac.za> pjrandew at sun.ac.za
Wed Dec 14 08:43:20 CST 2005


Dear Travis,
 
Thank-you for the "silent" version (0.8.4) of scipy_core.
 
Unfortunately when trying to invert a singular matrix using scipy_core
0.8.4, python "crashes" instead of issuing the usual error message:
 
...
>>> m.I
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python\Lib\site-packages\scipy\base\matrix.py", line 197, in
getI
    return matrix(linalg.inv(self))
  File "C:\Python\Lib\site-packages\scipy\linalg\basic.py", line 221, in
inv
    if info>0: raise LinAlgError, "singular matrix"
LinAlgError: singular matrix
>>> 
...
 
On this note.  Is there a way of determining before hand in scipy if a
matrix is singular, say by calculating its rank, e.g.:
 
...
>>> if matrix_rank(my_matrix) < max(my_matrix.shape):
...
 
And then if the matrix is singular, is there a way in scipy to calculate
the reduced row-echelon form (RREF) for a linear system of equation,
a.k.a. linalg.solve, e.g.
 
...
>>> linalg.rref(a,b)
...
 
http://en.wikipedia.org/wiki/Gauss-Jordan_elimination shows a "formal
algorithm" to calculate reduced row-echelon matrix.
 
Its looks easy to implement in ("high level") python, but a "low level"
implementation in scipy would be "nice"... 
(for lazy people like myself)
 
Regards,
 
Peter-Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.scipy.net/pipermail/scipy-user/attachments/20051214/495a7b1c/attachment.htm


More information about the SciPy-user mailing list