Вопрос

I read, that FFTW plans take a few seconds, so it's better to call it once, and in the for loop call execute(). This is my case. But of course, in every loop, the input data are different, but the size is the same, So how can I improve it? Is it better solved with boolean variables or not?

fftw_plan my_plan;

in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*N);
v = (double*) fftw_malloc(sizeof(double)*N);
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*N);


my_plan =fftw_plan_dft_r2c_1d(N,v,out,FFTW_ESTIMATE);
fftw_execute(my_plan);


fftw_destroy_plan(my_plan);

Also, this r2c of dft is only forward?

Это было полезно?

Решение

You can either re-use the same buffers for each FFT (often you need to copy data to/from the in/out buffers and perhaps convert between integer and floating point anyway) or you can use one of the "many" FFTW plans from the advanced interface, using e.g. fftw_plan_many_dft().

For an inverse FFT you probably want a C2R plan using either of the above methods and use the FFTW_BACKWARD flag when creating the plan.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top