Skip to main content

dft_cpu

Function dft_cpu 

pub fn dft_cpu(input_interleaved: &[f32], n: usize) -> Vec<f32>
Expand description

Naive O(N²) forward Discrete Fourier Transform, the reference the GPU radix-2 FFT is differentially checked against. Complex data is interleaved f32: element j is (input[2*j], input[2*j+1]) = (real, imag), so both the input slice and the returned vector hold 2*N f32.

X[k] = sum_{j<N} x[j] * exp(-2*pi*i * k * j / N) — the SAME forward sign convention exp(-2*pi*i*...) the emitted kernel’s twiddle uses, so the CPU reference and the GPU FFT compute the identical transform. Angles are accumulated in f64 for a clean reference; the comparison tolerance covers the f32-vs-f64 and FFT-vs-DFT summation differences.