// an input complex array and output complex array

fftw_complex *input, *out;

// define the size of the array 5000 X 2 *)

out = (fftw_complex*) fftw_malloc(5000*2*sizeof(fftw_complex));

input = (fftw_complex*) fftw_malloc(5000*2*sizeof(fftw_complex));

// feed data into the input array 

for(int i=0;i<5000;i++)

{

input[i][0]=dcos[i] ; // dcos[i] is an array that stored raw data of cosine part

input[i][1]=dsin[i] ; // dsin[i] is an array stored raw data of sine part

}

//declare a plan

fftw_plan p;

//define the plan, i don’t know what it is, just copy the code from FFTW manual

p= fftw_plan_dft_1d(5000,input,out,FFTW_FORWARD,FFTW_ESTIMATE);

// execute the plan, or tranform

fftw_execute(p);

// save the data into array Fdata

for(int i=0;i<5000;i++)

{

Fdata[i][0]=out[i][0];

Fdata[i][1]=out[i][1];

}

fftw_destroy_plan(p);

delete [] input;

delete [] out;

//Fourier Transform

Advertisements