Hi I'm using f2py to wrap the lapack routine dgesvd, by compiling the dgesvd.f file and linking it against llapack, as explained here
according to the docstring, the dgesvd module has the signature:
dgesvd - Function signature:
dgesvd(jobu,jobvt,m,n,a,s,u,vt,work,lwork,info,[lda,ldu,ldvt])
Required arguments:
jobu : input string(len=1)
jobvt : input string(len=1)
m : input int
n : input int
a : input rank-2 array('d') with bounds (lda,*)
s : input rank-1 array('d') with bounds (*)
u : input rank-2 array('d') with bounds (ldu,*)
vt : input rank-2 array('d') with bounds (ldvt,*)
work : input rank-1 array('d') with bounds (*)
lwork : input int
info : input int
Optional arguments:
lda := shape(a,0) input int
ldu := shape(u,0) input int
ldvt := shape(vt,0) input int
Then I use the following ocde to call the module:
mat = rand(20,30)
out_u,out_s,out_vh = zeros((20,20)), zeros((20,)), zeros((30,30))
rows, cols = shape(mat)
workspace = zeros((rows*cols))
out_info = 0
dgesvd(jobu='S',
jobvt='S',
m=rows,
n=cols,
a=mat,
s=out_s,
u=out_u,
vt=out_vh,
work=workspace,
lwork=rows*cols,
info=out_info)
Which gives me the correct singular values stored in out_s
, but the matrices out_u
and out_vh
are still only filled with zeros, do I have to do something differently to get the left/right singular vectors as well ?
The code runs through, without any error, which means that out_info
is 0.
(The argument 'S' for jobu and jobvt tells the routine to compute only the first min(m,n) singular vectors. Changing it to 'A', does not make any difference)
Any Ideas are highly appreciated! Thanks Mischa