Hello,
I am trying to do forward and backward Fourier transform using the FFT routines available in Intel MKL. I have taken help of manual and also website examples to do this but i am getting a segmentation fault. Please help me to resolve it.
I am taking real valued as input to FFT forward and want output in Complex form.
Following is my code which i have implemented so far
#include <iostream>
#include "mkl_dfti.h"
typedef struct {
float re;
float im;
} mkl_float_complex;
using namespace std;
int main(int argc, char **argv)
{
//Read binary file in array xr_in dimension 2001 X 1911
n2=2001 n1=1911
mkl_float_complex **xc_out;
DFTI_DESCRIPTOR_HANDLE desc_handle_for, desc_handle_back;
MKL_LONG status;
MKL_LONG lengths[2];
lengths[0] = n2; lengths[1] = n1;
xc_out = (mkl_float_complex**) malloc(sizeof(mkl_float_complex*)*n2);
for(i2 = 0; i2 < n2; i2++)
xc_out[i2] = (mkl_float_complex*) malloc(sizeof(mkl_float_complex)*n1);
status = DftiCreateDescriptor(&desc_handle_for, DFTI_SINGLE, DFTI_REAL, 2, lengths);
status = DftiSetValue(desc_handle_for, DFTI_CONJUGATE_EVEN_STORAGE, DFTI_COMPLEX_COMPLEX);
status = DftiSetValue(desc_handle_for, DFTI_PACKED_FORMAT, DFTI_CCE_FORMAT);
status = DftiSetValue(desc_handle_for, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
status = DftiCommitDescriptor(desc_handle_for);
status = DftiComputeForward(desc_handle_for, xr_in, xc_out);
status = DftiFreeDescriptor(&desc_handle_for);
//Writing real part only to file
//Open file
for(i2 = 0; i2 < n2; i2++)
for(i1 = 0; i1 < n1; i1++)
fwrite(&(xc_out[i2][i1].re), sizeof(float), 1, fp);
//Close file
}//End of main