PDA

View Full Version : fftw help


sunderam
10-26-2005, 12:15 AM
hi,
I am using fftw for doing some stuff. i m trying to do the following bu
get 0 as output .can someone please tell me where am i going wrong.

///////////////////////CODE BEGIN
HERE/////////////////////////////////////
#include <stdlib.h>
#include<math.h>
#include <fftw3.h>
int main()
{
int N = 256;
fftw_complex *out;
double **in;
fftw_plan p;


in = malloc(N*sizeof(double*));/*input*/
out = fftw_malloc(sizeof(double)*(N)); /*output complex type*/
p = fftw_plan_dft_r2c_1d(N,in,out,FFTW_ESTIMATE);
int i;


for (i = 0; i < (N); i++) {
in[i] = malloc(N*sizeof(double));
in[i][0] = sin(i / 10.0 * M_PI); /* Real part */
in[i][1] = 0.0; /* Imaginary part */
}


fftw_execute(p); /* repeat as needed */


for (i = 0; i < N/2+1; i++)
printf("H0 %d: %f\n", i, out[i][0]);


fftw_free(in);
fftw_free(out);
fftw_destroy_plan(p);

}

////////////////////END////////////////////////////////////


thanks in advance
sunderam