[SciPy-user] Fixes to svd?

Nick Arnett narnett at mccmedia.com
Fri Oct 1 10:38:04 EDT 2004


In trying to use linalg.svd, I found that I had to make a couple of 
changes to decomp.py to get things to work... and I'm wondering if they 
were correct.  This is my first stab at using Scipy.

The first problem I hit was that Python didn't recognize the call to 
diag (part = diag(s)) in diagsvd.  Looking around for where that seemed 
to live, I decided to add matrix_base to the scipy_base imports:

from scipy_base import asarray_chkfinite, asarray, matrix_base

... and then changed the first line of diagsvd to:

part = matrix_base.diag(s)

That seems to work.

Just below, also in diagsvd, Python didn't recognize "zeros", which I'm 
assuming it should be getting from Numeric... and although I'm certain 
that Scipy is supposed to use Numeric, I couldn't see where it was being 
imported in decomp, so I added:

from Numeric import zeros

Now things seem to be working and the matrix produced by diagsvd looks 
reasonable, though I haven't yet done any of the really big matrices 
I'll be processing.

Any feedback on whether or not this was the appropriate way to fix things?

Nick




More information about the SciPy-User mailing list