2
Python-C wrapper of FITPACK (by P. Dierckx) (in netlib known as dierckx)
3
Author: Pearu Peterson <pearu@ioc.ee>
7
$Date: 2006-05-27 03:51:39 -0600 (Sat, 27 May 2006) $
11
{"_curfit", fitpack_curfit, METH_VARARGS, doc_curfit},
12
{"_spl_", fitpack_spl_, METH_VARARGS, doc_spl_},
13
{"_splint", fitpack_splint, METH_VARARGS, doc_splint},
14
{"_sproot", fitpack_sproot, METH_VARARGS, doc_sproot},
15
{"_spalde", fitpack_spalde, METH_VARARGS, doc_spalde},
16
{"_parcur", fitpack_parcur, METH_VARARGS, doc_parcur},
17
{"_surfit", fitpack_surfit, METH_VARARGS, doc_surfit},
18
{"_bispev", fitpack_bispev, METH_VARARGS, doc_bispev},
20
/* link libraries: (one item per line)
23
/* python files: (to be imported to Multipack.py)
26
#if defined(NO_APPEND_FORTRAN)
40
#define CURFIT curfit_
41
#define PERCUR percur_
42
#define SPALDE spalde_
43
#define SPLDER splder_
45
#define SPLINT splint_
46
#define SPROOT sproot_
47
#define PARCUR parcur_
48
#define CLOCUR clocur_
49
#define SURFIT surfit_
50
#define BISPEV bispev_
51
#define PARDER parder_
53
void CURFIT(int*,int*,double*,double*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*);
54
void PERCUR(int*,int*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*);
55
void SPALDE(double*,int*,double*,int*,double*,double*,int*);
56
void SPLDER(double*,int*,double*,int*,int*,double*,double*,int*,double*,int*);
57
void SPLEV(double*,int*,double*,int*,double*,double*,int*,int*);
58
double SPLINT(double*,int*,double*,int*,double*,double*,double*);
59
void SPROOT(double*,int*,double*,double*,int*,int*,int*);
60
void PARCUR(int*,int*,int*,int*,double*,int*,double*,double*,double*,double*,int*,double*,int*,int*,double*,int*,double*,double*,double*,int*,int*,int*);
61
void CLOCUR(int*,int*,int*,int*,double*,int*,double*,double*,int*,double*,int*,int*,double*,int*,double*,double*,double*,int*,int*,int*);
62
void SURFIT(int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*,double*,int*,int*,int*,double*,int*,double*,int*,double*,double*,double*,double*,int*,double*,int*,int*,int*,int*);
63
void BISPEV(double*,int*,double*,int*,double*,int*,int*,double*,int*,double*,int*,double*,double*,int*,int*,int*,int*);
64
void PARDER(double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,int*,double*,int*,double*,double*,int*,int*,int*,int*);
66
/* Note that curev, cualde need no interface. */
68
static char doc_bispev[] = " [z,ier] = _bispev(tx,ty,c,kx,ky,x,y,nux,nuy)";
69
static PyObject *fitpack_bispev(PyObject *dummy, PyObject *args) {
70
int nx,ny,kx,ky,mx,my,lwrk,*iwrk,kwrk,ier,lwa,mxy,nux,nuy;
71
double *tx,*ty,*c,*x,*y,*z,*wrk,*wa = NULL;
72
PyArrayObject *ap_x = NULL,*ap_y = NULL,*ap_z = NULL,*ap_tx = NULL,\
73
*ap_ty = NULL,*ap_c = NULL;
74
PyObject *x_py = NULL,*y_py = NULL,*c_py = NULL,*tx_py = NULL,*ty_py = NULL;
75
if (!PyArg_ParseTuple(args, "OOOiiOOii",&tx_py,&ty_py,&c_py,&kx,&ky,
76
&x_py,&y_py,&nux,&nuy))
78
ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
79
ap_y = (PyArrayObject *)PyArray_ContiguousFromObject(y_py, PyArray_DOUBLE, 0, 1);
80
ap_c = (PyArrayObject *)PyArray_ContiguousFromObject(c_py, PyArray_DOUBLE, 0, 1);
81
ap_tx = (PyArrayObject *)PyArray_ContiguousFromObject(tx_py, PyArray_DOUBLE, 0, 1);
82
ap_ty = (PyArrayObject *)PyArray_ContiguousFromObject(ty_py, PyArray_DOUBLE, 0, 1);
83
if (ap_x == NULL || ap_y == NULL || ap_c == NULL || ap_tx == NULL \
84
|| ap_ty == NULL) goto fail;
85
x = (double *) ap_x->data;
86
y = (double *) ap_y->data;
87
c = (double *) ap_c->data;
88
tx = (double *) ap_tx->data;
89
ty = (double *) ap_ty->data;
90
nx = ap_tx->dimensions[0];
91
ny = ap_ty->dimensions[0];
92
mx = ap_x->dimensions[0];
93
my = ap_y->dimensions[0];
95
ap_z = (PyArrayObject *)PyArray_FromDims(1,&mxy,PyArray_DOUBLE);
96
z = (double *) ap_z->data;
98
lwrk = mx*(kx+1-nux)+my*(ky+1-nuy)+(nx-kx-1)*(ny-ky-1);
100
lwrk = mx*(kx+1)+my*(ky+1);
103
if ((wa = (double *)malloc(lwa*sizeof(double)))==NULL) {
108
iwrk = (int *)(wrk+lwrk);
110
PARDER(tx,&nx,ty,&ny,c,&kx,&ky,&nux,&nuy,x,&mx,y,&my,z,wrk,&lwrk,iwrk,&kwrk,&ier);
112
BISPEV(tx,&nx,ty,&ny,c,&kx,&ky,x,&mx,y,&my,z,wrk,&lwrk,iwrk,&kwrk,&ier);
120
return Py_BuildValue("Ni",PyArray_Return(ap_z),ier);
132
static char doc_surfit[] = " [tx,ty,c,o] = _surfit(x,y,z,w,xb,xe,yb,ye,kx,ky,iopt,s,eps,tx,ty,nxest,nyest,wrk,lwrk1,lwrk2)";
133
static PyObject *fitpack_surfit(PyObject *dummy, PyObject *args) {
134
int iopt,m,kx,ky,nxest,nyest,nx,ny,lwrk1,lwrk2,*iwrk,kwrk,ier,lwa,nxo,nyo,\
136
double *x,*y,*z,*w,xb,xe,yb,ye,s,*tx,*ty,*c,fp,*wrk1,*wrk2,*wa = NULL,eps;
137
PyArrayObject *ap_x = NULL,*ap_y = NULL,*ap_z,*ap_w = NULL,\
138
*ap_tx = NULL,*ap_ty = NULL,*ap_c = NULL;
139
PyArrayObject *ap_wrk = NULL;
140
PyObject *x_py = NULL,*y_py = NULL,*z_py = NULL,*w_py = NULL,\
141
*tx_py = NULL,*ty_py = NULL;
142
PyObject *wrk_py=NULL;
144
if (!PyArg_ParseTuple(args, "OOOOddddiiiddOOiiOii",\
145
&x_py,&y_py,&z_py,&w_py,&xb,&xe,\
146
&yb,&ye,&kx,&ky,&iopt,&s,&eps,&tx_py,&ty_py,&nxest,&nyest,\
147
&wrk_py,&lwrk1,&lwrk2)) return NULL;
148
ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
149
ap_y = (PyArrayObject *)PyArray_ContiguousFromObject(y_py, PyArray_DOUBLE, 0, 1);
150
ap_z = (PyArrayObject *)PyArray_ContiguousFromObject(z_py, PyArray_DOUBLE, 0, 1);
151
ap_w = (PyArrayObject *)PyArray_ContiguousFromObject(w_py, PyArray_DOUBLE, 0, 1);
152
ap_wrk=(PyArrayObject *)PyArray_ContiguousFromObject(wrk_py, PyArray_DOUBLE, 0, 1);
153
/*ap_iwrk=(PyArrayObject *)PyArray_ContiguousFromObject(iwrk_py, PyArray_INT, 0, 1);*/
154
if (ap_x == NULL || ap_y == NULL || ap_z == NULL || ap_w == NULL \
155
|| ap_wrk == NULL) goto fail;
156
x = (double *) ap_x->data;
157
y = (double *) ap_y->data;
158
z = (double *) ap_z->data;
159
w = (double *) ap_w->data;
160
m = ap_x->dimensions[0];
162
if (nmax<nyest) nmax=nyest;
163
lcest=(nxest-kx-1)*(nyest-ky-1);
164
kwrk=m+(nxest-2*kx-1)*(nyest-2*ky-1);
165
lwa = 2*nmax+lcest+lwrk1+lwrk2+kwrk;
166
if ((wa = (double *)malloc(lwa*sizeof(double)))==NULL) {
174
iwrk = (int *)(wrk1 + lwrk1);
175
wrk2 = (double *)(iwrk+kwrk);
177
ap_tx=(PyArrayObject *)PyArray_ContiguousFromObject(tx_py, PyArray_DOUBLE, 0, 1);
178
ap_ty=(PyArrayObject *)PyArray_ContiguousFromObject(ty_py, PyArray_DOUBLE, 0, 1);
179
if (ap_tx == NULL || ap_ty == NULL) goto fail;
180
nx = nxo = ap_tx->dimensions[0];
181
ny = nyo = ap_ty->dimensions[0];
182
memcpy(tx,ap_tx->data,nx*sizeof(double));
183
memcpy(ty,ap_ty->data,ny*sizeof(double));
186
lc = (nx-kx-1)*(ny-ky-1);
187
memcpy(wrk1,ap_wrk->data,lc*sizeof(double));
188
/*memcpy(iwrk,ap_iwrk->data,n*sizeof(int));*/
190
SURFIT(&iopt,&m,x,y,z,w,&xb,&xe,&yb,&ye,&kx,&ky,&s,&nxest,&nyest,&nmax,&eps,&nx,tx,&ny,ty,c,&fp,wrk1,&lwrk1,wrk2,&lwrk2,iwrk,&kwrk,&ier);
192
while ((ier>10) && (i++<5)) {
194
if ((wrk2 = (double *)malloc(lwrk2*sizeof(double)))==NULL) {
198
SURFIT(&iopt,&m,x,y,z,w,&xb,&xe,&yb,&ye,&kx,&ky,&s,&nxest,&nyest,&nmax,&eps,&nx,tx,&ny,ty,c,&fp,wrk1,&lwrk1,wrk2,&lwrk2,iwrk,&kwrk,&ier);
199
if (wrk2) free(wrk2);
202
PyErr_SetString(PyExc_ValueError, "Invalid inputs.");
205
lc = (nx-kx-1)*(ny-ky-1);
208
ap_tx = (PyArrayObject *)PyArray_FromDims(1,&nx,PyArray_DOUBLE);
209
ap_ty = (PyArrayObject *)PyArray_FromDims(1,&ny,PyArray_DOUBLE);
210
ap_c = (PyArrayObject *)PyArray_FromDims(1,&lc,PyArray_DOUBLE);
211
if (ap_tx == NULL || ap_ty == NULL || ap_c == NULL) goto fail;
212
if ((iopt==0)||(nx>nxo)||(ny>nyo)) {
213
ap_wrk = (PyArrayObject *)PyArray_FromDims(1,&lc,PyArray_DOUBLE);
214
if (ap_wrk == NULL) goto fail;
215
/*ap_iwrk = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_INT);*/
217
memcpy(ap_tx->data,tx,nx*sizeof(double));
218
memcpy(ap_ty->data,ty,ny*sizeof(double));
219
memcpy(ap_c->data,c,lc*sizeof(double));
220
memcpy(ap_wrk->data,wrk1,lc*sizeof(double));
221
/*memcpy(ap_iwrk->data,iwrk,n*sizeof(int));*/
227
return Py_BuildValue("NNN{s:N,s:i,s:d}",PyArray_Return(ap_tx),\
228
PyArray_Return(ap_ty),PyArray_Return(ap_c),\
229
"wrk",PyArray_Return(ap_wrk),\
240
/*Py_XDECREF(ap_iwrk);*/
241
if (!PyErr_Occurred()) {
242
PyErr_SetString(PyExc_ValueError, "An error occurred.");
248
static char doc_parcur[] = " [t,c,o] = _parcur(x,w,u,ub,ue,k,iopt,ipar,s,t,nest,wrk,iwrk,per)";
249
static PyObject *fitpack_parcur(PyObject *dummy, PyObject *args) {
250
int k,iopt,ipar,nest,*iwrk,idim,m,mx,n=0,no=0,nc,ier,lc,lwa,lwrk,i,per;
251
double *x,*w,*u,*c,*t,*wrk,*wa=NULL,ub,ue,fp,s;
252
PyObject *x_py = NULL,*u_py = NULL,*w_py = NULL,*t_py = NULL;
253
PyObject *wrk_py=NULL,*iwrk_py=NULL;
254
PyArrayObject *ap_x = NULL,*ap_u = NULL,*ap_w = NULL,*ap_t = NULL,*ap_c = NULL;
255
PyArrayObject *ap_wrk = NULL,*ap_iwrk = NULL;
256
if (!PyArg_ParseTuple(args, "OOOddiiidOiOOi",&x_py,&w_py,&u_py,&ub,&ue,\
257
&k,&iopt,&ipar,&s,&t_py,&nest,&wrk_py,&iwrk_py,&per)) return NULL;
258
ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
259
ap_u = (PyArrayObject *)PyArray_ContiguousFromObject(u_py, PyArray_DOUBLE, 0, 1);
260
ap_w = (PyArrayObject *)PyArray_ContiguousFromObject(w_py, PyArray_DOUBLE, 0, 1);
261
ap_wrk=(PyArrayObject *)PyArray_ContiguousFromObject(wrk_py, PyArray_DOUBLE, 0, 1);
262
ap_iwrk=(PyArrayObject *)PyArray_ContiguousFromObject(iwrk_py, PyArray_INT, 0, 1);
263
if (ap_x == NULL || ap_u == NULL || ap_w == NULL || ap_wrk == NULL || ap_iwrk == NULL) goto fail;
264
x = (double *) ap_x->data;
265
u = (double *) ap_u->data;
266
w = (double *) ap_w->data;
267
m = ap_w->dimensions[0];
268
mx = ap_x->dimensions[0];
271
lwrk=m*(k+1)+nest*(7+idim+5*k);
273
lwrk=m*(k+1)+nest*(6+idim+3*k);
275
lwa = nc+2*nest+lwrk;
276
if ((wa = (double *)malloc(lwa*sizeof(double)))==NULL) {
283
iwrk = (int *)(wrk + lwrk);
285
ap_t=(PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
286
if (ap_t == NULL) goto fail;
287
n = no = ap_t->dimensions[0];
288
memcpy(t,ap_t->data,n*sizeof(double));
291
memcpy(wrk,ap_wrk->data,n*sizeof(double));
292
memcpy(iwrk,ap_iwrk->data,n*sizeof(int));
295
CLOCUR(&iopt,&ipar,&idim,&m,u,&mx,x,w,&k,&s,&nest,&n,t,&nc,\
296
c,&fp,wrk,&lwrk,iwrk,&ier);
298
PARCUR(&iopt,&ipar,&idim,&m,u,&mx,x,w,&ub,&ue,&k,&s,&nest,&n,t,&nc,\
299
c,&fp,wrk,&lwrk,iwrk,&ier);
300
if (ier==10) goto fail;
301
if (ier>0 && n==0) n=1;
303
ap_t = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_DOUBLE);
304
ap_c = (PyArrayObject *)PyArray_FromDims(1,&lc,PyArray_DOUBLE);
305
if (ap_t == NULL || ap_c == NULL) goto fail;
306
if ((iopt==0)||(n>no)) {
307
ap_wrk = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_DOUBLE);
308
ap_iwrk = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_INT);
309
if (ap_wrk == NULL || ap_iwrk == NULL) goto fail;
311
memcpy(ap_t->data,t,n*sizeof(double));
313
memcpy((double *) ap_c->data+i*(n-k-1),c+i*n,(n-k-1)*sizeof(double));
314
memcpy(ap_wrk->data,wrk,n*sizeof(double));
315
memcpy(ap_iwrk->data,iwrk,n*sizeof(int));
319
return Py_BuildValue("NN{s:N,s:d,s:d,s:N,s:N,s:i,s:d}",PyArray_Return(ap_t),PyArray_Return(ap_c),"u",PyArray_Return(ap_u),"ub",ub,"ue",ue,"wrk",PyArray_Return(ap_wrk),"iwrk",PyArray_Return(ap_iwrk),"ier",ier,"fp",fp);
331
static char doc_curfit[] = " [t,c,o] = _curfit(x,y,w,xb,xe,k,iopt,s,t,nest,wrk,iwrk,per)";
332
static PyObject *fitpack_curfit(PyObject *dummy, PyObject *args) {
333
int iopt,m,k,nest,n,lwrk,*iwrk,ier,lwa,lc,no=0,per;
334
double *x,*y,*w,xb,xe,s,*t,*c,fp,*wrk,*wa = NULL;
335
PyArrayObject *ap_x = NULL,*ap_y = NULL,*ap_w = NULL,*ap_t = NULL,*ap_c = NULL;
336
PyArrayObject *ap_wrk = NULL,*ap_iwrk = NULL;
337
PyObject *x_py = NULL,*y_py = NULL,*w_py = NULL,*t_py = NULL;
338
PyObject *wrk_py=NULL,*iwrk_py=NULL;
339
if (!PyArg_ParseTuple(args, "OOOddiidOiOOi",&x_py,&y_py,&w_py,&xb,&xe,\
340
&k,&iopt,&s,&t_py,&nest,&wrk_py,&iwrk_py,&per)) return NULL;
341
ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
342
ap_y = (PyArrayObject *)PyArray_ContiguousFromObject(y_py, PyArray_DOUBLE, 0, 1);
343
ap_w = (PyArrayObject *)PyArray_ContiguousFromObject(w_py, PyArray_DOUBLE, 0, 1);
344
ap_wrk=(PyArrayObject *)PyArray_ContiguousFromObject(wrk_py, PyArray_DOUBLE, 0, 1);
345
ap_iwrk=(PyArrayObject *)PyArray_ContiguousFromObject(iwrk_py, PyArray_INT, 0, 1);
346
if (ap_x == NULL || ap_y == NULL || ap_w == NULL || ap_wrk == NULL || ap_iwrk == NULL) goto fail;
347
x = (double *) ap_x->data;
348
y = (double *) ap_y->data;
349
w = (double *) ap_w->data;
350
m = ap_x->dimensions[0];
351
if (per) lwrk = m*(k+1) + nest*(8+5*k);
352
else lwrk = m*(k+1) + nest*(7+3*k);
354
if ((wa = (double *)malloc(lwa*sizeof(double)))==NULL) {
361
iwrk = (int *)(wrk + lwrk);
363
ap_t=(PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
364
if (ap_t == NULL) goto fail;
365
n = no = ap_t->dimensions[0];
366
memcpy(t,ap_t->data,n*sizeof(double));
369
memcpy(wrk,ap_wrk->data,n*sizeof(double));
370
memcpy(iwrk,ap_iwrk->data,n*sizeof(int));
373
PERCUR(&iopt,&m,x,y,w,&k,&s,&nest,&n,t,c,&fp,wrk,&lwrk,iwrk,&ier);
375
CURFIT(&iopt,&m,x,y,w,&xb,&xe,&k,&s,&nest,&n,t,c,&fp,wrk,&lwrk,iwrk,&ier);
377
PyErr_SetString(PyExc_ValueError, "Invalid inputs.");
382
ap_t = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_DOUBLE);
383
if (ap_t == NULL) goto fail;
385
ap_c = (PyArrayObject *)PyArray_FromDims(1,&lc,PyArray_DOUBLE);
386
if (ap_c == NULL) goto fail;
387
if ((iopt==0)||(n>no)) {
390
ap_wrk = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_DOUBLE);
391
ap_iwrk = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_INT);
392
if (ap_wrk == NULL || ap_iwrk == NULL) goto fail;
394
memcpy(ap_t->data,t,n*sizeof(double));
395
memcpy(ap_c->data,c,lc*sizeof(double));
396
memcpy(ap_wrk->data,wrk,n*sizeof(double));
397
memcpy(ap_iwrk->data,iwrk,n*sizeof(int));
402
return Py_BuildValue("NN{s:N,s:N,s:i,s:d}",PyArray_Return(ap_t),PyArray_Return(ap_c),"wrk",PyArray_Return(ap_wrk),"iwrk",PyArray_Return(ap_iwrk),"ier",ier,"fp",fp);
414
static char doc_spl_[] = " [y,ier] = _spl_(x,nu,t,c,k )";
415
static PyObject *fitpack_spl_(PyObject *dummy, PyObject *args) {
417
double *x,*y,*t,*c,*wrk = NULL;
418
PyArrayObject *ap_x = NULL,*ap_y = NULL,*ap_t = NULL,*ap_c = NULL;
419
PyObject *x_py = NULL,*t_py = NULL,*c_py = NULL;
420
if (!PyArg_ParseTuple(args, "OiOOi",&x_py,&nu,&t_py,&c_py,&k)) return NULL;
421
ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
422
ap_t = (PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
423
ap_c = (PyArrayObject *)PyArray_ContiguousFromObject(c_py, PyArray_DOUBLE, 0, 1);
424
if ((ap_x == NULL || ap_t == NULL || ap_c == NULL)) goto fail;
425
x = (double *) ap_x->data;
426
m = ap_x->dimensions[0];
427
t = (double *) ap_t->data;
428
c = (double *) ap_c->data;
429
n = ap_t->dimensions[0];
430
ap_y = (PyArrayObject *)PyArray_FromDims(1,&m,PyArray_DOUBLE);
431
if (ap_y == NULL) goto fail;
432
y = (double *) ap_y->data;
433
if ((wrk = (double *)malloc(n*sizeof(double)))==NULL) {
438
SPLDER(t,&n,c,&k,&nu,x,y,&m,wrk,&ier);
440
SPLEV(t,&n,c,&k,x,y,&m,&ier);
445
return Py_BuildValue("Ni",PyArray_Return(ap_y),ier);
454
static char doc_splint[] = " [aint,wrk] = _splint(t,c,k,a,b)";
455
static PyObject *fitpack_splint(PyObject *dummy, PyObject *args) {
457
double *t,*c,*wrk = NULL,a,b,aint;
458
PyArrayObject *ap_t = NULL,*ap_c = NULL;
459
PyArrayObject *ap_wrk = NULL;
460
PyObject *t_py = NULL,*c_py = NULL;
461
if (!PyArg_ParseTuple(args, "OOidd",&t_py,&c_py,&k,&a,&b)) return NULL;
462
ap_t = (PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
463
ap_c = (PyArrayObject *)PyArray_ContiguousFromObject(c_py, PyArray_DOUBLE, 0, 1);
464
if ((ap_t == NULL || ap_c == NULL)) goto fail;
465
t = (double *) ap_t->data;
466
c = (double *) ap_c->data;
467
n = ap_t->dimensions[0];
468
ap_wrk = (PyArrayObject *)PyArray_FromDims(1,&n,PyArray_DOUBLE);
469
if (ap_wrk == NULL) goto fail;
470
wrk = (double *) ap_wrk->data;
471
aint = SPLINT(t,&n,c,&k,&a,&b,wrk);
474
return Py_BuildValue("dN",aint,PyArray_Return(ap_wrk));
481
static char doc_sproot[] = " [z,ier] = _sproot(t,c,k,mest)";
482
static PyObject *fitpack_sproot(PyObject *dummy, PyObject *args) {
484
double *t,*c,*z=NULL;
485
PyArrayObject *ap_t = NULL,*ap_c = NULL;
486
PyArrayObject *ap_z = NULL;
487
PyObject *t_py = NULL,*c_py = NULL;
488
if (!PyArg_ParseTuple(args, "OOii",&t_py,&c_py,&k,&mest)) return NULL;
489
ap_t = (PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
490
ap_c = (PyArrayObject *)PyArray_ContiguousFromObject(c_py, PyArray_DOUBLE, 0, 1);
491
if ((ap_t == NULL || ap_c == NULL)) goto fail;
492
t = (double *) ap_t->data;
493
c = (double *) ap_c->data;
494
n = ap_t->dimensions[0];
495
if ((z = (double *)malloc(mest*sizeof(double)))==NULL) {
499
SPROOT(t,&n,c,z,&mest,&m,&ier);
501
ap_z = (PyArrayObject *)PyArray_FromDims(1,&m,PyArray_DOUBLE);
502
if (ap_z == NULL) goto fail;
503
memcpy(ap_z->data,z,m*sizeof(double));
507
return Py_BuildValue("Ni",PyArray_Return(ap_z),ier);
515
static char doc_spalde[] = " [d,ier] = _spalde(t,c,k,x)";
516
static PyObject *fitpack_spalde(PyObject *dummy, PyObject *args) {
518
double *t,*c,*d=NULL,x;
519
PyArrayObject *ap_t = NULL,*ap_c = NULL,*ap_d = NULL;
520
PyObject *t_py = NULL,*c_py = NULL;
521
if (!PyArg_ParseTuple(args, "OOid",&t_py,&c_py,&k,&x)) return NULL;
522
ap_t = (PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
523
ap_c = (PyArrayObject *)PyArray_ContiguousFromObject(c_py, PyArray_DOUBLE, 0, 1);
524
if ((ap_t == NULL || ap_c == NULL)) goto fail;
525
t = (double *) ap_t->data;
526
c = (double *) ap_c->data;
527
n = ap_t->dimensions[0];
529
ap_d = (PyArrayObject *)PyArray_FromDims(1,&k1,PyArray_DOUBLE);
530
if (ap_d == NULL) goto fail;
531
d = (double *) ap_d->data;
532
SPALDE(t,&n,c,&k1,&x,d,&ier);
535
return Py_BuildValue("Ni",PyArray_Return(ap_d),ier);