title: Intel MKL in-place real-to-real transforms not possible?
body: <p>I am trying to learn how to use Intel's Math Kernel Library (MKL) to compute in-place FFTs of periodic real data. There are examples of not-in-place real-to-complex transforms and my guess at what should work for in-place real-to-real transforms does not reproduce correct results.</p>
  
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;cmath&gt;
  #include &lt;mkl.h&gt;
  
  #define TwoPI 6.2831853071795864769
  
  /* define a periodic function */
  void initialize(float* data, float* copy, const long size)
  {
      const double k = TwoPI/cbrt(size);
  
      for (int i = 0; i &lt; size; ++i)
      {
          data[i] = cos(k*i);
          copy[i] = data[i];
      }
  }
  
  int main()
  {
      const long fft_size = 1024;
      const long num_fft  = pow(fft_size,2);
      const long size     = pow(fft_size,3);
  
      DFTI_DESCRIPTOR_HANDLE handle = nullptr;
  
      /* configure a single-precision, real, 1-dimensional FFT of desired size */
      DftiCreateDescriptor(&amp;handle, DFTI_SINGLE, DFTI_REAL, 1, (MKL_LONG)fft_size);
      DftiSetValue(handle, DFTI_NUMBER_OF_TRANSFORMS, num_fft);
      DftiSetValue(handle, DFTI_INPUT_DISTANCE, fft_size);
      DftiSetValue(handle, DFTI_OUTPUT_DISTANCE, fft_size);
      DftiSetValue(handle, DFTI_PLACEMENT, DFTI_INPLACE);
      DftiCommitDescriptor(handle);
  
      /* prepare the data */
      float *data = (float*) mkl_malloc( sizeof(float)*size, 32 );
      float *copy = (float*) mkl_malloc( sizeof(float)*size, 32 );
      initialize(data, copy, size);
  
      /* compute the forward transform */
      DftiComputeForward(handle, data);
  
      /* free resources */
      DftiFreeDescriptor(&amp;handle);
      mkl_free(data);
      mkl_free(copy);
  
      return 0;
  }
  </code></pre>
  
  <p>So, what is the solution? Is it not possible? Do I always have to deal with not-in-place real-to-complex transforms and allocate memory separately for the complex output?</p>