

#include <nitro/math/fft.h>
void MATH_FFTReal( fx32* data, u32 nShift, const fx16* sinTable, const fx16* sinTable2 );
| data | Pointer to the data to transform. Overwritten by the transformed data. |
| nShift | The value obtained by taking the base-2 logarithm of the number of input real numbers. |
| sinTable | Pointer to the table of sine values. |
| sinTable2 | Pointer to a sine value table that omits every other value in sinTable. |
None.
Takes a real number series as input and performs a discrete Fourier transform that outputs a complex number series using the fast Fourier transform algorithm.
This performs the same transform as the MATH_FFT function with the imaginary number parts filled with 0, but it uses only half the amount of memory, and the calculation takes only around half as much time.
In the explanation below, the value 2nShift (2 to the nShift power) is represented as N. The data argument is a type fx32 array of length N. This is the data in real numbers you want to transform.
The sinTable argument is a pointer to the array of length N*3/4, filled with fx16-type sine values satisfying sinTable[k] = sin( (2π/N) * k ) (k = 0, 1,..., N*3/4-1). This can be created using the MATH_MakeFFTSinTable function.
The sinTable2 argument is a pointer to an array of length (N/2)*3/4, filled with fx16-type sine values that satisfy sinTable2[k] = sin( (2π/(N/2)) * k ) (k = 0, 1,..., (N/2)*3/4-1). This can be created by passing a value decremented by 1 to the nShift argument in the MATH_MakeFFTSinTable function.
The result of the discrete Fourier transform is a complex number series, but because a real number series is passed, only half the values are the independent numeric values. For this reason, this function extracts only the independent parts, overwrites them as an N/2+1-order complex number series (with the first and last imaginary components always 0) in data and then returns. The resulting size of the array that gets used is N, or the same as the input data. The return value is in a format that stores real and imaginary numbers alternately. However, the N/2th value (always a real number) gets stored in the imaginary part of the 0th value (always a real number) and returned. In other words, the transform result is an N/2+1-order complex number series, expressed as {data[0], data[2]+i*data[3], ..., data[N-2]+i*data[N-1], data[1]}, where i represents an imaginary number. As for the latter half that was omitted because it was not independent, the values take the complex conjugate of the reverse order of the complex number series (from the first number to the (N/2-1)th number).
The discrete Fourier transform is a calculation for getting Fm (m = 0, 1, ... N-1) to satisfy the expression
fn = Σk = 0N-1 Fke-i2πkn/N
where the sampling value in complex numbers taken along the time axis is expressed as fn (n = 0, 1, ... N-1).
When the input signals are decomposed into a superposition of sine waves, Fm can be viewed as a coefficient of each frequency. The fast Fourier transform is an algorithm that performs the discrete Fourier transform with a time complexity of order N*log(N).
The calculations are performed using fixed-decimal numbers, so if a large value is given as the input, there is a risk of overflow. When the input value is viewed as type s32, the absolute value should not be greater than or equal to 0x80000000/N. Also note that the maximum error when performing both the forward transform and inverse transform is around several times FX32_ONE.
MATH_MakeFFTSinTable
MATH_FFT
MATH_IFFT
MATH_IFFTReal
2009/03/23 Corrected mistakes in formula.
2005/07/21 Corrected explanation of sinTable.
2005/07/11 Corrected Description.
2005/05/13 Initial version.
CONFIDENTIAL