I a have a 2D double complex array of size 1001(rows)*144(columns) in C. I want to apply FFT on each of the rows and finally want the output in 4096*144 format. Here N point = 4096. Finally compare the result with matlab ouput. I am using renowned FFTW C library. I have read the tutorials but could not understand how to use properly. Which routine I should use, Like 1D routine or 2D routine and then how?
#Update
double complex reshaped_calib[1001][144]={{1.0 + 0.1 * I}};
double complex** input; //[4096][144];
// have to take dynamic array as I was getting segmentation fault here
input = malloc(4096 * sizeof(double complex*));
for (i = 0; i < 4096; i++) {
input[i] = malloc(144* sizeof(double complex));
}
// input is array I am sending to fftw to apply fft
for (i= 0; i< 1001; i++)
{
for (j= 0; j< 144; j++)
{
input[i][j]=reshaped_calib[i][j];
}
}
// Pad the extra rows
for (i= 1001; i< 4096; i++)
{
for (j= 0; j< 144; j++)
{
input[i][j] = 0.0;
}
}
int N=144, howmany=4096;
fftw_complex* data = (fftw_complex*) fftw_malloc(N*howmany*sizeof(fftw_complex));
i=0,j=0;
int dataCount=0;
for(i=0;i<4096;i++)
{
for(j=0;j<144;j++)
{
data[dataCount++]=CMPLX(creal(input[i][j]),cimag(input[i][j]));
}
}
int istride=1, idist=N;// as in C data as row major
// ... if data is column-major, set istride=howmany, idist=1
// if data is row-major, set istride=1, idist=N
fftw_plan p = fftw_plan_many_dft(1,&N,howmany,data,NULL,howmany,1,data,NULL,howmany,1,FFTW_FORWARD,FFTW_MEASURE);
fftw_execute(p);