Skip to main content

numra_fft/
lib.rs

1#![allow(clippy::approx_constant)]
2#![allow(clippy::manual_range_contains)]
3#![allow(clippy::needless_range_loop)]
4
5//! FFT and spectral analysis for Numra.
6//!
7//! Provides Fast Fourier Transform, power spectral density, windowing,
8//! convolution, and short-time Fourier transform. Built on `rustfft`.
9//!
10//! All public functions are generic over `S: Scalar` (f32/f64), with
11//! the FFT computation internally performed in f64 via rustfft.
12//!
13//! # Example
14//!
15//! ```rust
16//! use numra_fft::{fft, ifft, Complex};
17//!
18//! let signal: Vec<Complex<f64>> = vec![
19//!     Complex::new(1.0_f64, 0.0),
20//!     Complex::new(0.0, 0.0),
21//!     Complex::new(0.0, 0.0),
22//!     Complex::new(0.0, 0.0),
23//! ];
24//! let spectrum = fft(&signal);
25//! let recovered = ifft(&spectrum);
26//! for (a, b) in signal.iter().zip(recovered.iter()) {
27//!     assert!((a.re - b.re).abs() < 1e-12);
28//! }
29//! ```
30//!
31//! Author: Moussa Leblouba
32//! Date: 9 February 2026
33//! Modified: 2 May 2026
34
35pub mod complex;
36pub mod convolution;
37pub mod fft_core;
38pub mod real;
39pub mod spectral;
40pub mod utils;
41
42pub use complex::{Complex, ComplexF64};
43pub use convolution::{fftconvolve, fftcorrelate};
44pub use fft_core::{fft, fft2, ifft};
45pub use real::{irfft, rfft};
46pub use spectral::{psd, stft, welch, StftResult};
47pub use utils::{fftfreq, fftshift, ifftshift, window_func, Window};