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

Function execute_real_backward

numpy/fft/_pocketfft.c:2283–2324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2281 return (PyObject *)ret;
2282}
2283static PyObject *
2284execute_real_backward(PyObject *a1, double fct)
2285{
2286 rfft_plan plan=NULL;
2287 PyArrayObject *data = (PyArrayObject *)PyArray_FromAny(a1,
2288 PyArray_DescrFromType(NPY_CDOUBLE), 1, 0,
2289 NPY_ARRAY_DEFAULT | NPY_ARRAY_ENSUREARRAY | NPY_ARRAY_FORCECAST,
2290 NULL);
2291 if (!data) return NULL;
2292 int npts = PyArray_DIM(data, PyArray_NDIM(data) - 1);
2293 PyArrayObject *ret = (PyArrayObject *)PyArray_Empty(PyArray_NDIM(data),
2294 PyArray_DIMS(data), PyArray_DescrFromType(NPY_DOUBLE), 0);
2295 int fail = 0;
2296 if (!ret) fail=1;
2297 if (!fail) {
2298 int nrepeats = PyArray_SIZE(ret)/npts;
2299 double *rptr = (double *)PyArray_DATA(ret),
2300 *dptr = (double *)PyArray_DATA(data);
2301
2302 Py_BEGIN_ALLOW_THREADS;
2303 plan = make_rfft_plan(npts);
2304 if (!plan) fail=1;
2305 if (!fail) {
2306 for (int i = 0; i < nrepeats; i++) {
2307 memcpy((char *)(rptr + 1), (dptr + 2), (npts - 1)*sizeof(double));
2308 rptr[0] = dptr[0];
2309 if (rfft_backward(plan, rptr, fct)!=0) {fail=1; break;}
2310 rptr += npts;
2311 dptr += npts*2;
2312 }
2313 }
2314 if (plan) destroy_rfft_plan(plan);
2315 Py_END_ALLOW_THREADS;
2316 }
2317 if (fail) {
2318 Py_XDECREF(data);
2319 Py_XDECREF(ret);
2320 return PyErr_NoMemory();
2321 }
2322 Py_DECREF(data);
2323 return (PyObject *)ret;
2324}
2325
2326static PyObject *
2327execute_real(PyObject *a1, int is_forward, double fct)

Callers 1

execute_realFunction · 0.85

Calls 9

PyArray_FromAnyFunction · 0.85
PyArray_DIMFunction · 0.85
PyArray_NDIMFunction · 0.85
PyArray_EmptyFunction · 0.85
PyArray_DIMSFunction · 0.85
PyArray_DATAFunction · 0.85
make_rfft_planFunction · 0.85
rfft_backwardFunction · 0.85
destroy_rfft_planFunction · 0.85

Tested by

no test coverage detected