[SciPy-user] Not a number in linalg.svdvals

Nils Wagner nwagner at mecha.uni-stuttgart.de
Tue Oct 22 07:20:04 EDT 2002


Pearu Peterson schrieb:
> 
> On Tue, 22 Oct 2002, Nils Wagner wrote:
> 
> > 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
> 
> Can you send the output of:
> 
>     overwrite_a = overwrite_a or a1 is not a
>     gesdd, = get_lapack_funcs(('gesdd',),(a1,))
>     if gesdd.module_name[:7] == 'flapack':
>         print 'prefix=',gesdd.prefix
>         print 'm,n,compute_uv=',m,n,compute_uv
>         lwork = calc_lwork.gesdd(gesdd.prefix,m,n,compute_uv)[1]
>         print 'a1=',a1
>         u,s,v,info = gesdd(a1,compute_uv = compute_uv, lwork = lwork,
>                       overwrite_a = overwrite_a)
>         print ':a1=',a1
>         print 'u=',u
>         print 'v=',v
>         print 'info,lwork=',info,lwork
> 
Yes. Here it comes

Compute singular values using svd

prefix= d
m,n,compute_uv= 4 4 1
a1= [[ 0.    0.    1.    0.  ]
 [ 0.    0.    0.    1.  ]
 [-0.81  0.15 -0.02  0.  ]
 [ 0.25 -1.21  0.   -0.02]]
:a1= [[ 0.    0.    1.    0.  ]
 [ 0.    0.    0.    1.  ]
 [-0.81  0.15 -0.02  0.  ]
 [ 0.25 -1.21  0.   -0.02]]
u= [[-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]]
v= [[-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]]
info,lwork= 0 140

Singular values using svd

[ 1.29446282  1.00042554  0.99970394  0.72808433]

Compute singular values using svdvals

prefix= d
m,n,compute_uv= 4 4 0
a1= [[ 0.    0.    1.    0.  ]
 [ 0.    0.    0.    1.  ]
 [-0.81  0.15 -0.02  0.  ]
 [ 0.25 -1.21  0.   -0.02]]
:a1= [[ 0.    0.    1.    0.  ]
 [ 0.    0.    0.    1.  ]
 [-0.81  0.15 -0.02  0.  ]
 [ 0.25 -1.21  0.   -0.02]]
u= [ [ 0.]]
v= [ [ 0.]]
info,lwork= 0 268

Singular values using svdvals

[              nan               nan               nan              
nan]

> Try also different input arrays. E.g. A=[[1,2],[3,4]]
> 
That is strange. It works fine in this case

Compute singular values using svd

prefix= d
m,n,compute_uv= 2 2 1
a1= [[ 1.  2.]
 [ 3.  4.]]
:a1= [[ 1.  2.]
 [ 3.  4.]]
u= [[-0.40455358 -0.9145143 ]
 [-0.9145143   0.40455358]]
v= [[-0.57604844 -0.81741556]
 [ 0.81741556 -0.57604844]]
info,lwork= 0 70

Singular values using svd

[ 5.4649857   0.36596619]

Compute singular values using svdvals

prefix= d
m,n,compute_uv= 2 2 0
a1= [[ 1.  2.]
 [ 3.  4.]]
:a1= [[ 1.  2.]
 [ 3.  4.]]
u= [ [ 0.]]
v= [ [ 0.]]
info,lwork= 0 134

Singular values using svdvals

[ 5.4649857   0.36596619]

Nils

> Pearu
> 
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user



More information about the SciPy-User mailing list