#include #include #include #include #include #include #include #include #include #define IND(a,i) *((double *)(a->data+i*a->strides[0])) #define IND_int(a,i) *((int *)(a->data+i*a->strides[0])) #define IND2(a,i,j) *((double *)(a->data+i*a->strides[0]+j*a->strides[1])) #define IND2_int(a,i,j) *((int *)(a->data+i*a->strides[0]+j*a->strides[1])) static PyObject *mapper(PyObject *self, PyObject *args) { //store the string that is the function char * func_string; PyObject *array_tuple, *sec; void *f,*g; char **names; int count,i,j; PyArrayObject *tmp,*output; npy_intp dims[1]; if(!PyArg_ParseTuple(args,"Os",&array_tuple,&func_string)) { return NULL; } f = evaluator_create(func_string); assert (f); evaluator_get_variables(f,&names,&count); double vals[count], res; sec = PySequence_Fast(array_tuple,"expected list or tuple"); dims[0] = ((PyArrayObject *)PySequence_Fast_GET_ITEM(sec,0))->dimensions[0]; //setup the output array output = (PyArrayObject *) PyArray_SimpleNew(1,dims,PyArray_DOUBLE); PyArrayObject * cot[count]; for(i = 0;i