26 #include <grass/config.h>
28 #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
40 #define c_re(c) ((c)[0])
41 #define c_im(c) ((c)[1])
47 #include <grass/gmath.h>
48 #include <grass/gis.h>
70 int fft2(
int i_sign,
double (*
data)[2],
int NN,
int dimc,
int dimr)
80 norm = 1.0 / sqrt(NN);
83 plan = fftw_plan_dft_2d(dimr, dimc,
data,
data,
84 (i_sign < 0) ? FFTW_FORWARD : FFTW_BACKWARD,
89 fftw_destroy_plan(plan);
91 plan = fftw2d_create_plan(dimc, dimr,
92 (i_sign < 0) ? FFTW_FORWARD : FFTW_BACKWARD,
93 FFTW_ESTIMATE | FFTW_IN_PLACE);
97 fftwnd_destroy_plan(plan);
100 for (i = 0; i < NN; i++) {
127 int fft(
int i_sign,
double *
DATA[2],
int NN,
int dimc,
int dimr)
132 data = (fftw_complex *) G_malloc(NN *
sizeof(fftw_complex));
134 for (i = 0; i < NN; i++) {
135 c_re(data[i]) = DATA[0][i];
136 c_im(data[i]) = DATA[1][i];
139 fft2(i_sign, data, NN, dimc, dimr);
141 for (i = 0; i < NN; i++) {
142 DATA[0][i] = c_re(data[i]);
143 DATA[1][i] = c_im(data[i]);
void G_free(void *buf)
Free allocated memory.