Skip to main content

lib_jsl_ffts/
mod.rs

1//! Fast Fourier transforms.
2//!
3//! # Which FFT should I use?
4//!
5//! Use [`Fft`]. It handles any length, picks the right algorithm for it, and is fast:
6//!
7//! ```
8//! use lib_jsl_ffts::{Fft, FftDirection, FftEngine1D, FftOrdering, FftScaleFactor};
9//! use num_complex::Complex;
10//!
11//! let mut fft = Fft::new();
12//! fft.plan(1024, FftScaleFactor::None, FftDirection::Forward, FftOrdering::Standard).unwrap();
13//! let spectrum = fft.execute(&vec![Complex::new(0.0, 0.0); 1024]).unwrap();
14//! # assert_eq!(spectrum.len(), 1024);
15//! ```
16//!
17//! Plan once and reuse the engine; planning builds the twiddle tables.
18//!
19//! # What else is here
20//!
21//! | Item | Use it when |
22//! |------|-------------|
23//! | [`Fft`] | You want a transform and don't care how it is computed (default) |
24//! | [`best_fft::BestFft`] | You know the size is a power of two and want that engine directly |
25//! | [`bluestein_fft::BluesteinFft`] | You want the arbitrary-length algorithm directly |
26//! | [`simd_fft::SimdFft`] | You need vectorised kernels on ARM or RISC-V as well as x86 |
27//! | [`fractional_fft::FractionalFft`] | You need the fractional Fourier transform |
28//! | [`helpers`] | Frequency grids (`fftfreq`), fast lengths (`next_fast_len`), N-D real FFTs and N-D DCTs |
29//! | [`fft_engine_trait::FftEngine1D`] | You want to write code generic over FFT engines |
30//!
31//! Readable textbook implementations (recursive radix-2, iterative radix-2, split radix) live in
32//! the separate `lib_jsl_ffts_reference` crate, so they stay out of the way here.
33//!
34//! See the book chapter [Fast Fourier transforms](https://jwkunz.github.io/lib_jsl/book/fft/index.html).
35
36pub mod fft;
37pub mod fft_engine_trait;
38
39pub mod best_fft;
40pub mod bluestein_fft;
41pub mod dct;
42pub mod fractional_fft;
43pub mod helpers;
44pub mod multidimensional_fft;
45pub mod real_fft;
46pub mod simd_fft;
47
48pub mod fftlog;
49pub use fftlog::{fht, fhtoffset, hfft, ifht, ihfft, ln_gamma_complex};
50pub use best_fft::BestFft;
51pub use bluestein_fft::BluesteinFft;
52pub use dct::{TrigNormalization, TrigTransformType, dct, dst, idct, idst};
53pub use fft::Fft;
54pub use fft_engine_trait::{FftDirection, FftEngine1D, FftOrdering, FftScaleFactor};
55pub use fractional_fft::{FractionalFft, frft};
56pub use helpers::{dctn, dstn, fftfreq, fftshift_1d, idctn, idstn, ifftshift, ifftshift_1d, irfftn, next_fast_len, rfftfreq, rfftn};
57pub use multidimensional_fft::{fft2, fft3, fft_axis, fftn, fftshift, ifft2, ifft3};
58pub use real_fft::{RealFft, irfft, rfft};
59pub use simd_fft::SimdFft;
60
61#[cfg(test)]
62pub mod test_bench_data;