fftw3: The 1d Real-data DFT

 
 4.8.2 The 1d Real-data DFT
 --------------------------
 
 The real-input (r2c) DFT in FFTW computes the _forward_ transform Y of
 the size 'n' real array X, exactly as defined above, i.e.
  Y[k] = sum for j = 0 to (n - 1) of X[j] * exp(-2 pi j k sqrt(-1)/n) .
    This output array Y can easily be shown to possess the "Hermitian"
 symmetry Y[k] = Y[n-k]*, where we take Y to be periodic so that Y[n] =
 Y[0].
 
    As a result of this symmetry, half of the output Y is redundant
 (being the complex conjugate of the other half), and so the 1d r2c
 transforms only output elements 0...n/2 of Y (n/2+1 complex numbers),
 where the division by 2 is rounded down.
 
    Moreover, the Hermitian symmetry implies that Y[0] and, if n is even,
 the Y[n/2] element, are purely real.  So, for the 'R2HC' r2r transform,
 the halfcomplex format does not store the imaginary parts of these
 elements.
 
    The c2r and 'H2RC' r2r transforms compute the backward DFT of the
 _complex_ array X with Hermitian symmetry, stored in the r2c/'R2HC'
 output formats, respectively, where the backward transform is defined
 exactly as for the complex case:
  Y[k] = sum for j = 0 to (n - 1) of X[j] * exp(2 pi j k sqrt(-1)/n) .
    The outputs 'Y' of this transform can easily be seen to be purely
 real, and are stored as an array of real numbers.
 
    Like FFTW's complex DFT, these transforms are unnormalized.  In other
 words, applying the real-to-complex (forward) and then the
 complex-to-real (backward) transform will multiply the input by n.