Skip to main content

fft

Function fft 

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

Computes the Cooley-Tukey radix-2 FFT of a real-valued signal.

Runs in O(N log₂ N) on the GPU using log₂ N butterfly-stage kernel dispatches of N/2 threads each.

If input.len() is not a power of two the signal is zero-padded to the next power of two before the transform. Both returned vectors have length input.len().next_power_of_two().

§Example

use gpu_fft::fft;
let input = vec![0.0f32, 1.0, 0.0, 0.0];
let (real, imag) = fft(&input);
assert_eq!(real.len(), 4); // already a power of two