28 #if defined(HAVE_FFTW3_H) || defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H)
30 #if defined(HAVE_FFTW3_H)
32 #define c_re(c) ((c)[0])
33 #define c_im(c) ((c)[1])
34 #elif defined(HAVE_FFTW_H)
36 #elif defined(HAVE_DFFTW_H)
65 int fft2(
int i_sign,
double (*data)[2],
int NN,
int dimc,
int dimr)
75 norm = 1.0 / sqrt(NN);
78 plan = fftw_plan_dft_2d(dimr, dimc, data, data,
79 (i_sign < 0) ? FFTW_FORWARD : FFTW_BACKWARD,
84 fftw_destroy_plan(plan);
86 plan = fftw2d_create_plan(dimc, dimr,
87 (i_sign < 0) ? FFTW_FORWARD : FFTW_BACKWARD,
88 FFTW_ESTIMATE | FFTW_IN_PLACE);
90 fftwnd_one(plan, data, data);
92 fftwnd_destroy_plan(plan);
95 for (i = 0; i < NN; i++) {
122 int fft(
int i_sign,
double *DATA[2],
int NN,
int dimc,
int dimr)
127 data = (fftw_complex *)
G_malloc(NN *
sizeof(fftw_complex));
129 for (i = 0; i < NN; i++) {
130 c_re(data[i]) = DATA[0][i];
131 c_im(data[i]) = DATA[1][i];
134 fft2(i_sign, data, NN, dimc, dimr);
136 for (i = 0; i < NN; i++) {
137 DATA[0][i] =
c_re(data[i]);
138 DATA[1][i] =
c_im(data[i]);
void G_free(void *)
Free allocated memory.
int fft(int i_sign, double *DATA[2], int NN, int dimc, int dimr)
Fast Fourier Transform for two-dimensional array.
int fft2(int i_sign, double(*data)[2], int NN, int dimc, int dimr)
Fast Fourier Transform for two-dimensional array.