Skip to main content

fft_batch

Function fft_batch 

Source
pub fn fft_batch(signals: &[Vec<f32>]) -> Vec<(Vec<f32>, Vec<f32>)>
Expand description

Computes the Cooley-Tukey radix-2 FFT of a batch of real-valued signals in a single GPU pass.

All signals are zero-padded to the next power-of-two of the longest signal so they share a common length n. The batch is processed with a 2-D kernel dispatch โ€” the Y-dimension selects the signal, and the X-dimension covers butterfly pairs within a signal.

Returns one (real, imag) pair per input signal, each of length n.

ยงExample

use gpu_fft::fft_batch;
let signals = vec![
    vec![1.0f32, 0.0, 0.0, 0.0], // impulse โ†’ all-ones spectrum
    vec![1.0f32, 1.0, 1.0, 1.0], // DC      โ†’ [4, 0, 0, 0]
];
let results = fft_batch(&signals);
assert_eq!(results.len(), 2);