MCPcopy Create free account
hub / github.com/SimVascular/SimVascular / Math_inverse_fft

Function Math_inverse_fft

Code/Source/PythonAPI/Math_PyModule.cxx:189–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187");
188
189static PyObject *
190Math_inverse_fft(PyObject *self, PyObject *args)
191{
192 auto api = PyUtilApiFunction("Odddi", PyRunTimeErr, __func__);
193 PyObject *termsArg;
194 double t0 = 0;
195 double dt = 0;
196 double omega = 0;
197 int numPts = 0;
198
199 if (!PyArg_ParseTuple(args, api.format, &termsArg, &t0, &dt, &omega, &numPts)) { return api.argsError();
200 return api.argsError();
201 }
202
203 // Get an array of points from the pointsArgs list.
204 int dim = 2;
205 auto terms = GetPointsFromList(api, termsArg, dim, "terms");
206 if (terms == nullptr) {
207 return nullptr;
208 }
209 int nlistterms = PyList_Size(termsArg);
210
211 // Perform inverse fft operation.
212 //
213 auto mathObj = cvMath();
214 double **pts = NULL;
215 if (mathObj.inverseFFT(terms, nlistterms, t0, dt, omega, numPts, &pts) == SV_ERROR) {
216 mathObj.deleteArray(terms,nlistterms,dim);
217 api.error("Error calculating the inverse fft.");
218 return nullptr;
219 }
220
221 // Create result string
222 //
223 // [TODO:DaveP] This converts results to a string, not
224 // a list list the fft function above.
225 //
226 char r[2048];
227 PyObject *pylist = PyList_New(numPts);
228 for (int i = 0; i < numPts; i++) {
229 r[0] = '\0';
230 sprintf(r,"%.6le %.6le",pts[i][0],pts[i][1]);
231 PyObject *rr = PyBytes_FromString(r);
232 PyList_SET_ITEM(pylist, i, rr);
233 }
234
235 // [TODO:DaveP] this is hideous!
236 mathObj.deleteArray(terms,nlistterms,dim);
237 mathObj.deleteArray(pts,numPts,dim);
238
239 return pylist;
240}
241
242//--------------------------
243// Math_compute_womersley

Callers

nothing calls this directly

Calls 5

GetPointsFromListFunction · 0.85
argsErrorMethod · 0.80
errorMethod · 0.80
inverseFFTMethod · 0.45
deleteArrayMethod · 0.45

Tested by

no test coverage detected