Forums

FFTW: FFT and IFFT of real data - wrong data after IFFT

Started by Micha80 November 16, 2005
Hi,

I use the FFTW lib to do a FFT and a IFFT of real data.
So I declare

int len = 32;
out1 = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * len);
in1 = (double*) malloc(sizeof(double) * len);

I initialize the in1 field with 0,1,2,3...len-1

I do the FFT due to the documentation:

p_for =  fftw_plan_dft_r2c_1d(len, in1, out1, FFTW_FORWARD);
fftw_execute(p_for);

And now the Inverse FFT after the IFFT:

p_back =  fftw_plan_dft_c2r_1d(len, out1, in1, FFTW_BACKWARD);
fftw_execute(p_back);

The problem is, that values in in1 are all zero now. But there must be the
values 0...len-1 again.

Thanks in advance, Michael 


Micha80 wrote:
> The problem is, that values in in1 are all zero now. But there must be the > values 0...len-1 again.
FFTW FAQ, Q3.16.
Hi,

just another silly question:

You reserve memory with 

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

So, how to access each single element there?

One single Element is declared as
typedef double fftw_complex[2];

I have no idea how to read this structure out of the allocated memory.

Thanks in advance, Michael

Okay, I answer by myself:

out[i][0], out[i][1], ...