title: Efficient 2D FFT on real input data?
body: <p>I'm currently implementing a two dimensional FFT for real input data using opencl (more specifically a fast 2D convolution using FFTs, so I only need something which behaves similary enough to apply the convolution to). The 2D FFT is implemented using an 1D FFT on the rows and afterwards an 1D FFT on the cols.</p>
  
  <p>To make this more efficient I'm trying to use the symmetries of FFTs with real input in order to be able to calculate smaller FFTs. I found that I can combine two rows into one, using the first as real component, the second as imaginary component, do the first 1D FFT on the resulting row and then use the symmetry properties to construct the results of the 1D FFTs of the individual rows from that. So what I'm doing is basically the following:</p>
  
  <p>Let <code>f</code> and <code>g</code> be rows from the matrix.</p>
  
  <ol>
  <li>Construct <code>x = f + i * g</code></li>
  <li>Transform to get <code>F(x) = F(f) + i * F(g)</code></li>
  <li>Use symmetries to extract <code>F(f)</code> and <code>F(g)</code> from <code>F(x)</code></li>
  </ol>
  
  <p>I can't however just input the results directly into the 2nd 1D FFT, because in that case I would not transform the whole matrix, but two submatrices instead. However extracting the data between the transformations means either storing more data (<code>n/2+1</code> entries needed to express the result of an 1D FFT on real input) or combine the elements at index <code>0</code> and index <code>n/2</code> into one element (combining using the same trick, since both numbers are guaranteed to be real) and use the same amount of storage but have to make a spcial case for that in my convolution.</p>
  
  <p>Since I try to reuse buffers as much as possible (due to limited RAM availible on the gpu) using more storage isn't a nice solution. Furthermore my algorithms are not equipped to work on matrixsizes which are not power of 2 / multiples of 16 (varies from kernel to kernel). I would rather avoid introducing special cases either, since those would make my kernels more complex hurting efficiency (I'm already having trouble to minimize the register count used by each kernel).</p>
  
  <p>So my question is if there is an elegant approach to this problem, meaning one which will work without either using more memory or special cases for certain elements?</p>
  
  <p>Ideally I would like to be able to do the whole FFT without splitting my combined data in the middle of the FFT, but I'm not sure thats possible.</p>