I am trying to get a complex to complex fourier transform using fftw..
I first allocate space for 16 complex numbers. I initialise them to random numbers and then i perfrom the transform...
I am aware of the fact that in a complex to real mapping, the size of the output array is half the size of hte input array..
take a look at the output i have pasted here. i am getting all elements whose index is greater than (input array size)/2 to be zeros...
is this a valid output or have i done anything wrong..
Also, I have never used a complex array before, have i dealt with the initialisation correctly?
Code:
# include<complex.h>
# include<fftw3.h>
# include<time.h>
# include<math.h>
# define m 16
int main(int argc ,char *argv[])
{
int rc,i,j,sender,tag,number=0;
fftw_complex *in;
fftw_complex *out,*indexin,*indexout;
int count=0,sta,end,myid,nprocs;
double time1,time2;
fftw_plan p;
in=(complex *)(fftw_malloc(sizeof(complex)*m));
out=(complex *)(fftw_malloc(sizeof(complex)*m));
indexin=in;
indexout=out;
for(i=0;i<m;i++)
{
*in=rand();
printf("%d\t%f + i" ,i,*in++);
*in=rand();
printf(" %f\n",*in++);
}
in=indexin;
p=fftw_plan_dft_1d(m,in,out,FFTW_FORWARD,FFTW_ESTIMATE);
printf("\noutput array \n");
fftw_execute(p);
// out=indexout;
for(j=0;j<m;j++)
{
printf("%d\t%f +i ",j,*out++);
printf("%f\n",*out++);
}
printf("time consumed =%f\n",time2-time1);
fftw_destroy_plan(p);
fftw_free(indexin);
fftw_free(indexout);
return 0;
}
this is the output i am getting :
output:
Code:
0 1804289383.000000 + i 846930886.000000
1 1681692777.000000 + i 1714636915.000000
2 1957747793.000000 + i 424238335.000000
3 719885386.000000 + i 1649760492.000000
4 596516649.000000 + i 1189641421.000000
5 1025202362.000000 + i 1350490027.000000
6 783368690.000000 + i 1102520059.000000
7 2044897763.000000 + i 1967513926.000000
8 1365180540.000000 + i 1540383426.000000
9 304089172.000000 + i 1303455736.000000
10 35005211.000000 + i 521595368.000000
11 294702567.000000 + i 1726956429.000000
12 336465782.000000 + i 861021530.000000
13 278722862.000000 + i 233665123.000000
14 2145174067.000000 + i 468703135.000000
15 1101513929.000000 + i 1801979802.000000
output array
0 20859332864.000000 +i 2984769599.594296
1 410609648.520185 +i -1165990454.966789
2 -329755773.000000 +i 779267800.640235
3 -1091230550.520185 +i 2233043990.732258
4 367868742.000000 +i 2233043990.732258
5 -1091230550.520185 +i 779267800.640235
6 -329755773.000000 +i -1165990454.966789
7 410609648.520185 +i 2984769599.594296
8 0.000000 +i 0.000000
9 0.000000 +i 0.000000
10 0.000000 +i 0.000000
11 0.000000 +i 0.000000
12 0.000000 +i 0.000000
13 0.000000 +i 0.000000
14 0.000000 +i 0.000000
15 0.000000 +i 0.000000