Module dsp::dft
Discrete Fourier Transform (direct, O(n^2))
The direct-summation DFT: X[k] = sum_{n=0}^{N-1} x[n] * e^(-i2pikn/N). Works for any N (not just powers of two, unlike fft.h's radix-2 Cooley-Tukey) — use this for arbitrary-length transforms, and as the independent reference implementation fft.h's own tests verify against. For N large enough that O(n^2) matters, use fft.h instead when N is a power of two.
Functions
| dft | Forward transform, complex input -> complex output. 'out' must have space for 'n' elements; 'out' may not alias 'in'. |
| dft_real | Forward transform, real input -> complex output (convenience: treats each sample as Complex(x, 0) internally without requiring the caller to build that array themselves — the common case for analyzing a real audio/sensor signal). |
| idft | Inverse transform (includes the 1/N normalization), complex -> complex. |
| dft_f32 | Float in and out (computed in double, rounded once). Same contracts. |
| dft_real_f32 | |
| idft_f32 | |
| fdft | Q8.24 fixed-point forward/inverse transforms. Twiddle factors are computed in double precision and quantized to Fixed once per use (see complex_dsp.h's design-time-float/runtime-fixed note) — the summation itself runs entirely in Q8.24 arithmetic. |
| fidft |