| File: | /tmp/pyrefcon/scipy/scipy/odr/__odrpack.c |
| Warning: | line 74, column 3 Calling function '_Py_INCREF' with a PyObject argument whose ownership has been released (with stolen reference) |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* Anti-Copyright | |||
| 2 | * | |||
| 3 | * I hereby release this code into the PUBLIC DOMAIN AS IS. There is no | |||
| 4 | * support, warranty, or guarantee. I will gladly accept comments, bug | |||
| 5 | * reports, and patches, however. | |||
| 6 | * | |||
| 7 | * Robert Kern | |||
| 8 | * kern@caltech.edu | |||
| 9 | * | |||
| 10 | */ | |||
| 11 | ||||
| 12 | #define PY_SSIZE_T_CLEAN | |||
| 13 | #include "odrpack.h" | |||
| 14 | ||||
| 15 | ||||
| 16 | void F_FUNC(dodrc,DODRC)dodrc_(void (*fcn)(F_INTint *n, F_INTint *m, F_INTint *np, F_INTint *nq, F_INTint *ldn, F_INTint *ldm, | |||
| 17 | F_INTint *ldnp, double *beta, double *xplusd, F_INTint *ifixb, F_INTint *ifixx, | |||
| 18 | F_INTint *ldifx, F_INTint *ideval, double *f, double *fjacb, double *fjacd, | |||
| 19 | F_INTint *istop), | |||
| 20 | F_INTint *n, F_INTint *m, F_INTint *np, F_INTint *nq, double *beta, double *y, F_INTint *ldy, | |||
| 21 | double *x, F_INTint *ldx, double *we, F_INTint *ldwe, F_INTint *ld2we, double *wd, | |||
| 22 | F_INTint *ldwd, F_INTint *ld2wd, F_INTint *ifixb, F_INTint *ifixx, F_INTint *ldifx, F_INTint *job, | |||
| 23 | F_INTint *ndigit, double *taufac, double *sstol, double *partol, | |||
| 24 | F_INTint *maxit, F_INTint *iprF_INT, F_INTint *lunerr, F_INTint *lunrpt, double *stpb, | |||
| 25 | double *stpd, F_INTint *ldstpd, double *sclb, double *scld, F_INTint *ldscld, | |||
| 26 | double *work, F_INTint *lwork, F_INTint *iwork, F_INTint *liwork, F_INTint *info); | |||
| 27 | void F_FUNC(dwinf,DWINF)dwinf_(F_INTint *n, F_INTint *m, F_INTint *np, F_INTint *nq, F_INTint *ldwe, F_INTint *ld2we, F_INTint *isodr, | |||
| 28 | F_INTint *delta, F_INTint *eps, F_INTint *xplus, F_INTint *fn, F_INTint *sd, F_INTint *vcv, F_INTint *rvar, | |||
| 29 | F_INTint *wss, F_INTint *wssde, F_INTint *wssep, F_INTint *rcond, F_INTint *eta, F_INTint *olmav, | |||
| 30 | F_INTint *tau, F_INTint *alpha, F_INTint *actrs, F_INTint *pnorm, F_INTint *rnors, F_INTint *prers, | |||
| 31 | F_INTint *partl, F_INTint *sstol, F_INTint *taufc, F_INTint *apsma, F_INTint *betao, F_INTint *betac, | |||
| 32 | F_INTint *betas, F_INTint *betan, F_INTint *s, F_INTint *ss, F_INTint *ssf, F_INTint *qraux, F_INTint *u, | |||
| 33 | F_INTint *fs, F_INTint *fjacb, F_INTint *we1, F_INTint *diff, F_INTint *delts, F_INTint *deltn, | |||
| 34 | F_INTint *t, F_INTint *tt, F_INTint *omega, F_INTint *fjacd, F_INTint *wrk1, F_INTint *wrk2, | |||
| 35 | F_INTint *wrk3, F_INTint *wrk4, F_INTint *wrk5, F_INTint *wrk6, F_INTint *wrk7, F_INTint *lwkmn); | |||
| 36 | void F_FUNC(dluno,DLUNO)dluno_(F_INTint *lun, char *fn, int fnlen); | |||
| 37 | void F_FUNC(dlunc,DLUNC)dlunc_(F_INTint *lun); | |||
| 38 | ||||
| 39 | ||||
| 40 | ||||
| 41 | /* callback to pass to DODRC; calls the Python function in the global structure |odr_global| */ | |||
| 42 | void fcn_callback(F_INTint *n, F_INTint *m, F_INTint *np, F_INTint *nq, F_INTint *ldn, F_INTint *ldm, | |||
| 43 | F_INTint *ldnp, double *beta, double *xplusd, F_INTint *ifixb, | |||
| 44 | F_INTint *ifixx, F_INTint *ldfix, F_INTint *ideval, double *f, | |||
| 45 | double *fjacb, double *fjacd, F_INTint *istop) | |||
| 46 | { | |||
| 47 | PyObject *arg01, *arglist; | |||
| 48 | PyObject *result = NULL((void*)0); | |||
| 49 | PyArrayObject *result_array = NULL((void*)0); | |||
| 50 | PyArrayObject *pyXplusD; | |||
| 51 | void *beta_dst; | |||
| 52 | ||||
| 53 | arg01 = PyTuple_New(2); | |||
| 54 | ||||
| 55 | if (*m != 1) | |||
| ||||
| 56 | { | |||
| 57 | npy_intp dim2[2]; | |||
| 58 | dim2[0] = *m; | |||
| 59 | dim2[1] = *n; | |||
| 60 | pyXplusD = (PyArrayObject *) PyArray_SimpleNew(2, dim2, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 2, dim2, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 61 | memcpy(PyArray_DATA(pyXplusD), (void *)xplusd, (*m) * (*n) * sizeof(double)); | |||
| 62 | } | |||
| 63 | else | |||
| 64 | { | |||
| 65 | npy_intp dim1[1]; | |||
| 66 | dim1[0] = *n; | |||
| 67 | pyXplusD = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 68 | memcpy(PyArray_DATA(pyXplusD), (void *)xplusd, (*n) * sizeof(double)); | |||
| 69 | } | |||
| 70 | ||||
| 71 | PyTuple_SetItem(arg01, 0, odr_global.pyBeta); | |||
| 72 | Py_INCREF(odr_global.pyBeta)_Py_INCREF(((PyObject*)(odr_global.pyBeta))); | |||
| 73 | PyTuple_SetItem(arg01, 1, (PyObject *) pyXplusD); | |||
| 74 | Py_INCREF((PyObject *) pyXplusD)_Py_INCREF(((PyObject*)((PyObject *) pyXplusD))); | |||
| ||||
| 75 | ||||
| 76 | if (odr_global.extra_args != NULL((void*)0)) | |||
| 77 | { | |||
| 78 | arglist = PySequence_Concat(arg01, odr_global.extra_args); | |||
| 79 | } | |||
| 80 | else | |||
| 81 | { | |||
| 82 | arglist = PySequence_Tuple(arg01); /* make a copy */ | |||
| 83 | } | |||
| 84 | ||||
| 85 | Py_DECREF(arg01)_Py_DECREF(((PyObject*)(arg01))); | |||
| 86 | *istop = 0; | |||
| 87 | ||||
| 88 | beta_dst = (PyArray_DATA((PyArrayObject *) odr_global.pyBeta)); | |||
| 89 | if (beta != beta_dst) { | |||
| 90 | memcpy(beta_dst, (void *)beta, (*np) * sizeof(double)); | |||
| 91 | } | |||
| 92 | ||||
| 93 | if ((*ideval % 10) >= 1) | |||
| 94 | { | |||
| 95 | /* compute f with odr_global.fcn */ | |||
| 96 | ||||
| 97 | if (odr_global.fcn == NULL((void*)0)) | |||
| 98 | { | |||
| 99 | /* we don't have a function to call */ | |||
| 100 | PYERR2(odr_error, "Function has not been initialized"){PyErr_Print(); PyErr_SetString(odr_error, "Function has not been initialized" ); goto fail;}; | |||
| 101 | } | |||
| 102 | ||||
| 103 | if ((result = PyObject_CallObject(odr_global.fcn, arglist)) == NULL((void*)0)) | |||
| 104 | { | |||
| 105 | if (PyErr_ExceptionMatches(odr_stop)) | |||
| 106 | { | |||
| 107 | /* stop, don't fail */ | |||
| 108 | *istop = 1; | |||
| 109 | ||||
| 110 | Py_DECREF(arglist)_Py_DECREF(((PyObject*)(arglist))); | |||
| 111 | return; | |||
| 112 | } | |||
| 113 | goto fail; | |||
| 114 | } | |||
| 115 | ||||
| 116 | if ((result_array = | |||
| 117 | (PyArrayObject *) PyArray_ContiguousFromObject(result,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(result, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_DOUBLE), 0, 2, ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 118 | NPY_DOUBLE, 0,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(result, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_DOUBLE), 0, 2, ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 119 | 2)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(result, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_DOUBLE), 0, 2, ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 120 | { | |||
| 121 | PYERR2(odr_error,{PyErr_Print(); PyErr_SetString(odr_error, "Result from function call is not a proper array of floats." ); goto fail;} | |||
| 122 | "Result from function call is not a proper array of floats."){PyErr_Print(); PyErr_SetString(odr_error, "Result from function call is not a proper array of floats." ); goto fail;}; | |||
| 123 | } | |||
| 124 | ||||
| 125 | memcpy((void *)f, PyArray_DATA(result_array), (*n) * (*nq) * sizeof(double)); | |||
| 126 | Py_DECREF(result_array)_Py_DECREF(((PyObject*)(result_array))); | |||
| 127 | } | |||
| 128 | ||||
| 129 | if (((*ideval) / 10) % 10 >= 1) | |||
| 130 | { | |||
| 131 | /* compute fjacb with odr_global.fjacb */ | |||
| 132 | ||||
| 133 | if (odr_global.fjacb == NULL((void*)0)) | |||
| 134 | { | |||
| 135 | /* we don't have a function to call */ | |||
| 136 | PYERR2(odr_error, "Function has not been initialized"){PyErr_Print(); PyErr_SetString(odr_error, "Function has not been initialized" ); goto fail;}; | |||
| 137 | } | |||
| 138 | ||||
| 139 | if ((result = PyObject_CallObject(odr_global.fjacb, arglist)) == NULL((void*)0)) | |||
| 140 | { | |||
| 141 | if (PyErr_ExceptionMatches(odr_stop)) | |||
| 142 | { | |||
| 143 | /* stop, don't fail */ | |||
| 144 | *istop = 1; | |||
| 145 | ||||
| 146 | Py_DECREF(arglist)_Py_DECREF(((PyObject*)(arglist))); | |||
| 147 | return; | |||
| 148 | } | |||
| 149 | goto fail; | |||
| 150 | } | |||
| 151 | ||||
| 152 | if ((result_array = | |||
| 153 | (PyArrayObject *) PyArray_ContiguousFromObject(result,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(result, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_DOUBLE), 0, 3, ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 154 | NPY_DOUBLE, 0,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(result, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_DOUBLE), 0, 3, ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 155 | 3)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(result, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_DOUBLE), 0, 3, ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 156 | { | |||
| 157 | PYERR2(odr_error,{PyErr_Print(); PyErr_SetString(odr_error, "Result from function call is not a proper array of floats." ); goto fail;} | |||
| 158 | "Result from function call is not a proper array of floats."){PyErr_Print(); PyErr_SetString(odr_error, "Result from function call is not a proper array of floats." ); goto fail;}; | |||
| 159 | } | |||
| 160 | ||||
| 161 | if (*nq != 1 && *np != 1) | |||
| 162 | { | |||
| 163 | /* result_array should be rank-3 */ | |||
| 164 | ||||
| 165 | if (PyArray_NDIM(result_array) != 3) | |||
| 166 | { | |||
| 167 | Py_DECREF(result_array)_Py_DECREF(((PyObject*)(result_array))); | |||
| 168 | PYERR2(odr_error, "Beta Jacobian is not rank-3"){PyErr_Print(); PyErr_SetString(odr_error, "Beta Jacobian is not rank-3" ); goto fail;}; | |||
| 169 | } | |||
| 170 | } | |||
| 171 | else if (*nq == 1) | |||
| 172 | { | |||
| 173 | /* result_array should be rank-2 */ | |||
| 174 | ||||
| 175 | if (PyArray_NDIM(result_array) != 2) | |||
| 176 | { | |||
| 177 | Py_DECREF(result_array)_Py_DECREF(((PyObject*)(result_array))); | |||
| 178 | PYERR2(odr_error, "Beta Jacobian is not rank-2"){PyErr_Print(); PyErr_SetString(odr_error, "Beta Jacobian is not rank-2" ); goto fail;}; | |||
| 179 | } | |||
| 180 | } | |||
| 181 | ||||
| 182 | memcpy((void *)fjacb, PyArray_DATA(result_array), | |||
| 183 | (*n) * (*nq) * (*np) * sizeof(double)); | |||
| 184 | Py_DECREF(result_array)_Py_DECREF(((PyObject*)(result_array))); | |||
| 185 | ||||
| 186 | } | |||
| 187 | ||||
| 188 | if (((*ideval) / 100) % 10 >= 1) | |||
| 189 | { | |||
| 190 | /* compute fjacd with odr_global.fjacd */ | |||
| 191 | ||||
| 192 | if (odr_global.fjacd == NULL((void*)0)) | |||
| 193 | { | |||
| 194 | /* we don't have a function to call */ | |||
| 195 | PYERR2(odr_error, "fjcad has not been initialized"){PyErr_Print(); PyErr_SetString(odr_error, "fjcad has not been initialized" ); goto fail;}; | |||
| 196 | } | |||
| 197 | ||||
| 198 | if ((result = PyObject_CallObject(odr_global.fjacd, arglist)) == NULL((void*)0)) | |||
| 199 | { | |||
| 200 | if (PyErr_ExceptionMatches(odr_stop)) | |||
| 201 | { | |||
| 202 | /* stop, don't fail */ | |||
| 203 | *istop = 1; | |||
| 204 | ||||
| 205 | Py_DECREF(arglist)_Py_DECREF(((PyObject*)(arglist))); | |||
| 206 | return; | |||
| 207 | } | |||
| 208 | goto fail; | |||
| 209 | } | |||
| 210 | ||||
| 211 | if ((result_array = | |||
| 212 | (PyArrayObject *) PyArray_ContiguousFromObject(result,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(result, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_DOUBLE), 0, 3, ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 213 | NPY_DOUBLE, 0,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(result, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_DOUBLE), 0, 3, ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 214 | 3)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(result, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_DOUBLE), 0, 3, ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 215 | { | |||
| 216 | PYERR2(odr_error,{PyErr_Print(); PyErr_SetString(odr_error, "Result from function call is not a proper array of floats." ); goto fail;} | |||
| 217 | "Result from function call is not a proper array of floats."){PyErr_Print(); PyErr_SetString(odr_error, "Result from function call is not a proper array of floats." ); goto fail;}; | |||
| 218 | } | |||
| 219 | ||||
| 220 | if (*nq != 1 && *m != 1) | |||
| 221 | { | |||
| 222 | /* result_array should be rank-3 */ | |||
| 223 | ||||
| 224 | if (PyArray_NDIM(result_array) != 3) | |||
| 225 | { | |||
| 226 | Py_DECREF(result_array)_Py_DECREF(((PyObject*)(result_array))); | |||
| 227 | PYERR2(odr_error, "xplusd Jacobian is not rank-3"){PyErr_Print(); PyErr_SetString(odr_error, "xplusd Jacobian is not rank-3" ); goto fail;}; | |||
| 228 | } | |||
| 229 | } | |||
| 230 | else if (*nq == 1 && *m != 1) | |||
| 231 | { | |||
| 232 | /* result_array should be rank-2 */ | |||
| 233 | ||||
| 234 | if (PyArray_NDIM(result_array) != 2) | |||
| 235 | { | |||
| 236 | Py_DECREF(result_array)_Py_DECREF(((PyObject*)(result_array))); | |||
| 237 | PYERR2(odr_error, "xplusd Jacobian is not rank-2"){PyErr_Print(); PyErr_SetString(odr_error, "xplusd Jacobian is not rank-2" ); goto fail;}; | |||
| 238 | } | |||
| 239 | } | |||
| 240 | else if (*nq == 1 && *m == 1) | |||
| 241 | { | |||
| 242 | /* result_array should be rank-1 */ | |||
| 243 | ||||
| 244 | if (PyArray_NDIM(result_array) != 1) | |||
| 245 | { | |||
| 246 | Py_DECREF(result_array)_Py_DECREF(((PyObject*)(result_array))); | |||
| 247 | PYERR2(odr_error, "xplusd Jacobian is not rank-1"){PyErr_Print(); PyErr_SetString(odr_error, "xplusd Jacobian is not rank-1" ); goto fail;}; | |||
| 248 | } | |||
| 249 | } | |||
| 250 | ||||
| 251 | memcpy((void *)fjacd, PyArray_DATA(result_array), | |||
| 252 | (*n) * (*nq) * (*m) * sizeof(double)); | |||
| 253 | Py_DECREF(result_array)_Py_DECREF(((PyObject*)(result_array))); | |||
| 254 | } | |||
| 255 | ||||
| 256 | Py_DECREF(result)_Py_DECREF(((PyObject*)(result))); | |||
| 257 | Py_DECREF(arglist)_Py_DECREF(((PyObject*)(arglist))); | |||
| 258 | Py_DECREF(pyXplusD)_Py_DECREF(((PyObject*)(pyXplusD))); | |||
| 259 | ||||
| 260 | return; | |||
| 261 | ||||
| 262 | fail: | |||
| 263 | Py_XDECREF(result)_Py_XDECREF(((PyObject*)(result))); | |||
| 264 | Py_XDECREF(arglist)_Py_XDECREF(((PyObject*)(arglist))); | |||
| 265 | Py_XDECREF(pyXplusD)_Py_XDECREF(((PyObject*)(pyXplusD))); | |||
| 266 | *istop = -1; | |||
| 267 | return; | |||
| 268 | } | |||
| 269 | ||||
| 270 | ||||
| 271 | /* generates Python output from the raw output from DODRC */ | |||
| 272 | PyObject *gen_output(F_INTint n, F_INTint m, F_INTint np, F_INTint nq, F_INTint ldwe, F_INTint ld2we, | |||
| 273 | PyArrayObject * beta, PyArrayObject * work, | |||
| 274 | PyArrayObject * iwork, F_INTint isodr, F_INTint info, | |||
| 275 | int full_output) | |||
| 276 | { | |||
| 277 | PyArrayObject *sd_beta, *cov_beta; | |||
| 278 | ||||
| 279 | F_INTint delta, eps, xplus, fn, sd, vcv, rvar, wss, wssde, wssep, rcond; | |||
| 280 | F_INTint eta, olmav, tau, alpha, actrs, pnorm, rnors, prers, partl, sstol; | |||
| 281 | F_INTint taufc, apsma, betao, betac, betas, betan, s, ss, ssf, qraux, u; | |||
| 282 | F_INTint fs, fjacb, we1, diff, delts, deltn, t, tt, omega, fjacd; | |||
| 283 | F_INTint wrk1, wrk2, wrk3, wrk4, wrk5, wrk6, wrk7, lwkmn; | |||
| 284 | ||||
| 285 | PyObject *retobj; | |||
| 286 | ||||
| 287 | npy_intp dim1[1], dim2[2]; | |||
| 288 | ||||
| 289 | if (info == 50005) { | |||
| 290 | /* fatal error in fcn call; return NULL to propagate the exception */ | |||
| 291 | ||||
| 292 | return NULL((void*)0); | |||
| 293 | } | |||
| 294 | ||||
| 295 | lwkmn = PyArray_DIMS(work)[0]; | |||
| 296 | ||||
| 297 | F_FUNC(dwinf,DWINF)dwinf_(&n, &m, &np, &nq, &ldwe, &ld2we, &isodr, | |||
| 298 | &delta, &eps, &xplus, &fn, &sd, &vcv, &rvar, &wss, &wssde, | |||
| 299 | &wssep, &rcond, &eta, &olmav, &tau, &alpha, &actrs, &pnorm, | |||
| 300 | &rnors, &prers, &partl, &sstol, &taufc, &apsma, &betao, &betac, | |||
| 301 | &betas, &betan, &s, &ss, &ssf, &qraux, &u, &fs, &fjacb, &we1, | |||
| 302 | &diff, &delts, &deltn, &t, &tt, &omega, &fjacd, &wrk1, &wrk2, | |||
| 303 | &wrk3, &wrk4, &wrk5, &wrk6, &wrk7, &lwkmn); | |||
| 304 | ||||
| 305 | /* convert FORTRAN indices to C indices */ | |||
| 306 | delta--; | |||
| 307 | eps--; | |||
| 308 | xplus--; | |||
| 309 | fn--; | |||
| 310 | sd--; | |||
| 311 | vcv--; | |||
| 312 | rvar--; | |||
| 313 | wss--; | |||
| 314 | wssde--; | |||
| 315 | wssep--; | |||
| 316 | rcond--; | |||
| 317 | eta--; | |||
| 318 | olmav--; | |||
| 319 | tau--; | |||
| 320 | alpha--; | |||
| 321 | actrs--; | |||
| 322 | pnorm--; | |||
| 323 | rnors--; | |||
| 324 | prers--; | |||
| 325 | partl--; | |||
| 326 | sstol--; | |||
| 327 | taufc--; | |||
| 328 | apsma--; | |||
| 329 | betao--; | |||
| 330 | betac--; | |||
| 331 | betas--; | |||
| 332 | betan--; | |||
| 333 | s--; | |||
| 334 | ss--; | |||
| 335 | ssf--; | |||
| 336 | qraux--; | |||
| 337 | u--; | |||
| 338 | fs--; | |||
| 339 | fjacb--; | |||
| 340 | we1--; | |||
| 341 | diff--; | |||
| 342 | delts--; | |||
| 343 | deltn--; | |||
| 344 | t--; | |||
| 345 | tt--; | |||
| 346 | omega--; | |||
| 347 | fjacd--; | |||
| 348 | wrk1--; | |||
| 349 | wrk2--; | |||
| 350 | wrk3--; | |||
| 351 | wrk4--; | |||
| 352 | wrk5--; | |||
| 353 | wrk6--; | |||
| 354 | wrk7--; | |||
| 355 | ||||
| 356 | dim1[0] = PyArray_DIMS(beta)[0]; | |||
| 357 | sd_beta = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 358 | dim2[0] = PyArray_DIMS(beta)[0]; | |||
| 359 | dim2[1] = PyArray_DIMS(beta)[0]; | |||
| 360 | cov_beta = (PyArrayObject *) PyArray_SimpleNew(2, dim2, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 2, dim2, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 361 | ||||
| 362 | memcpy(PyArray_DATA(sd_beta), (void *)((double *)(PyArray_DATA(work)) + sd), | |||
| 363 | np * sizeof(double)); | |||
| 364 | memcpy(PyArray_DATA(cov_beta), (void *)((double *)(PyArray_DATA(work)) + vcv), | |||
| 365 | np * np * sizeof(double)); | |||
| 366 | ||||
| 367 | if (!full_output) | |||
| 368 | { | |||
| 369 | retobj = Py_BuildValue_Py_BuildValue_SizeT("OOO", PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(beta), | |||
| 370 | PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(sd_beta), | |||
| 371 | PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(cov_beta)); | |||
| 372 | Py_DECREF((PyObject *) sd_beta)_Py_DECREF(((PyObject*)((PyObject *) sd_beta))); | |||
| 373 | Py_DECREF((PyObject *) cov_beta)_Py_DECREF(((PyObject*)((PyObject *) cov_beta))); | |||
| 374 | ||||
| 375 | return retobj; | |||
| 376 | } | |||
| 377 | else | |||
| 378 | { | |||
| 379 | PyArrayObject *deltaA, *epsA, *xplusA, *fnA; | |||
| 380 | double res_var, sum_square, sum_square_delta, sum_square_eps; | |||
| 381 | double inv_condnum, rel_error; | |||
| 382 | PyObject *work_ind; | |||
| 383 | ||||
| 384 | work_ind = | |||
| 385 | Py_BuildValue_Py_BuildValue_SizeT | |||
| 386 | (("{s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 387 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 388 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 389 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 390 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 391 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 392 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 393 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 394 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 395 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 396 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 397 | ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" ",s:" F_INT_PYFMT"i" | |||
| 398 | ",s:" F_INT_PYFMT"i" "}"), | |||
| 399 | "delta", delta, "eps", eps, "xplus", xplus, "fn", fn, "sd", sd, "vcv", | |||
| 400 | vcv, "rvar", rvar, "wss", wss, "wssde", wssde, "wssep", wssep, | |||
| 401 | "rcond", rcond, "eta", eta, "olmav", olmav, "tau", tau, "alpha", | |||
| 402 | alpha, "actrs", actrs, "pnorm", pnorm, "rnors", rnors, "prers", | |||
| 403 | prers, "partl", partl, "sstol", sstol, "taufc", taufc, "apsma", | |||
| 404 | apsma, "betao", betao, "betac", betac, "betas", betas, "betan", | |||
| 405 | betan, "s", s, "ss", ss, "ssf", ssf, "qraux", qraux, "u", u, "fs", | |||
| 406 | fs, "fjacb", fjacb, "we1", we1, "diff", diff, "delts", delts, | |||
| 407 | "deltn", deltn, "t", t, "tt", tt, "omega", omega, "fjacd", fjacd, | |||
| 408 | "wrk1", wrk1, "wrk2", wrk2, "wrk3", wrk3, "wrk4", wrk4, "wrk5", wrk5, | |||
| 409 | "wrk6", wrk6, "wrk7", wrk7); | |||
| 410 | ||||
| 411 | if (m == 1) | |||
| 412 | { | |||
| 413 | dim1[0] = n; | |||
| 414 | deltaA = | |||
| 415 | (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 416 | xplusA = | |||
| 417 | (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 418 | } | |||
| 419 | else | |||
| 420 | { | |||
| 421 | dim2[0] = m; | |||
| 422 | dim2[1] = n; | |||
| 423 | deltaA = | |||
| 424 | (PyArrayObject *) PyArray_SimpleNew(2, dim2, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 2, dim2, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 425 | xplusA = | |||
| 426 | (PyArrayObject *) PyArray_SimpleNew(2, dim2, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 2, dim2, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 427 | } | |||
| 428 | ||||
| 429 | if (nq == 1) | |||
| 430 | { | |||
| 431 | dim1[0] = n; | |||
| 432 | epsA = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 433 | fnA = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 434 | } | |||
| 435 | else | |||
| 436 | { | |||
| 437 | dim2[0] = nq; | |||
| 438 | dim2[1] = n; | |||
| 439 | epsA = (PyArrayObject *) PyArray_SimpleNew(2, dim2, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 2, dim2, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 440 | fnA = (PyArrayObject *) PyArray_SimpleNew(2, dim2, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 2, dim2, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 441 | } | |||
| 442 | ||||
| 443 | memcpy(PyArray_DATA(deltaA), (void *)((double *)(PyArray_DATA(work)) + delta), | |||
| 444 | m * n * sizeof(double)); | |||
| 445 | memcpy(PyArray_DATA(epsA), (void *)((double *)(PyArray_DATA(work)) + eps), | |||
| 446 | nq * n * sizeof(double)); | |||
| 447 | memcpy(PyArray_DATA(xplusA), (void *)((double *)(PyArray_DATA(work)) + xplus), | |||
| 448 | m * n * sizeof(double)); | |||
| 449 | memcpy(PyArray_DATA(fnA), (void *)((double *)(PyArray_DATA(work)) + fn), | |||
| 450 | nq * n * sizeof(double)); | |||
| 451 | ||||
| 452 | res_var = *((double *)(PyArray_DATA(work)) + rvar); | |||
| 453 | sum_square = *((double *)(PyArray_DATA(work)) + wss); | |||
| 454 | sum_square_delta = *((double *)(PyArray_DATA(work)) + wssde); | |||
| 455 | sum_square_eps = *((double *)(PyArray_DATA(work)) + wssep); | |||
| 456 | inv_condnum = *((double *)(PyArray_DATA(work)) + rcond); | |||
| 457 | rel_error = *((double *)(PyArray_DATA(work)) + eta); | |||
| 458 | ||||
| 459 | retobj = | |||
| 460 | Py_BuildValue_Py_BuildValue_SizeT | |||
| 461 | (("OOO{s:O,s:O,s:O,s:O,s:d,s:d,s:d,s:d,s:d,s:d,s:O,s:O,s:O,s:" F_INT_PYFMT"i" "}"), | |||
| 462 | PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(beta), PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(sd_beta), | |||
| 463 | PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(cov_beta), "delta", PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(deltaA), "eps", | |||
| 464 | PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(epsA), "xplus", PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(xplusA), "y", | |||
| 465 | PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(fnA), "res_var", res_var, "sum_square", sum_square, | |||
| 466 | "sum_square_delta", sum_square_delta, "sum_square_eps", | |||
| 467 | sum_square_eps, "inv_condnum", inv_condnum, "rel_error", rel_error, | |||
| 468 | "work", PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(work), "work_ind", work_ind, "iwork", | |||
| 469 | PyArray_Return(*(PyObject * (*)(PyArrayObject *)) PyArray_API[76])(iwork), "info", info); | |||
| 470 | Py_DECREF((PyObject *) sd_beta)_Py_DECREF(((PyObject*)((PyObject *) sd_beta))); | |||
| 471 | Py_DECREF((PyObject *) cov_beta)_Py_DECREF(((PyObject*)((PyObject *) cov_beta))); | |||
| 472 | Py_DECREF((PyObject *) deltaA)_Py_DECREF(((PyObject*)((PyObject *) deltaA))); | |||
| 473 | Py_DECREF((PyObject *) epsA)_Py_DECREF(((PyObject*)((PyObject *) epsA))); | |||
| 474 | Py_DECREF((PyObject *) xplusA)_Py_DECREF(((PyObject*)((PyObject *) xplusA))); | |||
| 475 | Py_DECREF((PyObject *) fnA)_Py_DECREF(((PyObject*)((PyObject *) fnA))); | |||
| 476 | Py_DECREF((PyObject *) work_ind)_Py_DECREF(((PyObject*)((PyObject *) work_ind))); | |||
| 477 | ||||
| 478 | return retobj; | |||
| 479 | } | |||
| 480 | } | |||
| 481 | ||||
| 482 | PyObject *odr(PyObject * self, PyObject * args, PyObject * kwds) | |||
| 483 | { | |||
| 484 | PyObject *fcn, *initbeta, *py, *px, *pwe = NULL((void*)0), *pwd = NULL((void*)0), *fjacb = NULL((void*)0); | |||
| 485 | PyObject *fjacd = NULL((void*)0), *pifixb = NULL((void*)0), *pifixx = NULL((void*)0); | |||
| 486 | PyObject *pstpb = NULL((void*)0), *pstpd = NULL((void*)0), *psclb = NULL((void*)0), *pscld = NULL((void*)0); | |||
| 487 | PyObject *pwork = NULL((void*)0), *piwork = NULL((void*)0), *extra_args = NULL((void*)0); | |||
| 488 | F_INTint job = 0, ndigit = 0, maxit = -1, iprint = 0; | |||
| 489 | int full_output = 0; | |||
| 490 | double taufac = 0.0, sstol = -1.0, partol = -1.0; | |||
| 491 | char *errfile = NULL((void*)0), *rptfile = NULL((void*)0); | |||
| 492 | Py_ssize_t lerrfile = 0, lrptfile = 0; | |||
| 493 | PyArrayObject *beta = NULL((void*)0), *y = NULL((void*)0), *x = NULL((void*)0), *we = NULL((void*)0), *wd = NULL((void*)0); | |||
| 494 | PyArrayObject *ifixb = NULL((void*)0), *ifixx = NULL((void*)0); | |||
| 495 | PyArrayObject *stpb = NULL((void*)0), *stpd = NULL((void*)0), *sclb = NULL((void*)0), *scld = NULL((void*)0); | |||
| 496 | PyArrayObject *work = NULL((void*)0), *iwork = NULL((void*)0); | |||
| 497 | F_INTint n, m, np, nq, ldy, ldx, ldwe, ld2we, ldwd, ld2wd, ldifx; | |||
| 498 | F_INTint lunerr = -1, lunrpt = -1, ldstpd, ldscld, lwork, liwork, info = 0; | |||
| 499 | static char *kw_list[] = { "fcn", "initbeta", "y", "x", "we", "wd", "fjacb", | |||
| 500 | "fjacd", "extra_args", "ifixb", "ifixx", "job", "iprint", "errfile", | |||
| 501 | "rptfile", "ndigit", "taufac", "sstol", "partol", | |||
| 502 | "maxit", "stpb", "stpd", "sclb", "scld", "work", | |||
| 503 | "iwork", "full_output", NULL((void*)0) | |||
| 504 | }; | |||
| 505 | F_INTint isodr = 1; | |||
| 506 | PyObject *result; | |||
| 507 | npy_intp dim1[1], dim2[2], dim3[3]; | |||
| 508 | F_INTint implicit; /* flag for implicit model */ | |||
| 509 | ||||
| 510 | ||||
| 511 | if (kwds == NULL((void*)0)) | |||
| 512 | { | |||
| 513 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, ("OOOO|OOOOOOO" F_INT_PYFMT"i" F_INT_PYFMT"i" | |||
| 514 | "z#z#" F_INT_PYFMT"i" "ddd" F_INT_PYFMT"i" | |||
| 515 | "OOOOOOi:odr"), | |||
| 516 | &fcn, &initbeta, &py, &px, &pwe, &pwd, | |||
| 517 | &fjacb, &fjacd, &extra_args, &pifixb, &pifixx, | |||
| 518 | &job, &iprint, &errfile, &lerrfile, &rptfile, | |||
| 519 | &lrptfile, &ndigit, &taufac, &sstol, &partol, | |||
| 520 | &maxit, &pstpb, &pstpd, &psclb, &pscld, &pwork, | |||
| 521 | &piwork, &full_output)) | |||
| 522 | { | |||
| 523 | return NULL((void*)0); | |||
| 524 | } | |||
| 525 | } | |||
| 526 | else | |||
| 527 | { | |||
| 528 | if (!PyArg_ParseTupleAndKeywords_PyArg_ParseTupleAndKeywords_SizeT(args, kwds, | |||
| 529 | ("OOOO|OOOOOOO" F_INT_PYFMT"i" "" F_INT_PYFMT"i" | |||
| 530 | "z#z#" F_INT_PYFMT"i" "ddd" F_INT_PYFMT"i" | |||
| 531 | "OOOOOOi:odr"), | |||
| 532 | kw_list, &fcn, &initbeta, &py, &px, | |||
| 533 | &pwe, &pwd, &fjacb, &fjacd, | |||
| 534 | &extra_args, &pifixb, &pifixx, &job, | |||
| 535 | &iprint, &errfile, &lerrfile, &rptfile, | |||
| 536 | &lrptfile, &ndigit, &taufac, &sstol, | |||
| 537 | &partol, &maxit, &pstpb, &pstpd, | |||
| 538 | &psclb, &pscld, &pwork, &piwork, | |||
| 539 | &full_output)) | |||
| 540 | { | |||
| 541 | return NULL((void*)0); | |||
| 542 | } | |||
| 543 | } | |||
| 544 | ||||
| 545 | /* Check the validity of all arguments */ | |||
| 546 | ||||
| 547 | if (!PyCallable_Check(fcn)) | |||
| 548 | { | |||
| 549 | PYERR(PyExc_TypeError, "fcn must be callable"){PyErr_SetString(PyExc_TypeError,"fcn must be callable"); goto fail;}; | |||
| 550 | } | |||
| 551 | if (!PySequence_Check(initbeta)) | |||
| 552 | { | |||
| 553 | PYERR(PyExc_TypeError, "initbeta must be a sequence"){PyErr_SetString(PyExc_TypeError,"initbeta must be a sequence" ); goto fail;}; | |||
| 554 | } | |||
| 555 | if (!PySequence_Check(py) && !PyNumber_Check(py)) | |||
| 556 | { | |||
| 557 | PYERR(PyExc_TypeError,{PyErr_SetString(PyExc_TypeError,"y must be a sequence or integer (if model is implicit)" ); goto fail;} | |||
| 558 | "y must be a sequence or integer (if model is implicit)"){PyErr_SetString(PyExc_TypeError,"y must be a sequence or integer (if model is implicit)" ); goto fail;}; | |||
| 559 | } | |||
| 560 | if (!PySequence_Check(px)) | |||
| 561 | { | |||
| 562 | PYERR(PyExc_TypeError, "x must be a sequence"){PyErr_SetString(PyExc_TypeError,"x must be a sequence"); goto fail;}; | |||
| 563 | } | |||
| 564 | if (pwe != NULL((void*)0) && !PySequence_Check(pwe) && !PyNumber_Check(pwe)) | |||
| 565 | { | |||
| 566 | PYERR(PyExc_TypeError, "we must be a sequence or a number"){PyErr_SetString(PyExc_TypeError,"we must be a sequence or a number" ); goto fail;}; | |||
| 567 | } | |||
| 568 | if (pwd != NULL((void*)0) && !PySequence_Check(pwd) && !PyNumber_Check(pwd)) | |||
| 569 | { | |||
| 570 | PYERR(PyExc_TypeError, "wd must be a sequence or a number"){PyErr_SetString(PyExc_TypeError,"wd must be a sequence or a number" ); goto fail;}; | |||
| 571 | } | |||
| 572 | if (fjacb != NULL((void*)0) && !PyCallable_Check(fjacb)) | |||
| 573 | { | |||
| 574 | PYERR(PyExc_TypeError, "fjacb must be callable"){PyErr_SetString(PyExc_TypeError,"fjacb must be callable"); goto fail;}; | |||
| 575 | } | |||
| 576 | if (fjacd != NULL((void*)0) && !PyCallable_Check(fjacd)) | |||
| 577 | { | |||
| 578 | PYERR(PyExc_TypeError, "fjacd must be callable"){PyErr_SetString(PyExc_TypeError,"fjacd must be callable"); goto fail;}; | |||
| 579 | } | |||
| 580 | if (extra_args != NULL((void*)0) && !PySequence_Check(extra_args)) | |||
| 581 | { | |||
| 582 | PYERR(PyExc_TypeError, "extra_args must be a sequence"){PyErr_SetString(PyExc_TypeError,"extra_args must be a sequence" ); goto fail;}; | |||
| 583 | } | |||
| 584 | if (pifixx != NULL((void*)0) && !PySequence_Check(pifixx)) | |||
| 585 | { | |||
| 586 | PYERR(PyExc_TypeError, "ifixx must be a sequence"){PyErr_SetString(PyExc_TypeError,"ifixx must be a sequence"); goto fail;}; | |||
| 587 | } | |||
| 588 | if (pifixb != NULL((void*)0) && !PySequence_Check(pifixb)) | |||
| 589 | { | |||
| 590 | PYERR(PyExc_TypeError, "ifixb must be a sequence"){PyErr_SetString(PyExc_TypeError,"ifixb must be a sequence"); goto fail;}; | |||
| 591 | } | |||
| 592 | if (pstpb != NULL((void*)0) && !PySequence_Check(pstpb)) | |||
| 593 | { | |||
| 594 | PYERR(PyExc_TypeError, "stpb must be a sequence"){PyErr_SetString(PyExc_TypeError,"stpb must be a sequence"); goto fail;}; | |||
| 595 | } | |||
| 596 | if (pstpd != NULL((void*)0) && !PySequence_Check(pstpd)) | |||
| 597 | { | |||
| 598 | PYERR(PyExc_TypeError, "stpd must be a sequence"){PyErr_SetString(PyExc_TypeError,"stpd must be a sequence"); goto fail;}; | |||
| 599 | } | |||
| 600 | if (psclb != NULL((void*)0) && !PySequence_Check(psclb)) | |||
| 601 | { | |||
| 602 | PYERR(PyExc_TypeError, "sclb must be a sequence"){PyErr_SetString(PyExc_TypeError,"sclb must be a sequence"); goto fail;}; | |||
| 603 | } | |||
| 604 | if (pscld != NULL((void*)0) && !PySequence_Check(pscld)) | |||
| 605 | { | |||
| 606 | PYERR(PyExc_TypeError, "scld must be a sequence"){PyErr_SetString(PyExc_TypeError,"scld must be a sequence"); goto fail;}; | |||
| 607 | } | |||
| 608 | if (pwork != NULL((void*)0) && !PyArray_Check(pwork)((((PyObject*)(pwork))->ob_type) == (&(*(PyTypeObject * )PyArray_API[2])) || PyType_IsSubtype((((PyObject*)(pwork))-> ob_type), (&(*(PyTypeObject *)PyArray_API[2]))))) | |||
| 609 | { | |||
| 610 | PYERR(PyExc_TypeError, "work must be an array"){PyErr_SetString(PyExc_TypeError,"work must be an array"); goto fail;}; | |||
| 611 | } | |||
| 612 | if (piwork != NULL((void*)0) && !PyArray_Check(piwork)((((PyObject*)(piwork))->ob_type) == (&(*(PyTypeObject *)PyArray_API[2])) || PyType_IsSubtype((((PyObject*)(piwork) )->ob_type), (&(*(PyTypeObject *)PyArray_API[2]))))) | |||
| 613 | { | |||
| 614 | PYERR(PyExc_TypeError, "iwork must be an array"){PyErr_SetString(PyExc_TypeError,"iwork must be an array"); goto fail;}; | |||
| 615 | } | |||
| 616 | ||||
| 617 | /* start processing the arguments and check for errors on the way */ | |||
| 618 | ||||
| 619 | /* check for implicit model */ | |||
| 620 | ||||
| 621 | implicit = (job % 10 == 1); | |||
| 622 | ||||
| 623 | if (!implicit) | |||
| 624 | { | |||
| 625 | if ((y = | |||
| 626 | (PyArrayObject *) PyArray_CopyFromObject(py, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(py, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 627 | 2)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(py, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 628 | { | |||
| 629 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"y could not be made into a suitable array" ); goto fail;} | |||
| 630 | "y could not be made into a suitable array"){PyErr_SetString(PyExc_ValueError,"y could not be made into a suitable array" ); goto fail;}; | |||
| 631 | } | |||
| 632 | n = PyArray_DIMS(y)[PyArray_NDIM(y) - 1]; /* pick the last dimension */ | |||
| 633 | if ((x = | |||
| 634 | (PyArrayObject *) PyArray_CopyFromObject(px, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(px, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 635 | 2)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(px, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 636 | { | |||
| 637 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"x could not be made into a suitable array" ); goto fail;} | |||
| 638 | "x could not be made into a suitable array"){PyErr_SetString(PyExc_ValueError,"x could not be made into a suitable array" ); goto fail;}; | |||
| 639 | } | |||
| 640 | if (n != PyArray_DIMS(x)[PyArray_NDIM(x) - 1]) | |||
| 641 | { | |||
| 642 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"x and y don't have matching numbers of observations" ); goto fail;} | |||
| 643 | "x and y don't have matching numbers of observations"){PyErr_SetString(PyExc_ValueError,"x and y don't have matching numbers of observations" ); goto fail;}; | |||
| 644 | } | |||
| 645 | if (PyArray_NDIM(y) == 1) | |||
| 646 | { | |||
| 647 | nq = 1; | |||
| 648 | } | |||
| 649 | else | |||
| 650 | { | |||
| 651 | nq = PyArray_DIMS(y)[0]; | |||
| 652 | } | |||
| 653 | ||||
| 654 | ldx = ldy = n; | |||
| 655 | } | |||
| 656 | else | |||
| 657 | { /* we *do* have an implicit model */ | |||
| 658 | ldy = 1; | |||
| 659 | nq = (F_INTint)PyLong_AsLong(py); | |||
| 660 | dim1[0] = 1; | |||
| 661 | ||||
| 662 | /* initialize y to a dummy array; never referenced */ | |||
| 663 | y = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 664 | ||||
| 665 | if ((x = | |||
| 666 | (PyArrayObject *) PyArray_CopyFromObject(px, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(px, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 667 | 2)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(px, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 668 | { | |||
| 669 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"x could not be made into a suitable array" ); goto fail;} | |||
| 670 | "x could not be made into a suitable array"){PyErr_SetString(PyExc_ValueError,"x could not be made into a suitable array" ); goto fail;}; | |||
| 671 | } | |||
| 672 | ||||
| 673 | n = PyArray_DIMS(x)[PyArray_NDIM(x) - 1]; | |||
| 674 | ldx = n; | |||
| 675 | } | |||
| 676 | ||||
| 677 | if (PyArray_NDIM(x) == 1) | |||
| 678 | { | |||
| 679 | m = 1; | |||
| 680 | } | |||
| 681 | else | |||
| 682 | { | |||
| 683 | m = PyArray_DIMS(x)[0]; | |||
| 684 | } /* x, y */ | |||
| 685 | ||||
| 686 | if ((beta = | |||
| 687 | (PyArrayObject *) PyArray_CopyFromObject(initbeta, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(initbeta, (*(PyArray_Descr * ( *)(int)) PyArray_API[45])(NPY_DOUBLE), 1, 1, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 688 | 1)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(initbeta, (*(PyArray_Descr * ( *)(int)) PyArray_API[45])(NPY_DOUBLE), 1, 1, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 689 | { | |||
| 690 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"initbeta could not be made into a suitable array" ); goto fail;} | |||
| 691 | "initbeta could not be made into a suitable array"){PyErr_SetString(PyExc_ValueError,"initbeta could not be made into a suitable array" ); goto fail;}; | |||
| 692 | } | |||
| 693 | np = PyArray_DIMS(beta)[0]; | |||
| 694 | ||||
| 695 | if (pwe == NULL((void*)0)) | |||
| 696 | { | |||
| 697 | ldwe = ld2we = 1; | |||
| 698 | dim1[0] = n; | |||
| 699 | we = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 700 | ((double *)(PyArray_DATA(we)))[0] = -1.0; | |||
| 701 | } | |||
| 702 | else if (PyNumber_Check(pwe) && !PyArray_Check(pwe)((((PyObject*)(pwe))->ob_type) == (&(*(PyTypeObject *) PyArray_API[2])) || PyType_IsSubtype((((PyObject*)(pwe))-> ob_type), (&(*(PyTypeObject *)PyArray_API[2]))))) | |||
| 703 | { | |||
| 704 | /* we is a single weight, set the first value of we to -pwe */ | |||
| 705 | PyObject *tmp; | |||
| 706 | double val; | |||
| 707 | ||||
| 708 | tmp = PyNumber_Float(pwe); | |||
| 709 | if (tmp == NULL((void*)0)) | |||
| 710 | PYERR(PyExc_ValueError, "could not convert we to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert we to a suitable array" ); goto fail;}; | |||
| 711 | val = PyFloat_AsDouble(tmp); | |||
| 712 | Py_DECREF(tmp)_Py_DECREF(((PyObject*)(tmp))); | |||
| 713 | ||||
| 714 | dim3[0] = nq; | |||
| 715 | dim3[1] = 1; | |||
| 716 | dim3[2] = 1; | |||
| 717 | we = (PyArrayObject *) PyArray_SimpleNew(3, dim3, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 3, dim3, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 718 | if (implicit) | |||
| 719 | { | |||
| 720 | ((double *)(PyArray_DATA(we)))[0] = val; | |||
| 721 | } | |||
| 722 | else | |||
| 723 | { | |||
| 724 | ((double *)(PyArray_DATA(we)))[0] = -val; | |||
| 725 | } | |||
| 726 | ldwe = ld2we = 1; | |||
| 727 | } | |||
| 728 | else if (PySequence_Check(pwe)) | |||
| 729 | { | |||
| 730 | /* we needs to be turned into an array */ | |||
| 731 | ||||
| 732 | if ((we = | |||
| 733 | (PyArrayObject *) PyArray_CopyFromObject(pwe, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pwe, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 3, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 734 | 3)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pwe, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 3, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 735 | { | |||
| 736 | PYERR(PyExc_ValueError, "could not convert we to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert we to a suitable array" ); goto fail;}; | |||
| 737 | } | |||
| 738 | ||||
| 739 | if (PyArray_NDIM(we) == 1 && nq == 1) | |||
| 740 | { | |||
| 741 | ||||
| 742 | ldwe = n; | |||
| 743 | ld2we = 1; | |||
| 744 | } | |||
| 745 | else if (PyArray_NDIM(we) == 1 && PyArray_DIMS(we)[0] == nq) | |||
| 746 | { | |||
| 747 | /* we is a rank-1 array with diagonal weightings to be broadcast | |||
| 748 | * to all observations */ | |||
| 749 | ldwe = 1; | |||
| 750 | ld2we = 1; | |||
| 751 | } | |||
| 752 | else if (PyArray_NDIM(we) == 3 && PyArray_DIMS(we)[0] == nq | |||
| 753 | && PyArray_DIMS(we)[1] == nq && PyArray_DIMS(we)[2] == 1) | |||
| 754 | { | |||
| 755 | /* we is a rank-3 array with the covariant weightings | |||
| 756 | to be broadcast to all observations */ | |||
| 757 | ldwe = 1; | |||
| 758 | ld2we = nq; | |||
| 759 | } | |||
| 760 | else if (PyArray_NDIM(we) == 2 && PyArray_DIMS(we)[0] == nq | |||
| 761 | && PyArray_DIMS(we)[1] == nq) | |||
| 762 | { | |||
| 763 | /* we is a rank-2 array with the full covariant weightings | |||
| 764 | to be broadcast to all observations */ | |||
| 765 | ldwe = 1; | |||
| 766 | ld2we = nq; | |||
| 767 | } | |||
| 768 | ||||
| 769 | else if (PyArray_NDIM(we) == 2 && PyArray_DIMS(we)[0] == nq | |||
| 770 | && PyArray_DIMS(we)[1] == n) | |||
| 771 | { | |||
| 772 | /* we is a rank-2 array with the diagonal elements of the | |||
| 773 | covariant weightings for each observation */ | |||
| 774 | ldwe = n; | |||
| 775 | ld2we = 1; | |||
| 776 | } | |||
| 777 | else if (PyArray_NDIM(we) == 3 && PyArray_DIMS(we)[0] == nq | |||
| 778 | && PyArray_DIMS(we)[1] == nq && PyArray_DIMS(we)[2] == n) | |||
| 779 | { | |||
| 780 | /* we is the full specification of the covariant weights | |||
| 781 | for each observation */ | |||
| 782 | ldwe = n; | |||
| 783 | ld2we = nq; | |||
| 784 | } | |||
| 785 | else | |||
| 786 | { | |||
| 787 | PYERR(PyExc_ValueError, "could not convert we to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert we to a suitable array" ); goto fail;}; | |||
| 788 | } | |||
| 789 | } /* we */ | |||
| 790 | ||||
| 791 | if (pwd == NULL((void*)0)) | |||
| 792 | { | |||
| 793 | ldwd = ld2wd = 1; | |||
| 794 | ||||
| 795 | dim1[0] = m; | |||
| 796 | wd = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 797 | ((double *)(PyArray_DATA(wd)))[0] = -1.0; | |||
| 798 | } | |||
| 799 | else if (PyNumber_Check(pwd) && !PyArray_Check(pwd)((((PyObject*)(pwd))->ob_type) == (&(*(PyTypeObject *) PyArray_API[2])) || PyType_IsSubtype((((PyObject*)(pwd))-> ob_type), (&(*(PyTypeObject *)PyArray_API[2]))))) | |||
| 800 | { | |||
| 801 | /* wd is a single weight, set the first value of wd to -pwd */ | |||
| 802 | PyObject *tmp; | |||
| 803 | double val; | |||
| 804 | ||||
| 805 | tmp = PyNumber_Float(pwd); | |||
| 806 | if (tmp == NULL((void*)0)) | |||
| 807 | PYERR(PyExc_ValueError, "could not convert wd to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert wd to a suitable array" ); goto fail;}; | |||
| 808 | val = PyFloat_AsDouble(tmp); | |||
| 809 | Py_DECREF(tmp)_Py_DECREF(((PyObject*)(tmp))); | |||
| 810 | ||||
| 811 | dim3[0] = 1; | |||
| 812 | dim3[1] = 1; | |||
| 813 | dim3[2] = m; | |||
| 814 | wd = (PyArrayObject *) PyArray_SimpleNew(3, dim3, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 3, dim3, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 815 | ((double *)(PyArray_DATA(wd)))[0] = -val; | |||
| 816 | ldwd = ld2wd = 1; | |||
| 817 | } | |||
| 818 | else if (PySequence_Check(pwd)) | |||
| 819 | { | |||
| 820 | /* wd needs to be turned into an array */ | |||
| 821 | ||||
| 822 | if ((wd = | |||
| 823 | (PyArrayObject *) PyArray_CopyFromObject(pwd, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pwd, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 3, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 824 | 3)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pwd, (*(PyArray_Descr * (*)(int )) PyArray_API[45])(NPY_DOUBLE), 1, 3, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 825 | { | |||
| 826 | PYERR(PyExc_ValueError, "could not convert wd to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert wd to a suitable array" ); goto fail;}; | |||
| 827 | } | |||
| 828 | ||||
| 829 | if (PyArray_NDIM(wd) == 1 && m == 1) | |||
| 830 | { | |||
| 831 | ldwd = n; | |||
| 832 | ld2wd = 1; | |||
| 833 | } | |||
| 834 | else if (PyArray_NDIM(wd) == 1 && PyArray_DIMS(wd)[0] == m) | |||
| 835 | { | |||
| 836 | /* wd is a rank-1 array with diagonal weightings to be broadcast | |||
| 837 | * to all observations */ | |||
| 838 | ldwd = 1; | |||
| 839 | ld2wd = 1; | |||
| 840 | } | |||
| 841 | ||||
| 842 | else if (PyArray_NDIM(wd) == 3 && PyArray_DIMS(wd)[0] == m | |||
| 843 | && PyArray_DIMS(wd)[1] == m && PyArray_DIMS(wd)[2] == 1) | |||
| 844 | { | |||
| 845 | /* wd is a rank-3 array with the covariant wdightings | |||
| 846 | to be broadcast to all observations */ | |||
| 847 | ldwd = 1; | |||
| 848 | ld2wd = m; | |||
| 849 | } | |||
| 850 | else if (PyArray_NDIM(wd) == 2 && PyArray_DIMS(wd)[0] == m | |||
| 851 | && PyArray_DIMS(wd)[1] == m) | |||
| 852 | { | |||
| 853 | /* wd is a rank-2 array with the full covariant weightings | |||
| 854 | to be broadcast to all observations */ | |||
| 855 | ldwd = 1; | |||
| 856 | ld2wd = m; | |||
| 857 | } | |||
| 858 | ||||
| 859 | else if (PyArray_NDIM(wd) == 2 && PyArray_DIMS(wd)[0] == m | |||
| 860 | && PyArray_DIMS(wd)[1] == n) | |||
| 861 | { | |||
| 862 | /* wd is a rank-2 array with the diagonal elements of the | |||
| 863 | covariant weightings for each observation */ | |||
| 864 | ldwd = n; | |||
| 865 | ld2wd = 1; | |||
| 866 | } | |||
| 867 | else if (PyArray_NDIM(wd) == 3 && PyArray_DIMS(wd)[0] == m | |||
| 868 | && PyArray_DIMS(wd)[1] == m && PyArray_DIMS(wd)[2] == n) | |||
| 869 | { | |||
| 870 | /* wd is the full specification of the covariant weights | |||
| 871 | for each observation */ | |||
| 872 | ldwd = n; | |||
| 873 | ld2wd = m; | |||
| 874 | } | |||
| 875 | else | |||
| 876 | { | |||
| 877 | PYERR(PyExc_ValueError, "could not convert wd to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert wd to a suitable array" ); goto fail;}; | |||
| 878 | } | |||
| 879 | ||||
| 880 | } /* wd */ | |||
| 881 | ||||
| 882 | ||||
| 883 | if (pifixb == NULL((void*)0)) | |||
| 884 | { | |||
| 885 | dim1[0] = np; | |||
| 886 | ifixb = (PyArrayObject *) PyArray_SimpleNew(1, dim1, F_INT_NPY)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_INT , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 887 | *(F_INTint *)(PyArray_DATA(ifixb)) = -1; /* set first element negative */ | |||
| 888 | } | |||
| 889 | else | |||
| 890 | { | |||
| 891 | /* pifixb is a sequence as checked before */ | |||
| 892 | ||||
| 893 | if ((ifixb = | |||
| 894 | (PyArrayObject *) PyArray_CopyFromObject(pifixb, F_INT_NPY, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pifixb, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_INT), 1, 1, 0x0020 | ((0x0001 | ( 0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 895 | 1)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pifixb, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_INT), 1, 1, 0x0020 | ((0x0001 | ( 0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 896 | { | |||
| 897 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert ifixb to a suitable array" ); goto fail;} | |||
| 898 | "could not convert ifixb to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert ifixb to a suitable array" ); goto fail;}; | |||
| 899 | } | |||
| 900 | ||||
| 901 | if (PyArray_DIMS(ifixb)[0] != np) | |||
| 902 | { | |||
| 903 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert ifixb to a suitable array" ); goto fail;} | |||
| 904 | "could not convert ifixb to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert ifixb to a suitable array" ); goto fail;}; | |||
| 905 | } | |||
| 906 | } /* ifixb */ | |||
| 907 | ||||
| 908 | if (pifixx == NULL((void*)0)) | |||
| 909 | { | |||
| 910 | dim2[0] = m; | |||
| 911 | dim2[1] = 1; | |||
| 912 | ifixx = (PyArrayObject *) PyArray_SimpleNew(2, dim2, F_INT_NPY)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 2, dim2, NPY_INT , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 913 | *(F_INTint *)(PyArray_DATA(ifixx)) = -1; /* set first element negative */ | |||
| 914 | ldifx = 1; | |||
| 915 | } | |||
| 916 | else | |||
| 917 | { | |||
| 918 | /* pifixx is a sequence as checked before */ | |||
| 919 | ||||
| 920 | if ((ifixx = | |||
| 921 | (PyArrayObject *) PyArray_CopyFromObject(pifixx, F_INT_NPY, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pifixx, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_INT), 1, 2, 0x0020 | ((0x0001 | ( 0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 922 | 2)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pifixx, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_INT), 1, 2, 0x0020 | ((0x0001 | ( 0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 923 | { | |||
| 924 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert ifixx to a suitable array" ); goto fail;} | |||
| 925 | "could not convert ifixx to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert ifixx to a suitable array" ); goto fail;}; | |||
| 926 | } | |||
| 927 | ||||
| 928 | if (PyArray_NDIM(ifixx) == 1 && PyArray_DIMS(ifixx)[0] == m) | |||
| 929 | { | |||
| 930 | ldifx = 1; | |||
| 931 | } | |||
| 932 | else if (PyArray_NDIM(ifixx) == 1 && PyArray_DIMS(ifixx)[0] == n && m == 1) | |||
| 933 | { | |||
| 934 | ldifx = n; | |||
| 935 | } | |||
| 936 | else if (PyArray_NDIM(ifixx) == 2 && PyArray_DIMS(ifixx)[0] == m | |||
| 937 | && PyArray_DIMS(ifixx)[1] == n) | |||
| 938 | { | |||
| 939 | ldifx = n; | |||
| 940 | } | |||
| 941 | else | |||
| 942 | { | |||
| 943 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert ifixx to a suitable array" ); goto fail;} | |||
| 944 | "could not convert ifixx to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert ifixx to a suitable array" ); goto fail;}; | |||
| 945 | } | |||
| 946 | } /* ifixx */ | |||
| 947 | ||||
| 948 | if (errfile != NULL((void*)0)) | |||
| 949 | { | |||
| 950 | /* call FORTRAN's OPEN to open the file with a logical unit of 18 */ | |||
| 951 | lunerr = 18; | |||
| 952 | F_FUNC(dluno,DLUNO)dluno_(&lunerr, errfile, lerrfile); | |||
| 953 | } | |||
| 954 | ||||
| 955 | if (rptfile != NULL((void*)0)) | |||
| 956 | { | |||
| 957 | /* call FORTRAN's OPEN to open the file with a logical unit of 19 */ | |||
| 958 | lunrpt = 19; | |||
| 959 | F_FUNC(dluno,DLUNO)dluno_(&lunrpt, rptfile, lrptfile); | |||
| 960 | } | |||
| 961 | ||||
| 962 | if (pstpb == NULL((void*)0)) | |||
| 963 | { | |||
| 964 | dim1[0] = np; | |||
| 965 | stpb = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 966 | *(double *)(PyArray_DATA(stpb)) = 0.0; | |||
| 967 | } | |||
| 968 | else /* pstpb is a sequence */ | |||
| 969 | { | |||
| 970 | if ((stpb = | |||
| 971 | (PyArrayObject *) PyArray_CopyFromObject(pstpb, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pstpb, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 1, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 972 | 1)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pstpb, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 1, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0) | |||
| 973 | || PyArray_DIMS(stpb)[0] != np) | |||
| 974 | { | |||
| 975 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert stpb to a suitable array" ); goto fail;} | |||
| 976 | "could not convert stpb to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert stpb to a suitable array" ); goto fail;}; | |||
| 977 | } | |||
| 978 | } /* stpb */ | |||
| 979 | ||||
| 980 | if (pstpd == NULL((void*)0)) | |||
| 981 | { | |||
| 982 | dim2[0] = 1; | |||
| 983 | dim2[1] = m; | |||
| 984 | stpd = (PyArrayObject *) PyArray_SimpleNew(2, dim2, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 2, dim2, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 985 | *(double *)(PyArray_DATA(stpd)) = 0.0; | |||
| 986 | ldstpd = 1; | |||
| 987 | } | |||
| 988 | else | |||
| 989 | { | |||
| 990 | if ((stpd = | |||
| 991 | (PyArrayObject *) PyArray_CopyFromObject(pstpd, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pstpd, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 992 | 2)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pstpd, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 993 | { | |||
| 994 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert stpb to a suitable array" ); goto fail;} | |||
| 995 | "could not convert stpb to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert stpb to a suitable array" ); goto fail;}; | |||
| 996 | } | |||
| 997 | ||||
| 998 | if (PyArray_NDIM(stpd) == 1 && PyArray_DIMS(stpd)[0] == m) | |||
| 999 | { | |||
| 1000 | ldstpd = 1; | |||
| 1001 | } | |||
| 1002 | else if (PyArray_NDIM(stpd) == 1 && PyArray_DIMS(stpd)[0] == n && m == 1) | |||
| 1003 | { | |||
| 1004 | ldstpd = n; | |||
| 1005 | } | |||
| 1006 | else if (PyArray_NDIM(stpd) == 2 && PyArray_DIMS(stpd)[0] == n && | |||
| 1007 | PyArray_DIMS(stpd)[1] == m) | |||
| 1008 | { | |||
| 1009 | ldstpd = n; | |||
| 1010 | } | |||
| 1011 | } /* stpd */ | |||
| 1012 | ||||
| 1013 | if (psclb == NULL((void*)0)) | |||
| 1014 | { | |||
| 1015 | dim1[0] = np; | |||
| 1016 | sclb = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 1017 | *(double *)(PyArray_DATA(sclb)) = 0.0; | |||
| 1018 | } | |||
| 1019 | else /* psclb is a sequence */ | |||
| 1020 | { | |||
| 1021 | if ((sclb = | |||
| 1022 | (PyArrayObject *) PyArray_CopyFromObject(psclb, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(psclb, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 1, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 1023 | 1)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(psclb, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 1, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0) | |||
| 1024 | || PyArray_DIMS(sclb)[0] != np) | |||
| 1025 | { | |||
| 1026 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert sclb to a suitable array" ); goto fail;} | |||
| 1027 | "could not convert sclb to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert sclb to a suitable array" ); goto fail;}; | |||
| 1028 | } | |||
| 1029 | } /* sclb */ | |||
| 1030 | ||||
| 1031 | if (pscld == NULL((void*)0)) | |||
| 1032 | { | |||
| 1033 | dim2[0] = 1; | |||
| 1034 | dim2[1] = n; | |||
| 1035 | scld = (PyArrayObject *) PyArray_SimpleNew(2, dim2, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 2, dim2, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 1036 | *(double *)(PyArray_DATA(scld)) = 0.0; | |||
| 1037 | ldscld = 1; | |||
| 1038 | } | |||
| 1039 | else | |||
| 1040 | { | |||
| 1041 | if ((scld = | |||
| 1042 | (PyArrayObject *) PyArray_CopyFromObject(pscld, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pscld, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 1043 | 2)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pscld, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 2, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 1044 | { | |||
| 1045 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert stpb to a suitable array" ); goto fail;} | |||
| 1046 | "could not convert stpb to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert stpb to a suitable array" ); goto fail;}; | |||
| 1047 | } | |||
| 1048 | ||||
| 1049 | if (PyArray_NDIM(scld) == 1 && PyArray_DIMS(scld)[0] == m) | |||
| 1050 | { | |||
| 1051 | ldscld = 1; | |||
| 1052 | } | |||
| 1053 | else if (PyArray_NDIM(scld) == 1 && PyArray_DIMS(scld)[0] == n && m == 1) | |||
| 1054 | { | |||
| 1055 | ldscld = n; | |||
| 1056 | } | |||
| 1057 | else if (PyArray_NDIM(scld) == 2 && PyArray_DIMS(scld)[0] == n && | |||
| 1058 | PyArray_DIMS(scld)[1] == m) | |||
| 1059 | { | |||
| 1060 | ldscld = n; | |||
| 1061 | } | |||
| 1062 | } /* scld */ | |||
| 1063 | ||||
| 1064 | if (job % 10 < 2) | |||
| 1065 | { | |||
| 1066 | /* ODR, not OLS */ | |||
| 1067 | ||||
| 1068 | lwork = | |||
| 1069 | 18 + 11 * np + np * np + m + m * m + 4 * n * nq + 6 * n * m + | |||
| 1070 | 2 * n * nq * np + 2 * n * nq * m + nq * nq + 5 * nq + nq * (np + m) + | |||
| 1071 | ldwe * ld2we * nq; | |||
| 1072 | ||||
| 1073 | isodr = 1; | |||
| 1074 | } | |||
| 1075 | else | |||
| 1076 | { | |||
| 1077 | /* OLS, not ODR */ | |||
| 1078 | ||||
| 1079 | lwork = | |||
| 1080 | 18 + 11 * np + np * np + m + m * m + 4 * n * nq + 2 * n * m + | |||
| 1081 | 2 * n * nq * np + 5 * nq + nq * (np + m) + ldwe * ld2we * nq; | |||
| 1082 | ||||
| 1083 | isodr = 0; | |||
| 1084 | } | |||
| 1085 | ||||
| 1086 | liwork = 20 + np + nq * (np + m); | |||
| 1087 | ||||
| 1088 | if ((job / 10000) % 10 >= 1) | |||
| 1089 | { | |||
| 1090 | /* fit is a restart, make sure work and iwork are input */ | |||
| 1091 | ||||
| 1092 | if (pwork == NULL((void*)0) || piwork == NULL((void*)0)) | |||
| 1093 | { | |||
| 1094 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"need to input work and iwork arrays to restart" ); goto fail;} | |||
| 1095 | "need to input work and iwork arrays to restart"){PyErr_SetString(PyExc_ValueError,"need to input work and iwork arrays to restart" ); goto fail;}; | |||
| 1096 | } | |||
| 1097 | } | |||
| 1098 | ||||
| 1099 | if ((job / 1000) % 10 >= 1) | |||
| 1100 | { | |||
| 1101 | /* delta should be supplied, make sure the user does */ | |||
| 1102 | ||||
| 1103 | if (pwork == NULL((void*)0)) | |||
| 1104 | { | |||
| 1105 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"need to input work array for delta initialization" ); goto fail;} | |||
| 1106 | "need to input work array for delta initialization"){PyErr_SetString(PyExc_ValueError,"need to input work array for delta initialization" ); goto fail;}; | |||
| 1107 | } | |||
| 1108 | } | |||
| 1109 | ||||
| 1110 | if (pwork != NULL((void*)0)) | |||
| 1111 | { | |||
| 1112 | if ((work = | |||
| 1113 | (PyArrayObject *) PyArray_CopyFromObject(pwork, NPY_DOUBLE, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pwork, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 1, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 1114 | 1)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(pwork, (*(PyArray_Descr * (*)( int)) PyArray_API[45])(NPY_DOUBLE), 1, 1, 0x0020 | ((0x0001 | (0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 1115 | { | |||
| 1116 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert work to a suitable array" ); goto fail;} | |||
| 1117 | "could not convert work to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert work to a suitable array" ); goto fail;}; | |||
| 1118 | } | |||
| 1119 | if (PyArray_DIMS(work)[0] < lwork) | |||
| 1120 | { | |||
| 1121 | printf("%ld %lld\n", PyArray_DIMS(work)[0], (long long)lwork)__printf_chk (2 - 1, "%ld %lld\n", PyArray_DIMS(work)[0], (long long)lwork); | |||
| 1122 | PYERR(PyExc_ValueError, "work is too small"){PyErr_SetString(PyExc_ValueError,"work is too small"); goto fail ;}; | |||
| 1123 | } | |||
| 1124 | } | |||
| 1125 | else | |||
| 1126 | { | |||
| 1127 | /* initialize our own work array */ | |||
| 1128 | dim1[0] = lwork; | |||
| 1129 | work = (PyArrayObject *) PyArray_SimpleNew(1, dim1, NPY_DOUBLE)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_DOUBLE , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 1130 | } /* work */ | |||
| 1131 | ||||
| 1132 | if (piwork != NULL((void*)0)) | |||
| 1133 | { | |||
| 1134 | if ((iwork = | |||
| 1135 | (PyArrayObject *) PyArray_CopyFromObject(piwork, F_INT_NPY, 1,(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(piwork, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_INT), 1, 1, 0x0020 | ((0x0001 | ( 0x0100 | 0x0400))) | 0x0040, ((void*)0)) | |||
| 1136 | 1)(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) PyArray_API[69])(piwork, (*(PyArray_Descr * (*) (int)) PyArray_API[45])(NPY_INT), 1, 1, 0x0020 | ((0x0001 | ( 0x0100 | 0x0400))) | 0x0040, ((void*)0))) == NULL((void*)0)) | |||
| 1137 | { | |||
| 1138 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"could not convert iwork to a suitable array" ); goto fail;} | |||
| 1139 | "could not convert iwork to a suitable array"){PyErr_SetString(PyExc_ValueError,"could not convert iwork to a suitable array" ); goto fail;}; | |||
| 1140 | } | |||
| 1141 | ||||
| 1142 | if (PyArray_DIMS(iwork)[0] < liwork) | |||
| 1143 | { | |||
| 1144 | PYERR(PyExc_ValueError, "iwork is too small"){PyErr_SetString(PyExc_ValueError,"iwork is too small"); goto fail;}; | |||
| 1145 | } | |||
| 1146 | } | |||
| 1147 | else | |||
| 1148 | { | |||
| 1149 | /* initialize our own iwork array */ | |||
| 1150 | dim1[0] = liwork; | |||
| 1151 | iwork = (PyArrayObject *) PyArray_SimpleNew(1, dim1, F_INT_NPY)(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) PyArray_API [93])(&(*(PyTypeObject *)PyArray_API[2]), 1, dim1, NPY_INT , ((void*)0), ((void*)0), 0, 0, ((void*)0)); | |||
| 1152 | } /* iwork */ | |||
| 1153 | ||||
| 1154 | /* check if what JOB requests can be done with what the user has | |||
| 1155 | input into the function */ | |||
| 1156 | ||||
| 1157 | if ((job / 10) % 10 >= 2) | |||
| 1158 | { | |||
| 1159 | /* derivatives are supposed to be supplied */ | |||
| 1160 | ||||
| 1161 | if (fjacb == NULL((void*)0) || fjacd == NULL((void*)0)) | |||
| 1162 | { | |||
| 1163 | PYERR(PyExc_ValueError,{PyErr_SetString(PyExc_ValueError,"need fjacb and fjacd to calculate derivatives" ); goto fail;} | |||
| 1164 | "need fjacb and fjacd to calculate derivatives"){PyErr_SetString(PyExc_ValueError,"need fjacb and fjacd to calculate derivatives" ); goto fail;}; | |||
| 1165 | } | |||
| 1166 | } | |||
| 1167 | ||||
| 1168 | /* setup the global data for the callback */ | |||
| 1169 | odr_global.fcn = fcn; | |||
| 1170 | Py_INCREF(fcn)_Py_INCREF(((PyObject*)(fcn))); | |||
| 1171 | odr_global.fjacb = fjacb; | |||
| 1172 | Py_XINCREF(fjacb)_Py_XINCREF(((PyObject*)(fjacb))); | |||
| 1173 | odr_global.fjacd = fjacd; | |||
| 1174 | Py_XINCREF(fjacd)_Py_XINCREF(((PyObject*)(fjacd))); | |||
| 1175 | odr_global.pyBeta = (PyObject *) beta; | |||
| 1176 | Py_INCREF(beta)_Py_INCREF(((PyObject*)(beta))); | |||
| 1177 | odr_global.extra_args = extra_args; | |||
| 1178 | Py_XINCREF(extra_args)_Py_XINCREF(((PyObject*)(extra_args))); | |||
| 1179 | /* now call DODRC */ | |||
| 1180 | F_FUNC(dodrc,DODRC)dodrc_(fcn_callback, &n, &m, &np, &nq, (double *)(PyArray_DATA(beta)), | |||
| 1181 | (double *)(PyArray_DATA(y)), &ldy, (double *)(PyArray_DATA(x)), &ldx, | |||
| 1182 | (double *)(PyArray_DATA(we)), &ldwe, &ld2we, | |||
| 1183 | (double *)(PyArray_DATA(wd)), &ldwd, &ld2wd, | |||
| 1184 | (F_INTint *)(PyArray_DATA(ifixb)), (F_INTint *)(PyArray_DATA(ifixx)), &ldifx, | |||
| 1185 | &job, &ndigit, &taufac, &sstol, &partol, &maxit, | |||
| 1186 | &iprint, &lunerr, &lunrpt, | |||
| 1187 | (double *)(PyArray_DATA(stpb)), (double *)(PyArray_DATA(stpd)), &ldstpd, | |||
| 1188 | (double *)(PyArray_DATA(sclb)), (double *)(PyArray_DATA(scld)), &ldscld, | |||
| 1189 | (double *)(PyArray_DATA(work)), &lwork, (F_INTint *)(PyArray_DATA(iwork)), &liwork, | |||
| 1190 | &info); | |||
| 1191 | ||||
| 1192 | result = gen_output(n, m, np, nq, ldwe, ld2we, | |||
| 1193 | beta, work, iwork, isodr, info, full_output); | |||
| 1194 | ||||
| 1195 | if (result == NULL((void*)0)) | |||
| 1196 | PYERR(PyExc_RuntimeError, "could not generate output"){PyErr_SetString(PyExc_RuntimeError,"could not generate output" ); goto fail;}; | |||
| 1197 | ||||
| 1198 | if (lunerr != -1) | |||
| 1199 | { | |||
| 1200 | F_FUNC(dlunc,DLUNC)dlunc_(&lunerr); | |||
| 1201 | } | |||
| 1202 | if (lunrpt != -1) | |||
| 1203 | { | |||
| 1204 | F_FUNC(dlunc,DLUNC)dlunc_(&lunrpt); | |||
| 1205 | } | |||
| 1206 | ||||
| 1207 | Py_DECREF(odr_global.fcn)_Py_DECREF(((PyObject*)(odr_global.fcn))); | |||
| 1208 | Py_XDECREF(odr_global.fjacb)_Py_XDECREF(((PyObject*)(odr_global.fjacb))); | |||
| 1209 | Py_XDECREF(odr_global.fjacd)_Py_XDECREF(((PyObject*)(odr_global.fjacd))); | |||
| 1210 | Py_DECREF(odr_global.pyBeta)_Py_DECREF(((PyObject*)(odr_global.pyBeta))); | |||
| 1211 | Py_XDECREF(odr_global.extra_args)_Py_XDECREF(((PyObject*)(odr_global.extra_args))); | |||
| 1212 | ||||
| 1213 | odr_global.fcn = odr_global.fjacb = odr_global.fjacd = odr_global.pyBeta = | |||
| 1214 | odr_global.extra_args = NULL((void*)0); | |||
| 1215 | ||||
| 1216 | Py_DECREF(beta)_Py_DECREF(((PyObject*)(beta))); | |||
| 1217 | Py_DECREF(y)_Py_DECREF(((PyObject*)(y))); | |||
| 1218 | Py_DECREF(x)_Py_DECREF(((PyObject*)(x))); | |||
| 1219 | Py_DECREF(we)_Py_DECREF(((PyObject*)(we))); | |||
| 1220 | Py_DECREF(wd)_Py_DECREF(((PyObject*)(wd))); | |||
| 1221 | Py_DECREF(ifixb)_Py_DECREF(((PyObject*)(ifixb))); | |||
| 1222 | Py_DECREF(ifixx)_Py_DECREF(((PyObject*)(ifixx))); | |||
| 1223 | Py_DECREF(stpb)_Py_DECREF(((PyObject*)(stpb))); | |||
| 1224 | Py_DECREF(stpd)_Py_DECREF(((PyObject*)(stpd))); | |||
| 1225 | Py_DECREF(sclb)_Py_DECREF(((PyObject*)(sclb))); | |||
| 1226 | Py_DECREF(scld)_Py_DECREF(((PyObject*)(scld))); | |||
| 1227 | Py_DECREF(work)_Py_DECREF(((PyObject*)(work))); | |||
| 1228 | Py_DECREF(iwork)_Py_DECREF(((PyObject*)(iwork))); | |||
| 1229 | ||||
| 1230 | return result; | |||
| 1231 | ||||
| 1232 | fail: | |||
| 1233 | ||||
| 1234 | ||||
| 1235 | if (lunerr != -1) | |||
| 1236 | { | |||
| 1237 | F_FUNC(dlunc,DLUNC)dlunc_(&lunerr); | |||
| 1238 | } | |||
| 1239 | if (lunrpt != -1) | |||
| 1240 | { | |||
| 1241 | F_FUNC(dlunc,DLUNC)dlunc_(&lunrpt); | |||
| 1242 | } | |||
| 1243 | ||||
| 1244 | Py_XDECREF(beta)_Py_XDECREF(((PyObject*)(beta))); | |||
| 1245 | Py_XDECREF(y)_Py_XDECREF(((PyObject*)(y))); | |||
| 1246 | Py_XDECREF(x)_Py_XDECREF(((PyObject*)(x))); | |||
| 1247 | Py_XDECREF(we)_Py_XDECREF(((PyObject*)(we))); | |||
| 1248 | Py_XDECREF(wd)_Py_XDECREF(((PyObject*)(wd))); | |||
| 1249 | Py_XDECREF(ifixb)_Py_XDECREF(((PyObject*)(ifixb))); | |||
| 1250 | Py_XDECREF(ifixx)_Py_XDECREF(((PyObject*)(ifixx))); | |||
| 1251 | Py_XDECREF(stpb)_Py_XDECREF(((PyObject*)(stpb))); | |||
| 1252 | Py_XDECREF(stpd)_Py_XDECREF(((PyObject*)(stpd))); | |||
| 1253 | Py_XDECREF(sclb)_Py_XDECREF(((PyObject*)(sclb))); | |||
| 1254 | Py_XDECREF(scld)_Py_XDECREF(((PyObject*)(scld))); | |||
| 1255 | Py_XDECREF(work)_Py_XDECREF(((PyObject*)(work))); | |||
| 1256 | Py_XDECREF(iwork)_Py_XDECREF(((PyObject*)(iwork))); | |||
| 1257 | ||||
| 1258 | return NULL((void*)0); | |||
| 1259 | } | |||
| 1260 | ||||
| 1261 | ||||
| 1262 | PyObject *set_exceptions(PyObject * self, PyObject * args, PyObject * kwds) | |||
| 1263 | { | |||
| 1264 | PyObject *exc_error, *exc_stop; | |||
| 1265 | ||||
| 1266 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "OO", &exc_error, &exc_stop)) | |||
| 1267 | return NULL((void*)0); | |||
| 1268 | ||||
| 1269 | Py_INCREF(exc_stop)_Py_INCREF(((PyObject*)(exc_stop))); | |||
| 1270 | Py_INCREF(exc_error)_Py_INCREF(((PyObject*)(exc_error))); | |||
| 1271 | odr_stop = exc_stop; | |||
| 1272 | odr_error = exc_error; | |||
| 1273 | ||||
| 1274 | Py_INCREF(Py_None)_Py_INCREF(((PyObject*)((&_Py_NoneStruct)))); | |||
| 1275 | return Py_None(&_Py_NoneStruct); | |||
| 1276 | } | |||
| 1277 | ||||
| 1278 | static PyMethodDef methods[] = { | |||
| 1279 | {"_set_exceptions", (PyCFunction) set_exceptions, METH_VARARGS0x0001, NULL((void*)0)}, | |||
| 1280 | {"odr", (PyCFunction) odr, METH_VARARGS0x0001 | METH_KEYWORDS0x0002, NULL((void*)0)}, | |||
| 1281 | {NULL((void*)0), NULL((void*)0)}, | |||
| 1282 | }; | |||
| 1283 | ||||
| 1284 | static struct PyModuleDef moduledef = { | |||
| 1285 | PyModuleDef_HEAD_INIT{ { 1, ((void*)0) }, ((void*)0), 0, ((void*)0), }, | |||
| 1286 | "_odrpack", | |||
| 1287 | NULL((void*)0), | |||
| 1288 | -1, | |||
| 1289 | methods, | |||
| 1290 | NULL((void*)0), | |||
| 1291 | NULL((void*)0), | |||
| 1292 | NULL((void*)0), | |||
| 1293 | NULL((void*)0) | |||
| 1294 | }; | |||
| 1295 | ||||
| 1296 | PyObject *PyInit___odrpack(void) | |||
| 1297 | { | |||
| 1298 | PyObject *m; | |||
| 1299 | import_array(){if (_import_array() < 0) {PyErr_Print(); PyErr_SetString( PyExc_ImportError, "numpy.core.multiarray failed to import"); return ((void*)0); } }; | |||
| 1300 | m = PyModule_Create(&moduledef)PyModule_Create2(&moduledef, 1013); | |||
| 1301 | return m; | |||
| 1302 | } |
| 1 | #ifndef PyTuple_SetItem |
| 2 | struct _object; |
| 3 | typedef struct _object PyObject; |
| 4 | void clang_analyzer_PyObject_Steal_Reference(const void *); |
| 5 | int clang_analyzer_noimpl_conjure_int(); |
| 6 | int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o) { |
| 7 | clang_analyzer_PyObject_Steal_Reference(o); |
| 8 | return clang_analyzer_noimpl_conjure_int(); |
| 9 | } |
| 10 | #else |
| 11 | #warning "API PyTuple_SetItem is defined as a macro." |
| 12 | #endif |