Description: minpack API types misfit on s390x
URL: http://projects.scipy.org/scipy/ticket/1700
Debian: http://bugs.debian.org/681270

Index: python-scipy-0.10.1+dfsg1/scipy/optimize/__minpack.h
===================================================================
--- python-scipy-0.10.1+dfsg1.orig/scipy/optimize/__minpack.h	2012-02-21 17:50:06.000000000 -0500
+++ python-scipy-0.10.1+dfsg1/scipy/optimize/__minpack.h	2012-07-21 17:05:14.270325178 -0400
@@ -63,7 +63,7 @@
   */
 
   PyArrayObject *result_array = NULL;
- 
+
   result_array = (PyArrayObject *)call_python_function(multipack_python_function, *n, x, multipack_extra_arguments, 1, minpack_error);
   if (result_array == NULL) {
     *iflag = -1;
@@ -122,7 +122,7 @@
   */
 
   PyArrayObject *result_array = NULL;
- 
+
   result_array = (PyArrayObject *)call_python_function(multipack_python_function,*n, x, multipack_extra_arguments, 1, minpack_error);
   if (result_array == NULL) {
     *iflag = -1;
@@ -161,7 +161,7 @@
       *iflag = -1;
       return -1;
     }
-    if (multipack_jac_transpose == 1) 
+    if (multipack_jac_transpose == 1)
       MATRIXC2F(fjac, result_array->data, *n, *ldfjac)
     else
       memcpy(fjac, result_array->data, (*n)*(*ldfjac)*sizeof(double));
@@ -231,6 +231,7 @@
   double   xtol = 1.49012e-8, epsfcn = 0.0, factor = 1.0e2;
   int      mode = 2, nprint = 0, info, nfev, ldfjac;
   npy_intp n,lr;
+  int      n_int, lr_int;  /* for casted storage to pass int into HYBRD */
   double   *x, *fvec, *diag, *fjac, *r, *qtf;
 
   PyArrayObject *ap_x = NULL, *ap_fvec = NULL;
@@ -242,7 +243,7 @@
   double   *wa = NULL;
 
   STORE_VARS();    /* Define storage variables for global variables. */
-  
+
   if (!PyArg_ParseTuple(args, "OO|OidiiiddO", &fcn, &x0, &extra_args, &full_output, &xtol, &maxfev, &ml, &mu, &epsfcn, &factor, &o_diag)) return NULL;
 
   INIT_FUNC(fcn,extra_args,minpack_error);
@@ -262,7 +263,7 @@
   ap_fvec = (PyArrayObject *)call_python_function(fcn, n, x, extra_args, 1, minpack_error);
   if (ap_fvec == NULL) goto fail;
   fvec = (double *) ap_fvec->data;
-  if (ap_fvec->nd == 0) 
+  if (ap_fvec->nd == 0)
     n = 1;
   else if (ap_fvec->dimensions[0] < n)
     n = ap_fvec->dimensions[0];
@@ -288,7 +289,8 @@
   allocated = 1;
 
   /* Call the underlying FORTRAN routines. */
-  HYBRD(raw_multipack_calling_function, &n, x, fvec, &xtol, &maxfev, &ml, &mu, &epsfcn, diag, &mode, &factor, &nprint, &info, &nfev, fjac, &ldfjac, r, &lr, qtf, wa, wa+n, wa+2*n, wa+3*n);
+  n_int = n; lr_int = lr; /* cast/store/pass into HYBRD */
+  HYBRD(raw_multipack_calling_function, &n_int, x, fvec, &xtol, &maxfev, &ml, &mu, &epsfcn, diag, &mode, &factor, &nprint, &info, &nfev, fjac, &ldfjac, r, &lr_int, qtf, wa, wa+n, wa+2*n, wa+3*n);
 
   RESTORE_FUNC();
 
@@ -332,6 +334,7 @@
   double   xtol = 1.49012e-8, factor = 1.0e2;
   int      mode = 2, nprint = 0, info, nfev, njev, ldfjac;
   npy_intp n, lr;
+  int n_int, lr_int;
   double   *x, *fvec, *diag, *fjac, *r, *qtf;
 
   PyArrayObject *ap_x = NULL, *ap_fvec = NULL;
@@ -388,7 +391,8 @@
   allocated = 1;
 
   /* Call the underlying FORTRAN routines. */
-  HYBRJ(jac_multipack_calling_function, &n, x, fvec, fjac, &ldfjac, &xtol, &maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, r, &lr, qtf, wa, wa+n, wa+2*n, wa+3*n);
+  n_int = n; lr_int = lr; /* cast/store/pass into HYBRJ */
+  HYBRJ(jac_multipack_calling_function, &n_int, x, fvec, fjac, &ldfjac, &xtol, &maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, r, &lr_int, qtf, wa, wa+n, wa+2*n, wa+3*n);
 
   RESTORE_JAC_FUNC();
 
@@ -420,7 +424,7 @@
   Py_XDECREF(ap_qtf);
   if (allocated) free(wa);
   return NULL;
-  
+
 }
 
 /************************ Levenberg-Marquardt *******************/
@@ -434,6 +438,7 @@
   double   gtol = 0.0, epsfcn = 0.0, factor = 1.0e2;
   int      m, mode = 2, nprint = 0, info, nfev, ldfjac, *ipvt;
   npy_intp n;
+  int      n_int;  /* for casted storage to pass int into LMDIF */
   double   *x, *fvec, *diag, *fjac, *qtf;
 
   PyArrayObject *ap_x = NULL, *ap_fvec = NULL;
@@ -486,14 +491,15 @@
   allocated = 1;
 
   /* Call the underlying FORTRAN routines. */
-  LMDIF(raw_multipack_lm_function, &m, &n, x, fvec, &ftol, &xtol, &gtol, &maxfev, &epsfcn, diag, &mode, &factor, &nprint, &info, &nfev, fjac, &ldfjac, ipvt, qtf, wa, wa+n, wa+2*n, wa+3*n);
-    
+  n_int = n; /* to provide int*-pointed storage for int argument of LMDIF */
+  LMDIF(raw_multipack_lm_function, &m, &n_int, x, fvec, &ftol, &xtol, &gtol, &maxfev, &epsfcn, diag, &mode, &factor, &nprint, &info, &nfev, fjac, &ldfjac, ipvt, qtf, wa, wa+n, wa+2*n, wa+3*n);
+
   RESTORE_FUNC();
 
   if (info < 0) goto fail;           /* Python error */
 
   free(wa);
-  Py_DECREF(extra_args); 
+  Py_DECREF(extra_args);
   Py_DECREF(ap_diag);
 
   if (full_output) {
@@ -517,7 +523,7 @@
   Py_XDECREF(ap_ipvt);
   Py_XDECREF(ap_qtf);
   if (allocated) free(wa);
-  return NULL;  
+  return NULL;
 }
 
 
@@ -530,6 +536,7 @@
   double   gtol = 0.0, factor = 1.0e2;
   int      m, mode = 2, nprint = 0, info, nfev, njev, ldfjac, *ipvt;
   npy_intp n;
+  int n_int;
   double   *x, *fvec, *diag, *fjac, *qtf;
 
   PyArrayObject *ap_x = NULL, *ap_fvec = NULL;
@@ -582,7 +589,8 @@
   allocated = 1;
 
   /* Call the underlying FORTRAN routines. */
-  LMDER(jac_multipack_lm_function, &m, &n, x, fvec, fjac, &ldfjac, &ftol, &xtol, &gtol, &maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, ipvt, qtf, wa, wa+n, wa+2*n, wa+3*n);
+  n_int = n;
+  LMDER(jac_multipack_lm_function, &m, &n_int, x, fvec, fjac, &ldfjac, &ftol, &xtol, &gtol, &maxfev, diag, &mode, &factor, &nprint, &info, &nfev, &njev, ipvt, qtf, wa, wa+n, wa+2*n, wa+3*n);
 
   RESTORE_JAC_FUNC();
 
@@ -613,7 +621,7 @@
   Py_XDECREF(ap_ipvt);
   Py_XDECREF(ap_qtf);
   if (allocated) free(wa);
-  return NULL;  
+  return NULL;
 }
 
 
@@ -660,7 +668,7 @@
     fjac = (double *)ap_fjac -> data;
     xp = (double *)ap_xp->data;
     fvecp = (double *)ap_fvecp -> data;
-    err = (double *)ap_err->data;    
+    err = (double *)ap_err->data;
 
     CHKDER(&m, &n, x, fvec, fjac, &m, xp, fvecp, &mode, err);
 
@@ -668,7 +676,7 @@
     Py_DECREF(ap_fjac);
     Py_DECREF(ap_fvecp);
   }
-  else 
+  else
     PYERR(minpack_error,"Invalid mode, must be 1 or 2.");
 
   Py_DECREF(ap_x);
