Skip to main content

Crate spektra_fft

Crate spektra_fft 

Source
Expand description

A radix-2 Cooley-Tukey Fast Fourier Transform, generic over f32 and f64.

A Fft is a plan: it precomputes the twiddle factors and the bit-reversal permutation for one transform length, and every transform of that length then reuses them. Planning takes &self, so a single plan can be shared across threads and across channels.

use spektra_fft::{Fft, numbers::complex::Complex};

let plan = Fft::<f64>::new(8)?;

let mut signal = [Complex::new(1.0, 0.0); 8];
plan.transform_in_place(&mut signal)?;

// A constant signal puts all of its energy in the DC bin.
assert!((signal[0].re - 8.0).abs() < 1e-12);
assert!(signal[1].norm() < 1e-12);

§Normalization

The forward transform is unnormalized and the inverse divides by n, so a forward followed by an inverse returns the original signal. This is the same convention as NumPy and FFTW.

Modules§

float
The floating-point abstraction the transform is generic over.
numbers

Structs§

Fft
A planned Fast Fourier Transform of one fixed length.

Enums§

FftError
Why a transform could not run.