MCPcopy Create free account
hub / github.com/numpy/numpy / execute_complex

Function execute_complex

numpy/fft/_pocketfft.c:2195–2228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2193 }
2194
2195static PyObject *
2196execute_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
2230static PyObject *
2231execute_real_forward(PyObject *a1, double fct)

Callers 1

executeFunction · 0.85

Calls 8

PyArray_FromAnyFunction · 0.85
PyArray_DIMFunction · 0.85
PyArray_NDIMFunction · 0.85
PyArray_DATAFunction · 0.85
make_cfft_planFunction · 0.85
cfft_forwardFunction · 0.85
cfft_backwardFunction · 0.85
destroy_cfft_planFunction · 0.85

Tested by

no test coverage detected