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

Randewijk P-J <pjrandew@sun.ac.za> pjrandew at sun.ac.za
Thu Dec 15 01:38:53 CST 2005

```Dear Travis,

...
>>> os.environ['NO_SCIPY_IMPORT']='True'
>>> from scipy import *
Skip importing scipy packages (NO_SCIPY_IMPORT=True)
>>> k
matrix([[ 400.        ,  400.        ,    0.        ,    0.        ],
[   0.        ,    0.        ,  400.        ,  400.        ],
[   0.        ,  346.41016151,    0.        ,  173.20508076],
[ 346.41016151,    0.        ,  173.20508076,    0.        ]])
>>> k.I
Traceback (most recent call last):
File "<pyshell#5>", line 1, in ?
k.I
File "C:\Python\Lib\site-packages\scipy\base\matrix.py", line 204, in
getI
return matrix(linalg.inv(self))
File "C:\Python\Lib\site-packages\scipy\basic\basic_lite.py", line
103, in inverse
return solve_linear_equations(a, Numeric.identity(a.shape[0]))
File "C:\Python\Lib\site-packages\scipy\basic\basic_lite.py", line 93,
in solve_linear_equations
raise LinAlgError, 'Singular matrix'
LinAlgError: Singular matrix
>>>
...

Further to Nils & Fernando's comments, for the following singular matrix
k, and with 'NO_SCIPY_IMPORT'='True'

...
>>> k
matrix([[ 391.69663728,  407.81602433,    0.        ,    0.        ],
[   0.        ,    0.        ,  391.69663728,  407.81602433],
[   0.        ,  346.1991378 ,    0.        ,  183.56941791],
[ 346.1991378 ,    0.        ,  183.56941791,    0.        ]])
>>> k.I
matrix([[ -1.64892268e+13,  -8.74328513e+12,   1.94239968e+13,
1.86562414e+13],
[  1.58374716e+13,   8.39769695e+12,  -1.86562414e+13,
-1.79188325e+13],
[  3.10975335e+13,   1.64892268e+13,  -3.66323052e+13,
-3.51843721e+13],
[ -2.98683685e+13,  -1.58374716e+13,   3.51843721e+13,
3.37936702e+13]])
>>>
...

Both k matrixes fail however in full scipy... and shows the annoying
message, "pythonw.exe has encountered a problem and needs to close.  We
are sorry for the inconvenience."

My platform is winXP, py2.3 using the following binaries:
scipy_core-0.8.4.win32-py2.3.exe
scipy-0.4.3.win32-py2.3.exe

scipy_core-0.6.1.win32-py2.3.exe
and
scipy-0.4.3.win32-py2.3.exe

Doesn't works fine together...

PJR

P.S. How does the 'NO_SCIPY_IMPORT' environment variable work?

with

...
>>> os.environ['NO_SCIPY_IMPORT']=1

Traceback (most recent call last):
File "<pyshell#1>", line 1, in ?
os.environ['NO_SCIPY_IMPORT']=1  # this will not import full scipy
but
File "C:\Python\Lib\os.py", line 414, in __setitem__
putenv(key, item)
TypeError: putenv() argument 2 must be string, not int
...

"os.environ['NO_SCIPY_IMPORT']='True'" works, as shown at the top, but

...
>>> os.environ['NO_SCIPY_IMPORT']='False'
>>> from scipy import *
Skip importing scipy packages (NO_SCIPY_IMPORT=False)
>>>
...

Doesn't work as I would have expect it...

> -----Original Message-----
> From: scipy-user-bounces at scipy.net
> [mailto:scipy-user-bounces at scipy.net] On Behalf Of Travis Oliphant
> Sent: 15 December 2005 00:27
> To: SciPy Users List
> Subject: Re: [SciPy-user] Bug in inverse matrixcalculation
> for "scipy_core-0.8.4.win32-py2.3.exe"
>
>
> Randewijk P-J <pjrandew at sun.ac.za> wrote:
>
> > 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:
>
> I'm not seeing this. I'm getting the proper error message.
> Can you show
> the platform.
>
> Also, try it when the environment variable NO_SCIPY_IMPORT=1
>
> import os
> os.environ['NO_SCIPY_IMPORT']=1  # this will not import full
> scipy but
> use only scipy_core\
> import scipy
>
> Full scipy installs its own (hopefully better) matrix
> inverse.  We need
> to figure out which one is giving you trouble.
>
> -Travis
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
>

```