24 releases

Uses new Rust 2024

new 0.3.1 Feb 14, 2026
0.3.0 Feb 12, 2026
0.2.9 Jan 28, 2026
0.2.7 Dec 20, 2025
0.1.7 Oct 29, 2025

#565 in Algorithms

Download history 15/week @ 2025-10-30 115/week @ 2025-11-06 4/week @ 2025-11-13 19/week @ 2025-11-20 117/week @ 2025-11-27 157/week @ 2025-12-04 187/week @ 2025-12-11 102/week @ 2025-12-18 52/week @ 2025-12-25 19/week @ 2026-01-01 173/week @ 2026-01-08 71/week @ 2026-01-15 75/week @ 2026-01-22 225/week @ 2026-01-29 19/week @ 2026-02-05 232/week @ 2026-02-12

557 downloads per month
Used in 6 crates

BSD-3-Clause OR Apache-2.0

5MB
99K SLoC

Zaft FFT Example

This example demonstrates how to perform real-to-complex (R2C) and complex-to-real (C2R) FFTs, as well as standard complex-to-complex forward and inverse FFTs using Zaft.

Real-to-Complex (R2C) and Complex-to-Real (C2R)

use zaft::Zaft;
use num_complex::Complex;

fn main() -> Result<(), zaft::ZaftError> {
    // Example real input data
    let mut real_data: Vec<f32> = vec![0.0; 1024];

    // Create R2C and C2R FFT executors
    let forward_r2c = Zaft::make_r2c_fft_f32(real_data.len())?;
    let inverse_r2c = Zaft::make_c2r_fft_f32(real_data.len())?;

    // Prepare buffer for complex output
    let mut complex_data = vec![Complex::<f32>::default(); real_data.len() / 2 + 1];

    // Perform forward R2C FFT
    forward_r2c.execute(&real_data, &mut complex_data)?;

    // Perform inverse C2R FFT
    inverse_r2c.execute(&complex_data, &mut real_data)?;

    Ok(())
}

Note: After the round-trip, real_data will approximately equal its original values (within floating-point precision and normalization).

Complex-to-Complex FFT

use zaft::Zaft;
use num_complex::Complex;

fn main() -> Result<(), zaft::ZaftError> {
    // Example complex input
    let mut data: Vec<Complex<f32>> = vec![Complex::new(0.0, 0.0); 1024];

    // Create forward and inverse complex FFT executors
    let forward = Zaft::make_forward_fft_f32(data.len())?;
    let inverse = Zaft::make_inverse_fft_f32(data.len())?;

    // Perform forward FFT
    forward.execute(&mut data)?;

    // Perform inverse FFT
    inverse.execute(&mut data)?;

    Ok(())
}

Notes

R2C FFTs only store the non-redundant half of the spectrum: the length of the complex buffer is (real_len / 2 + 1).

C2R FFTs require the same shape of complex input and reconstruct the full real output.

Complex-to-complex FFTs operate in-place and maintain the full length of the data.


This project is licensed under either of

  • BSD-3-Clause License (see LICENSE)
  • Apache License, Version 2.0 (see LICENSE)

at your option.

Dependencies

~4.5MB
~86K SLoC