forked from scipy/scipy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
odrpack.h
57 lines (45 loc) · 1.59 KB
/
odrpack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "Python.h"
#include "numpy/arrayobject.h"
#include "numpy/npy_3kcompat.h"
#if defined(NO_APPEND_FORTRAN)
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) F
#else
#define F_FUNC(f,F) f
#endif
#else
#if defined(UPPERCASE_FORTRAN)
#define F_FUNC(f,F) F##_
#else
#define F_FUNC(f,F) f##_
#endif
#endif
#define PYERR(errobj,message) {PyErr_SetString(errobj,message); goto fail;}
#define PYERR2(errobj,message) {PyErr_Print(); PyErr_SetString(errobj, message); goto fail;}
#define ISCONTIGUOUS(m) ((m)->flags & CONTIGUOUS)
#define MAX(n1,n2) ((n1) > (n2))?(n1):(n2);
#define MIN(n1,n2) ((n1) > (n2))?(n2):(n1);
struct ODR_info_ {
PyObject* fcn;
PyObject* fjacb;
PyObject* fjacd;
PyObject* pyBeta;
PyObject* extra_args;
};
typedef struct ODR_info_ ODR_info;
static ODR_info odr_global;
static PyObject *odr_error=NULL;
static PyObject *odr_stop=NULL;
void fcn_callback(int *n, int *m, int *np, int *nq, int *ldn, int *ldm,
int *ldnp, double *beta, double *xplusd, int *ifixb,
int *ifixx, int *ldfix, int *ideval, double *f,
double *fjacb, double *fjacd, int *istop);
PyObject *gen_output(int n, int m, int np, int nq, int ldwe, int ld2we,
PyArrayObject *beta, PyArrayObject *work, PyArrayObject *iwork,
int isodr, int info, int full_output);
PyObject *odr(PyObject *self, PyObject *args, PyObject *kwds);
#define PyArray_CONTIGUOUS(m) (ISCONTIGUOUS(m) ? Py_INCREF(m), m : \
(PyArrayObject *)(PyArray_ContiguousFromObject((PyObject *)(m), \
(m)->descr->type_num, 0,0)))
#define D(dbg) printf("we're here: %i\n", dbg)
#define EXIST(name,obj) if (obj==NULL){printf("%s\n",name);}