Skip to main content

ifft_batch

Function ifft_batch 

Source
pub fn ifft_batch<R: Runtime>(
    device: &R::Device,
    signals: &[(Vec<f32>, Vec<f32>)],
) -> Vec<Vec<f32>>
Expand description

Computes the Cooley-Tukey radix-2 DIT IFFT for a batch of complex spectra in a single GPU pass.

Each element of signals is a (real, imag) pair produced by [fft_batch] (or by calling fft repeatedly). All pairs must share the same power-of-two length — pass the direct output of fft_batch unchanged.

Returns one Vec<f32> per input signal, each of length 2 * n:

  • [0..n] — reconstructed real signal
  • [n..2n] — reconstructed imaginary signal (≈ 0 for real-valued inputs)

§Panics

Panics if any pair has mismatched lengths, or if the shared length is not a power of two. An empty batch returns an empty Vec.

§Example

use cubecl::wgpu::WgpuRuntime;
use gpu_fft::{fft::fft_batch, ifft::ifft_batch};
let signals = vec![vec![1.0f32, 2.0, 3.0, 4.0]];
let spectra = fft_batch::<WgpuRuntime>(&Default::default(), &signals);
let pairs: Vec<_> = spectra.into_iter().collect();
let recovered = ifft_batch::<WgpuRuntime>(&Default::default(), &pairs);