| 2193 | } |
| 2194 | |
| 2195 | static PyObject * |
| 2196 | execute_complex(PyObject *a1, int is_forward, double fct) |
| 2197 | { |
| 2198 | PyArrayObject *data = (PyArrayObject *)PyArray_FromAny(a1, |
| 2199 | PyArray_DescrFromType(NPY_CDOUBLE), 1, 0, |
| 2200 | NPY_ARRAY_ENSURECOPY | NPY_ARRAY_DEFAULT | |
| 2201 | NPY_ARRAY_ENSUREARRAY | NPY_ARRAY_FORCECAST, |
| 2202 | NULL); |
| 2203 | if (!data) return NULL; |
| 2204 | |
| 2205 | int npts = PyArray_DIM(data, PyArray_NDIM(data) - 1); |
| 2206 | cfft_plan plan=NULL; |
| 2207 | |
| 2208 | int nrepeats = PyArray_SIZE(data)/npts; |
| 2209 | double *dptr = (double *)PyArray_DATA(data); |
| 2210 | int fail=0; |
| 2211 | Py_BEGIN_ALLOW_THREADS; |
| 2212 | plan = make_cfft_plan(npts); |
| 2213 | if (!plan) fail=1; |
| 2214 | if (!fail) |
| 2215 | for (int i = 0; i < nrepeats; i++) { |
| 2216 | int res = is_forward ? |
| 2217 | cfft_forward(plan, dptr, fct) : cfft_backward(plan, dptr, fct); |
| 2218 | if (res!=0) { fail=1; break; } |
| 2219 | dptr += npts*2; |
| 2220 | } |
| 2221 | if (plan) destroy_cfft_plan(plan); |
| 2222 | Py_END_ALLOW_THREADS; |
| 2223 | if (fail) { |
| 2224 | Py_XDECREF(data); |
| 2225 | return PyErr_NoMemory(); |
| 2226 | } |
| 2227 | return (PyObject *)data; |
| 2228 | } |
| 2229 | |
| 2230 | static PyObject * |
| 2231 | execute_real_forward(PyObject *a1, double fct) |
no test coverage detected