LinearAlgebraError: SVD did not converge

Damian Menscher menscher+python at uiuc.edu
Wed Aug 28 01:07:20 CEST 2002


Damian Menscher <menscher+python at uiuc.edu> wrote:
> Fernando P?rez <fperez528 at yahoo.com> wrote:
>> Damian Menscher wrote:

>>> You say "the SVD decomposition always exists".  I agree.  But
>>> apparently LinearAlgebra.singular_value_decomposition() doesn't
>>> know that.

>> Mmmhh, then it looks like it's time to debug 
>> LinearAlgebra.singular_value_decomposition(). Not exactly what you wanted to 
>> hear, is it? :)

> Yeah, I tried that.  But the routine doesn't actually do any work.
> It just calls lapack_lite.dgesdd.  And, that's just a .so file.  I
> downloaded the source, and it's really scary stuff.  Porting a
> Fortran math library to C and then calling it from Python is not
> the best way to get readable code!

> Printing out the singular values the routine comes up with just
> before it realizes it "didn't converge" indicates the condition
> number of the matrix is about 1e8.  That corresponds well with the
> other matrices I'm inverting.  Given that it apparently is taking
> an iterative approach, my current plan is to modify the code to
> increase the max number of iterations.

Ok, so after several hours of trying to read that code, I found
the parameter that needs to be tuned.  In case anyone has this
problem and finds this thread a year from now, here's your hint:

File: Src/dlapack_lite.c
Subroutine: dlasd4_
Line: 22562

There's a for loop there that limits the number of iterations to
20.  Increasing this value to 50 allows my matrix to converge.
I have not bothered to test what the "best" value for this number
is, though.  In any case, it appears the number just exists to
prevent infinite loops, and 50 isn't really that much closer to
infinity than 20....  (Actually, I'm just going to set it to 100
so I don't have to think about it ever again.)

Damian Menscher
-- 
-=#| Physics Grad Student & SysAdmin @ U Illinois Urbana-Champaign |#=-
-=#| 488 LLP, 1110 W. Green St, Urbana, IL 61801 Ofc:(217)333-0038 |#=-
-=#| 1412 DCL, Workstation Services Group, CITES Ofc:(217)244-3862 |#=-
-=#| <menscher at uiuc.edu> www.uiuc.edu/~menscher/ Fax:(217)333-9819 |#=-



More information about the Python-list mailing list