[Numpy-discussion] Inversion of near singular matrices.

Algis Kabaila akabaila at pcug.org.au
Sat Jan 29 06:40:05 EST 2011


I am interested in determining if a matrix is singular or 
"nearly singular" - very ill conditioned.  The problem occurs in 
structural engineering applications.

My OS is kubuntu 10.10 (32 bit)
Python 2.6.6
numpy and numpy.linalg  binaries from ubuntu repositories.

The attached tar ball has a little CLI script that generates 
singular or near singular matrices (because of the inevitable 
roundoffs) for matrices with elements from sequence 1, 2, 3, 4 

The dimension of matrix nn can be passed as command line 
parameter via sys.argv[1] .  If argv[1] does not exist, the 5x5 
default matrix is used.
for nn = 3 and 4 numpy does not raise an exception
for nn = 5 it does raise an exception
for nn = 6, 7 np not raises exception
for nn = 8     np does raise exception
for nn = 9     np does not raise exception
for higher nn values np mostly raises the exception, but for nn 
= 23 and nn=120 it does NOT raise the exception.

It is worht noting that in practical problems of engineering 
analyisis the ill conditioned matrix is not "exact" - there 
always are approximations and roundoff errors.

So my question is: how can one reliably detect singularity (or 
near singularity) and raise an exception?

Many thanks for your attention,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: inversion.tar.gz
Type: application/x-compressed-tar
Size: 1089 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110129/223da9e5/attachment.bin>

More information about the NumPy-Discussion mailing list