Camm Maguire <camm@enhanced.com> writes:
2) Given the error code, and the scaling behavior with matrix size,
I'd say the lwork parameter (size of the work array) passed to
dgesdd is not always large enough, i.e. is not scaling properly
with n,m. Please see 'man dgesdd' for interpretations of the error
code. It is the responsibility of the calling routine to allocate
and pass the work array to dgesdd. With most lapack routines, one
can make a 'workspace query' call first by setting lwork to -1, or
some such. check the man page for details. This of course would
have to be done with each change in n,m. Alternatively, you could
take the minimum workspace requirements from the manpage.
Right, but that's actually what we do, use the workspace query. It's
all very weird, because the -12 value indicates that the lwork
parameter is wrong, but it is computed from an exactly identical call,
except lwork=-l:
lwork = -1;
F77_CALL(dgesdd)(CHAR(STRING_ELT(jobu, 0)),
&n, &p, xvals, &n, REAL(s),
REAL(u), &ldu,
REAL(v), &ldvt,
&tmp, &lwork, iwork, &info);
lwork = (int) tmp;