diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-11-02 04:35:04 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-11-02 04:35:04 +0000 |
commit | 39242cbff4ad887be3d0d46dd348f769d6729d82 (patch) | |
tree | dc2eb581310ce44f71daa0b3ec16c514e3c38692 /numpy/linalg/lapack_litemodule.c | |
parent | a39c1cd2e4ec42adfdd548da86ae36a9241a58da (diff) | |
download | numpy-39242cbff4ad887be3d0d46dd348f769d6729d82.tar.gz |
Fix problem with dgesdd where the optimal work size is not computed correctly.
Diffstat (limited to 'numpy/linalg/lapack_litemodule.c')
-rw-r--r-- | numpy/linalg/lapack_litemodule.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/numpy/linalg/lapack_litemodule.c b/numpy/linalg/lapack_litemodule.c index 12484480e..0cb2c8bcc 100644 --- a/numpy/linalg/lapack_litemodule.c +++ b/numpy/linalg/lapack_litemodule.c @@ -437,6 +437,33 @@ lapack_lite_dgesdd(PyObject *self, PyObject *args) DDATA(vt),&ldvt,DDATA(work),&lwork,IDATA(iwork), &info); + if (info == 0 && lwork == -1) { + /* We need to check the result because + sometimes the "optimal" value is actually + too small. + Change it to the maximum of the minimum and the optimal. + */ + long nwork, work0 = (long) *DDATA(work); + int mn = MIN(m,n); + int mx = MAX(m,n); + switch(jobz){ + case 'N': + nwork = MAX(work0,3*mn + MAX(mx,6*mn)+500); + break; + case 'O': + nwork = MAX(work0,3*mn*mn + \ + MAX(mx,5*mn*mn+4*mn+500)); + break; + case 'S': + case 'A': + nwork = MAX(work0,3*mn*mn + \ + MAX(mx,4*mn*(mn+1))+500); + break; + defaul: + nwork = work0; + } + *DDATA(work) = (double) nwork; + } return Py_BuildValue("{s:i,s:c,s:i,s:i,s:i,s:i,s:i,s:i,s:i}","dgesdd_", lapack_lite_status__,"jobz",jobz,"m",m,"n",n, "lda",lda,"ldu",ldu,"ldvt",ldvt,"lwork",lwork, |