[Numpy-svn] r3424 - in trunk/numpy: core/include/numpy core/src linalg

numpy-svn at scipy.org numpy-svn at scipy.org
Wed Nov 1 22:35:12 CST 2006


Author: oliphant
Date: 2006-11-01 22:35:04 -0600 (Wed, 01 Nov 2006)
New Revision: 3424

Modified:
   trunk/numpy/core/include/numpy/ndarrayobject.h
   trunk/numpy/core/src/multiarraymodule.c
   trunk/numpy/linalg/lapack_litemodule.c
   trunk/numpy/linalg/linalg.py
Log:
Fix problem with dgesdd where the optimal work size is not computed correctly.

Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2006-11-01 10:09:49 UTC (rev 3423)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2006-11-02 04:35:04 UTC (rev 3424)
@@ -1114,8 +1114,7 @@
 #define NPY_ITEM_HASOBJECT  0x01  /* Same as needing REFCOUNT */
 
 #define NPY_LIST_PICKLE     0x02  /* Convert to list for pickling */
-#define NPY_ITEM_IS_POINTER 0x06  /* The item is a POINTER -- automatic
-                                     LIST_PICKLE       */
+#define NPY_ITEM_IS_POINTER 0x04  /* The item is a POINTER  */
 
 #define NPY_NEEDS_INIT      0x08  /* memory needs to be initialized 
                                      for this data-type */

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2006-11-01 10:09:49 UTC (rev 3423)
+++ trunk/numpy/core/src/multiarraymodule.c	2006-11-02 04:35:04 UTC (rev 3424)
@@ -7243,6 +7243,7 @@
         ADDCONST(NEEDS_INIT);
         ADDCONST(NEEDS_PYAPI);
         ADDCONST(USE_GETITEM);
+        ADDCONST(USE_SETITEM);
 
         ADDCONST(RAISE);
         ADDCONST(WRAP);

Modified: trunk/numpy/linalg/lapack_litemodule.c
===================================================================
--- trunk/numpy/linalg/lapack_litemodule.c	2006-11-01 10:09:49 UTC (rev 3423)
+++ trunk/numpy/linalg/lapack_litemodule.c	2006-11-02 04:35:04 UTC (rev 3424)
@@ -437,6 +437,33 @@
                           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,

Modified: trunk/numpy/linalg/linalg.py
===================================================================
--- trunk/numpy/linalg/linalg.py	2006-11-01 10:09:49 UTC (rev 3423)
+++ trunk/numpy/linalg/linalg.py	2006-11-02 04:35:04 UTC (rev 3424)
@@ -590,15 +590,6 @@
         results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,
                                  work, -1, iwork, 0)
         lwork = int(work[0])
-        if option == 'N' and lwork==1:
-            # there seems to be a bug in dgesdd of lapack
-            #   (NNemec, 060310)
-            # returning the wrong lwork size for option == 'N'
-            results = lapack_routine('A', m, n, a, m, s, u, m, vt, n,
-                                     work, -1, iwork, 0)
-            lwork = int(work[0])
-            assert lwork > 1
-
         work = zeros((lwork,), t)
         results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,
                                  work, lwork, iwork, 0)



More information about the Numpy-svn mailing list