for (i = 0; i < nx; i++) { for (j = 0; j < ny; j++) { a_ij = (double *)(a->data+i*a->strides[0]+j*a->strides[1]); x_i = (double *)(xcoor->data + i*xcoor->strides[0]); y_j = (double *)(ycoor->data + j*ycoor->strides[0]); /* call Python function pointed to by func1: */ arglist = Py_BuildValue("(dd)", *x_i, *y_j); result = PyEval_CallObject(func1, arglist); *a_ij = PyFloat_AS_DOUBLE(result); } } return Py_BuildValue(""); /* return None: */ }