CMSIS-DSP  Version 1.4.4
CMSIS DSP Software Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Real FFT Functions
The CMSIS DSP library includes specialized algorithms for computing the FFT of real data sequences. The FFT is defined over complex data but in many applications the input is real. Real FFT algorithms take advantage of the symmetry properties of the FFT and have a speed advantage over complex algorithms of the same length.
The Fast RFFT algorith relays on the mixed radix CFFT that save processor usage.
The real length N forward FFT of a sequence is computed using the steps shown below.
RFFT.gif
Real Fast Fourier Transform
The real sequence is initially treated as if it were complex to perform a CFFT. Later, a processing stage reshapes the data to obtain half of the frequency spectrum in complex format. Except the first complex number that contains the two real numbers X[0] and X[N/2] all the data is complex. In other words, the first complex sample contains two real values packed.
The input for the inverse RFFT should keep the same format as the output of the forward RFFT. A first processing stage pre-process the data to later perform an inverse CFFT.
RIFFT.gif
Real Inverse Fast Fourier Transform
The algorithms for floating-point, Q15, and Q31 data are slightly different and we describe each algorithm in turn.
Floating-point
The main functions are arm_rfft_fast_f32() and arm_rfft_fast_init_f32(). The older functions arm_rfft_f32() and arm_rfft_init_f32() have been deprecated but are still documented.
The FFT of a real N-point sequence has even symmetry in the frequency domain. The second half of the data equals the conjugate of the first half flipped in frequency:
*X[0] - real data
*X[1] - complex data
*X[2] - complex data
 ... 
*X[fftLen/2-1] - complex data
*X[fftLen/2] - real data
*X[fftLen/2+1] - conjugate of X[fftLen/2-1]
*X[fftLen/2+2] - conjugate of X[fftLen/2-2]
 ... 
*X[fftLen-1] - conjugate of X[1]
  
Looking at the data, we see that we can uniquely represent the FFT using only
*N/2+1 samples:
*X[0] - real data
*X[1] - complex data
*X[2] - complex data
 ... 
*X[fftLen/2-1] - complex data
*X[fftLen/2] - real data
  
Looking more closely we see that the first and last samples are real valued. They can be packed together and we can thus represent the FFT of an N-point real sequence by N/2 complex values:
*X[0],X[N/2] - packed real data: X[0] + jX[N/2]
*X[1] - complex data
*X[2] - complex data
 ... 
*X[fftLen/2-1] - complex data
  
The real FFT functions pack the frequency domain data in this fashion. The forward transform outputs the data in this form and the inverse transform expects input data in this form. The function always performs the needed bitreversal so that the input and output data is always in normal order. The functions support lengths of [32, 64, 128, ..., 4096] samples.
The forward and inverse real FFT functions apply the standard FFT scaling; no scaling on the forward transform and 1/fftLen scaling on the inverse transform.
Q15 and Q31
The real algorithms are defined in a similar manner and utilize N/2 complex transforms behind the scenes. In the case of fixed-point data, a radix-4 complex transform is performed and this limits the allows sequence lengths to 128, 512, and 2048 samples.
TBD. We need to document input and output order of data.
The complex transforms used internally include scaling to prevent fixed-point overflows. The overall scaling equals 1/(fftLen/2).
A separate instance structure must be defined for each transform used but twiddle factor and bit reversal tables can be reused.
There is also an associated initialization function for each data type. The initialization function performs the following operations:
  • Sets the values of the internal structure fields.
  • Initializes twiddle factor table and bit reversal table pointers.
  • Initializes the internal complex FFT data structure.
Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure should be manually initialized as follows:
*arm_rfft_instance_q31 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};    
*arm_rfft_instance_q15 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};    
  
where fftLenReal is the length of the real transform; fftLenBy2 length of the internal complex transform. ifftFlagR Selects forward (=0) or inverse (=1) transform. bitReverseFlagR Selects bit reversed output (=0) or normal order output (=1). twidCoefRModifier stride modifier for the twiddle factor table. The value is based on the FFT length; pTwiddleARealpoints to the A array of twiddle coefficients; pTwiddleBRealpoints to the B array of twiddle coefficients; pCfft points to the CFFT Instance structure. The CFFT structure must also be initialized. Refer to arm_cfft_radix4_f32() for details regarding static initialization of the complex FFT instance structure.