title: FFTW advance interface: fftw_plan_many_r2r() does not work
body: <p>I'm trying to implement 1D discrete cosine transform (type-I or any) for x and z direction when an input is an 1D array of size nx * nz flattened from the 2D nx by nz matrix. To do this, i'm using the fftw_plan_many_r2r() function in the intel MKL library. however, fftw_handle is set to NULL after set fftw_plan and segmentation fault occurs when execute the fft plans.
  Here is my code. It seems okay for me, however, does not work.. Expecting your help!</p>
  
  <p>by the way, i'm using other fftw advanced interfaces such as fftw_plan_many_dft, fftw_plan_many_dft_r2c and fftw_plan_many_dft_c2r routines very well.. So it feels more embarrassing.. When making the program, I refered the page (<a href="http://www.fftw.org/pruned.html" rel="nofollow noreferrer">http://www.fftw.org/pruned.html</a>)</p>
  
  <hr>
  
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;iostream&gt;
  #include &lt;complex&gt;
  #include &lt;vector&gt;
  #include &lt;fftw/fftw3_mkl.h&gt;
  
  void main()
  {
      // dimensions
      int nx = 4;
      int nz = 5;
  
      // plans
      fftw_plan plan_forward_x;
      fftw_plan plan_forward_z;
  
      // matrices
      std::vector&lt;double&gt; M_in = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f,  // -&gt;&gt; z-dir
                                   1.0f, 3.0f, 5.0f, 7.0f, 9.0f,
                                   6.0f, 2.0f, 7.0f, 3.0f, 1.0f,
                                   6.0f, 4.0f, 5.0f, 3.0f, 1.0f };
      std::vector&lt;double&gt; M_out(nx*nz);
      std::vector&lt;double&gt; Mkx(nx*nz);
      std::vector&lt;double&gt; Mkz(nx*nz);
  
      // set batched 1D DCT-1 plans for x-directional transformation
      {
           int rank = 1;
           int batch = nz;
           int inembed_x[] = { 0 };
           int idist = 1;
           int istride = nz;
           int onembed_x[] = { 0 };
           int odist = 1;
           int ostride = nz;
           fftw_r2r_kind kind = FFTW_REDFT00; // DCT-1
           plan_forward_x = fftw_plan_many_r2r(rank, &amp;nx, batch, 
                                        M_in.data(), inembed_x, istride, idist, 
                                        Mkx.data(), onembed_x, ostride, odist, 
                                        &amp;kind, FFTW_ESTIMATE);
      }
      // set batched 1D DCT-1 plans for z-directional transformation
      {
           int rank = 1;
           int batch = nx;
           int idist = nz;
           int odist = nz;
           int inembed_z[] = { 0 };
           int onembed_z[] = { 0 };
           int istride = 1;
           int ostride = 1;
           fftw_r2r_kind kind = FFTW_REDFT00; // DCT-1
           plan_forward_z = fftw_plan_many_r2r(rank, &amp;nz, batch, 
                                        M_in.data(), inembed_z, istride, idist, 
                                        Mkz.data(), onembed_z, ostride, odist, 
                                        &amp;kind, FFTW_ESTIMATE);
      }
  
      // execution
      fftw_execute(plan_forward_x);
      fftw_execute(plan_forward_z);
  
      // free fftw routines
      fftw_destroy_plan(plan_forward_x);
      fftw_destroy_plan(plan_forward_z);
      fftw_cleanup();
  
      return 0;
  }
  </code></pre>