c++accelerate-frameworkvdsp

What should I feed to real FFT functions in vDSP?


The function signature of vDSP_fft_zrop (actually most of FFT functions in vDSP) accepts two DSPSplitComplex structures as input and output. However, for real FFT calculations, forward FFT accepts an input of only real values, while backward FFT produces an output of only real values. So how should I fill the input/output DSPSplitComplex structures for all-real values?

To declare more clearly, if I'm going to implement a more common API below:

void forward_fft( std::complex<float>* output, const float* input, unsigned size);

It is clear that I should interlace the output of vDSP functions to output memory using vDSP_ztoc, but how should I treat the input memory? Should I just do:

DSPSplitComplex input_for_vdsp;
input_for_vdsp.realp = input;
input_for_vdsp.imagp = nullptr

, or I should allocate a memory for the imagp pointer?


Solution

  • You can represent real values as even-odd configuration that uses both the real and imaginary parts of the complex values. See Apple's Data Packing for Fourier Transforms article for a full discussion.