Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

complex FFT in 2 dimensions

gambron__philippe
316 Views

Hello,

I am trying compute a complex to complex FFT in 2 dimensions but the values I obtain are not correct (only the first 2 are). This is not a normalisation issue. The transform I obtain is not simply proportional to the correct one.

I have made a minimal example that reproduces the problem. The signal corresponds to a square whose corners are set to 1+i while the remaining values are set to 0. I have also tried with an out-of-place transform but the same problem occurs. You will find the source code below.

I suppose I have made some silly mistake somewhere (I am a beginner with the MKL) but I can't figure out where.

Thank you!

#include <mkl_dfti.h>
#include <iostream>

int main(){

  long int n[2]={8, 8};
 
  double signal[128]={1,1, 1,1, 0,0, 0,0, 0,0, 0,0, 1,1, 1,1,
              1,1, 1,1, 0,0, 0,0, 0,0, 0,0, 1,1, 1,1,
              0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
              0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
              0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
              0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
              1,1, 1,1, 0,0, 0,0, 0,0, 0,0, 1,1, 1,1,
              1,1, 1,1, 0,0, 0,0, 0,0, 0,0, 1,1, 1,1};
 
  DFTI_DESCRIPTOR_HANDLE descriptor_handle;
  DftiCreateDescriptor(&descriptor_handle, DFTI_DOUBLE, DFTI_COMPLEX, 2, n);
  DftiErrorMessage(DftiCommitDescriptor(descriptor_handle));

  DftiComputeForward(descriptor_handle, signal);

  for(int i=0; i<64; ++i){
    std::cout << signal[2*i] << " " << signal[2*i+1] << "\n";
  }

  DftiFreeDescriptor(&descriptor_handle);
 
 
  return 0;
}

 

 

 

 

0 Kudos
2 Replies
Gennady_F_Intel
Moderator
316 Views

Philippe, could you please look at the MKL FFT double-precision complex-to-complex in-place 2D example which  you may find out in mklroot\examples\dftc\source\directory. Please look at basic_dp_complex_dft_2d.c case. Hope this example will help you. 

0 Kudos
gambron__philippe
316 Views

Hello,

Thank you for your reply.

That did the trick!

The examples you pointed to me are much more complete that what is online.

Thanks!

0 Kudos
Reply