[SciPy-user] Not a number in linalg.svdvals
Nils Wagner
nwagner at mecha.uni-stuttgart.de
Tue Oct 22 05:52:29 EDT 2002
Pietro Berkes schrieb:
>
> The whole story is very strange: if the tests pass, then svdvals should be
> allright. Try inserting in svd, line 274 in decomp.py the following line:
>
> print u,s,v,info
>
> and maybe also
>
> print lwork
>
> Then call linalg.svdvals again, and look if 's' looks fine.
I have modified decomp.py according to your suggestion, that is in
decomp.py line 274
overwrite_a = overwrite_a or a1 is not a
gesdd, = get_lapack_funcs(('gesdd',),(a1,))
if gesdd.module_name[:7] == 'flapack':
lwork = calc_lwork.gesdd(gesdd.prefix,m,n,compute_uv)[1]
u,s,v,info = gesdd(a1,compute_uv = compute_uv, lwork = lwork,
overwrite_a = overwrite_a)
print u,s,v,info
print lwork
Please find attached my small test program. This is
the output
Compute singular values using svd
[[-0.01064368 0.93221664 -0.35956157 0.03967781]
[ 0.02760821 0.35939368 0.93265212 0.01529682]
[ 0.35956157 -0.03967781 -0.01064368 0.93221664]
[-0.93265212 -0.01529682 0.02760821 0.35939368]] [ 1.29446282
1.00042554 0.99970394 0.72808433] [[-0.40511624 0.91346254
-0.01377785 0.0357378 ]
[ 0.02830277 0.01255214 0.93261333 0.35954662]
[ 0.01552803 -0.03501285 -0.35945512 0.932376 ]
[-0.91369506 -0.40521936 0.02888879 0.01113738]] 0
140
Singular values using svd
[ 1.29446282 1.00042554 0.99970394 0.72808433]
Compute singular values using svdvals
[ [ 0.]] [ nan nan
nan nan] [ [ 0.]] 0
268
Singular values using svdvals
[ nan nan nan
nan]
Nils
>
> Pietro.
>
> On Tuesday 22 October 2002 10:17, you wrote:
> > Pearu,
> >
> > I have removed the whole scipy installation. Then I have reinstalled
> > scipy
> > using latest CVS, but the problem with linalg.svdvals(A)
> >
> > [ nan nan nan
> > nan]
> >
> > is still there.
> >
> > svdvals is defined in decomp.py and afaik it uses svd, but svd works
> > well here.
> >
> > It is exasperating !
> >
> > Any idea ?
> >
> > Nils
> >
> > > _______________________________________________
> > > SciPy-user mailing list
> > > SciPy-user at scipy.net
> > > http://www.scipy.net/mailman/listinfo/scipy-user
> >
> > _______________________________________________
> > SciPy-user mailing list
> > SciPy-user at scipy.net
> > http://www.scipy.net/mailman/listinfo/scipy-user
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
-------------- next part --------------
from scipy import *
from scipy.linalg import *
A = array(([ 0. , 0. , 1. , 0. ],
[ 0. , 0. , 0. , 1. ],
[-0.81, 0.15, -0.02, 0. ],
[ 0.25, -1.21, 0. , -0.02]))
print
print 'Compute singular values using svd'
print
u,s,v = svd(A)
print
print 'Singular values using svd'
print
print s
print
print 'Compute singular values using svdvals'
print
s1 = svdvals(A)
print
print 'Singular values using svdvals'
print
print s1
More information about the SciPy-User
mailing list