Ticket #12011: trac_12011-cvxopt.patch

File trac_12011-cvxopt.patch, 8.7 KB (added by jhpalmieri, 10 years ago)

patch for cvxopt spkg; for review only

  • SPKG.txt

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1333219637 25200
    # Node ID baa1a11d8ae18b4a1ffe646909db6bfc12edd724
    # Parent  c2c47c967f07b0f371ae62089378730f65242323
    #12011: upgrade to verion 1.1.4, and import an upstream fix from 1.1.5
    so self-tests pass on OS X Lion.
    
    diff --git a/SPKG.txt b/SPKG.txt
    a b GNU Lesser General Public License, v2.1. 
    3838
    3939== Special Update/Build Instructions ==
    4040
     41 * cvxopt.h.patch: TODO: document the reasons for this patch!
     42
     43 * setup.py.patch: look for ATLAS (etc.) in SAGE_ROOT/local/lib
     44   instead of /usr/lib. TODO: more details for this patch.
     45
     46 * dense.c.patch: this incorporates upstream changes from version
     47   1.1.5, fixing a bug to allow self-tests to pass on OS X 10.7
     48   (Lion). When upgrading CVXOPT to version 1.1.5, this patch can be
     49   removed.
     50
    4151 * TODO: incorporate docs buiding into spkg-install, and/or merge into
    4252   Sage documentation
    4353 
    GNU Lesser General Public License, v2.1. 
    5060
    5161== Changelog ==
    5262
     63=== cvxopt-1.1.4.p0 (John Palmieri, 31 March 2012) ===
     64 * Upgrade to version 1.1.4.
     65 * Trac #12011: apply upstream fix (from 1.1.5) to fix self-tests on
     66   OS X Lion.
     67
    5368=== cvxopt-1.1.3.p1 (Jeroen Demeyer, 23 February 2012) ===
    5469 * Trac #12519: Do not add -lcblas and -latlas on Darwin, since those
    5570   libraries aren't installed on Darwin.
  • patches/cvxopt.h.patch

    diff --git a/patches/cvxopt.h.patch b/patches/cvxopt.h.patch
    a b  
    1 diff -ru src/src/C/cvxopt.h src.patched/src/C/cvxopt.h
    2 --- src/src/C/cvxopt.h  2010-09-16 06:52:51.000000000 +0200
    3 +++ src.patched/src/C/cvxopt.h  2010-10-12 00:11:27.000000000 +0200
    4 @@ -27,7 +27,21 @@
     1--- src/src/C/cvxopt.h  2011-12-21 13:53:49.000000000 -0800
     2+++ src.patched/src/C/cvxopt.h  2012-03-31 10:13:43.000000000 -0700
     3@@ -27,8 +27,22 @@
    54 /* ANSI99 complex is disabled during build of CHOLMOD */
    65 
    76 #ifndef NO_ANSI99_COMPLEX
    87-#include "complex.h"
     8-#define MAT_BUFZ(O)  ((complex *)((matrix *)O)->buffer)
    99+
    1010+#include <complex.h>
    1111+/* work around Solaris 10 specific problem in complex.h */
    diff -ru src/src/C/cvxopt.h src.patched/ 
    2121+    #endif
    2222+ #endif
    2323+
    24  #define MAT_BUFZ(O)  ((complex *)((matrix *)O)->buffer)
     24+#define MAT_BUFZ(O)  ((complex *)((matrix *)O)->buffer)
    2525 #endif
    2626 
    27 @@ -55,7 +69,7 @@
    28  typedef struct {
    29    PyObject_HEAD
    30    void *buffer;          /* in column-major-mode array of type 'id' */
     27 #ifndef __CVXOPT__
     28@@ -49,7 +63,7 @@
     29   int_t strides[2];
     30   int_t ob_exports;
     31 #else
    3132-  int_t nrows, ncols;    /* number of rows and columns */
    3233+  int nrows, ncols;    /* number of rows and columns */
     34 #endif
    3335   int   id;              /* DOUBLE, INT, COMPLEX */
    3436 } matrix;
    35  
  • new file patches/dense.c.patch

    diff --git a/patches/dense.c.patch b/patches/dense.c.patch
    new file mode 100644
    - +  
     1--- src/src/C/dense.c   2011-12-21 13:53:49.000000000 -0800
     2+++ src/patched/src/C/dense.c   2012-03-25 17:05:23.000000000 -0700
     3@@ -1478,16 +1479,28 @@
     4       matrix *ret = Matrix_NewFromMatrix((matrix *)other, id);
     5       if (!ret) return PyErr_NoMemory();
     6 
     7-      int lgt = MAT_LGT(ret), int1 = 1, int0 = 0;
     8-      axpy[id](&lgt, &One[id], &n, &int0, ret->buffer, &int1);
     9+      int lgt = MAT_LGT(ret); int i;
     10+      switch (id) {
     11+        case INT:
     12+          for (i=0; i<lgt; i++) MAT_BUFI(ret)[i] += n.i;
     13+          break;
     14+        case DOUBLE:
     15+          for (i=0; i<lgt; i++) MAT_BUFD(ret)[i] += n.d;
     16+          break;
     17+        case COMPLEX:
     18+          for (i=0; i<lgt; i++) MAT_BUFZ(ret)[i] += n.z;
     19+          break;
     20+      }
     21       return (PyObject *)ret;
     22     }
     23     else {
     24       convert_num[id](&n,other,(Matrix_Check(other) ? 0 : 1),0);
     25 
     26-      int int1 = 1, int0 = 0;
     27-      axpy[id](&int1, &One[id], &n, &int0, MAT_BUF(self), &int1);
     28-
     29+      switch (id) {
     30+        case INT:     MAT_BUFI(self)[0] += n.i; break;
     31+        case DOUBLE:  MAT_BUFD(self)[0] += n.d; break;
     32+        case COMPLEX: MAT_BUFZ(self)[0] += n.z; break;
     33+      }
     34       Py_INCREF(self);
     35       return self;
     36     }
     37@@ -1503,14 +1516,34 @@
     38       matrix *ret = Matrix_NewFromMatrix((matrix *)self, id);
     39       if (!ret) return PyErr_NoMemory();
     40 
     41-      int lgt = MAT_LGT(self), int1 = 1, int0 = 0;
     42-      axpy[id](&lgt, &One[id], &n, &int0, ret->buffer, &int1);
     43+      int lgt = MAT_LGT(self); int i;
     44+      switch (id) {
     45+        case INT:
     46+          for (i=0; i<lgt; i++) MAT_BUFI(ret)[i] += n.i;
     47+          break;
     48+        case DOUBLE:
     49+          for (i=0; i<lgt; i++) MAT_BUFD(ret)[i] += n.d;
     50+          break;
     51+        case COMPLEX:
     52+          for (i=0; i<lgt; i++) MAT_BUFZ(ret)[i] += n.z;
     53+          break;
     54+      }
     55 
     56       return (PyObject *)ret;
     57     }
     58     else {
     59-      int lgt = MAT_LGT(self), int1 = 1, int0 = 0;
     60-      axpy[id](&lgt, &One[id], &n, &int0, MAT_BUF(self), &int1);
     61+      int lgt = MAT_LGT(self); int i;
     62+      switch (id) {
     63+        case INT:
     64+          for (i=0; i<lgt; i++) MAT_BUFI(self)[i] += n.i;
     65+          break;
     66+        case DOUBLE:
     67+          for (i=0; i<lgt; i++) MAT_BUFD(self)[i] += n.d;
     68+          break;
     69+        case COMPLEX:
     70+          for (i=0; i<lgt; i++) MAT_BUFZ(self)[i] += n.z;
     71+          break;
     72+      }
     73 
     74       Py_INCREF(self);
     75       return self;
     76@@ -1584,16 +1617,28 @@
     77       matrix *ret = Matrix_NewFromMatrix((matrix *)other, id);
     78       if (!ret) return PyErr_NoMemory();
     79 
     80-      int lgt = MAT_LGT(ret), int1 = 1, int0 = 0;
     81-      scal[id](&lgt, &MinusOne[id], ret->buffer, &int1);
     82-      axpy[id](&lgt, &One[id], &n, &int0, ret->buffer, &int1);
     83+      int lgt = MAT_LGT(ret); int i;
     84+      switch (id) {
     85+        case INT:
     86+          for (i=0; i<lgt; i++) MAT_BUFI(ret)[i] = n.i - MAT_BUFI(ret)[i];
     87+          break;
     88+        case DOUBLE:
     89+          for (i=0; i<lgt; i++) MAT_BUFD(ret)[i] = n.d - MAT_BUFD(ret)[i];
     90+          break;
     91+        case COMPLEX:
     92+          for (i=0; i<lgt; i++) MAT_BUFZ(ret)[i] = n.z - MAT_BUFZ(ret)[i];
     93+          break;
     94+      }
     95       return (PyObject *)ret;
     96     }
     97     else {
     98       convert_num[id](&n,other,(Matrix_Check(other) ? 0 : 1),0);
     99 
     100-      int int1 = 1, int0 = 0;
     101-      axpy[id](&int1, &MinusOne[id], &n, &int0, MAT_BUF(self), &int1);
     102+      switch (id) {
     103+        case INT:     MAT_BUFI(self)[0] -= n.i; break;
     104+        case DOUBLE:  MAT_BUFD(self)[0] -= n.d; break;
     105+        case COMPLEX: MAT_BUFZ(self)[0] -= n.z; break;
     106+      }
     107 
     108       Py_INCREF(self);
     109       return self;
     110@@ -1609,14 +1654,34 @@
     111       matrix *ret = Matrix_NewFromMatrix((matrix *)self, id);
     112       if (!ret) return PyErr_NoMemory();
     113 
     114-      int lgt = MAT_LGT(self), int1 = 1, int0 = 0;
     115-      axpy[id](&lgt, &MinusOne[id], &n, &int0, ret->buffer, &int1);
     116+      int lgt = MAT_LGT(self); int i;
     117+      switch (id) {
     118+        case INT:
     119+          for (i=0; i<lgt; i++) MAT_BUFI(ret)[i] -= n.i;
     120+          break;
     121+        case DOUBLE:
     122+          for (i=0; i<lgt; i++) MAT_BUFD(ret)[i] -= n.d;
     123+          break;
     124+        case COMPLEX:
     125+          for (i=0; i<lgt; i++) MAT_BUFZ(ret)[i] -= n.z;
     126+          break;
     127+      }
     128 
     129       return (PyObject *)ret;
     130     }
     131     else {
     132-      int lgt = MAT_LGT(self), int1 = 1, int0 = 0;
     133-      axpy[id](&lgt, &MinusOne[id], &n, &int0, MAT_BUF(self), &int1);
     134+      int lgt = MAT_LGT(self); int i;
     135+      switch (id) {
     136+        case INT:
     137+          for (i=0; i<lgt; i++) MAT_BUFI(self)[i] -= n.i;
     138+          break;
     139+        case DOUBLE:
     140+          for (i=0; i<lgt; i++) MAT_BUFD(self)[i] -= n.d;
     141+          break;
     142+        case COMPLEX:
     143+          for (i=0; i<lgt; i++) MAT_BUFZ(self)[i] -= n.z;
     144+          break;
     145+      }
     146 
     147       Py_INCREF(self);
     148       return self;
  • patches/setup.py.patch

    diff --git a/patches/setup.py.patch b/patches/setup.py.patch
    a b  
    1 diff -ru src/src/setup.py src.patched/src/setup.py
    2 --- src/src/setup.py    2010-09-16 06:55:00.000000000 +0200
    3 +++ src.patched/src/setup.py    2012-02-16 11:14:40.338372823 +0100
     1--- src/src/setup.py    2011-12-21 13:53:49.000000000 -0800
     2+++ src.patched/src/setup.py    2012-03-31 11:23:29.000000000 -0700
    43@@ -1,18 +1,39 @@
    54 from distutils.core import setup, Extension
    65 from glob import glob
    diff -ru src/src/setup.py src.patched/sr 
    140139         'C/SuiteSparse/UMFPACK/Source/umfpack_global.c',
    141140         'C/SuiteSparse/UMFPACK/Source/umfpack_tictoc.c' ] +
    142141@@ -117,8 +138,8 @@
    143  if sys.maxint > 2**31: MACROS += [('DLONG','')]
     142 if sys.maxsize > 2**31: MACROS += [('DLONG','')]
    144143 
    145144 cholmod = Extension('cholmod',
    146145-    library_dirs = [ ATLAS_LIB_DIR ],
    diff -ru src/src/setup.py src.patched/sr 
    172171+
    173172 setup (name = 'cvxopt',
    174173     description = 'Convex optimization package',
    175      version = '1.1.3',
     174     version = '1.1.4',