Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

complex FFT in 2 dimensions

$
0
0

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;
}

 

 

 

 


Viewing all articles
Browse latest Browse all 3005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>