FFTW - Real 2D FFT Computation, Special Requirements

I use FFTW3 to calculate 2D real FFT in C ++. I read the manual, but I have some questions. From the manual: http://www.fftw.org/fftw3_doc/One_002dDimensional-DFTs-of-Real-Data.html#One_002dDimensional-DFTs-of-Real-Data

In exchange for these advantages in speed and space, the user sacrifices some of the simplicity of complex FFTW transformations. First of all, the input and output arrays have different sizes and types: the input is n real numbers, and the output is n / 2 + 1 complex numbers (non-reserved outputs); it also requires a little “padding” of the input array for in-place conversions. Secondly, the inverse transform (complex to real) has the side effect of overwriting its input array, by default. None of these inconveniences should be a serious problem for users, but it is important to know about them.

  • I understand that I need to convert the input 2D matrix to a 1st order vector. But what does the conclusion look like? What do the numbers n / 2 + 1 mean? In other words, how to change the output order to get a 2D matrix?

  • What exactly do I need to do to create this "add-on"?

+5
source share
2 answers
  • If your input is already in a normal two-dimensional C ++ array, all you need to do is its type:

    double twoDarray[10][10];
    double *oneDarrayPointer = (double *)twoDarray;
    

    If your input is 100 (as in the example above), your output array will consist of 51 complex numbers. The format of these numbers should be described by your library, but this is probably an array of 102 doubles- 51 entries 2 times (real / imaginary parts).

    Edit: confirmed - fftw_complexdefined as:

    typedef double fftw_complex[2];
    

    Thus, these are simply consecutive pairs doublesrepresenting the real and imaginary parts of a complex number.

  • , - . , 2 . , - :

    double *inPlaceFFTPointer = malloc(sizeof twoDarray + 2*sizeof(double));
    memcpy(inPlaceFFTPointer, oneDarrayPointer, sizeof twoDarray);
    

    , 0.0 , .

+2
+2
source

All Articles