#include "Python.h" #include #include #include #include #define NO_IMPORT_ARRAY 1 #include "arrayobject.h" #define A_GET1(a, t, i) (*((t *) ((a)->data+((i)*(a)->strides[0])))) #define A_SET1(a, t, i, v) (A_GET1(a, t, i) = (v)) #define A_GET2(a, t, i, j) (*((t *) ((a)->data+((i)*(a)->strides[0] + \ (j)*(a)->strides[1])))) #define A_SET2(a, t, i, j, v) (A_GET2(a, t, i, j) = (v)) int Convolve1d(PyArrayObject *kernel, PyArrayObject *data, PyArrayObject *convolved) { int xc, xk; int ksizex = kernel->dimensions[0]; int halfk = ksizex / 2; int dsizex = data->dimensions[0]; /* This code is to demonstrate that API functions still work. */ if (!PyArray_Check((PyObject *) kernel) || !PyArray_Check((PyObject *) data) || !PyArray_Check((PyObject *) convolved)) { PyErr_Format(PyExc_TypeError, "Convolve1d: expected PyArrayObjects..."); return -1; } for(xc=0; xcdimensions[0], kcols = kernel->dimensions[1]; int drows = data->dimensions[0], dcols = data->dimensions[1]; int halfkrows = krows/2; int halfkcols = kcols/2; /* Copy the data in the half kernel "frame" straight through. */ for(di=0; di