1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! This crate provides fast Fourier transforms (FFT) in pure Rust.
//!
//! # Implementation
//! For FFTs with sizes that are multiples of 2 and 3, the Stockham auto-sort algorithm is used.
//! For any other sizes, Bluestein's algorithm is used.

#[macro_use]
mod vector;

mod autosort;
mod bluesteins;
mod fft;
mod float;
mod twiddle;

pub use crate::fft::*;

/// Create a complex-valued FFT over `f32` with the specified size.
pub fn create_fft_f32(size: usize) -> Box<dyn Fft<Real = f32> + Send> {
    if let Some(fft) = crate::autosort::prime_factor::create_f32(size) {
        fft
    } else {
        crate::bluesteins::create_f32(size)
    }
}

/// Create a complex-valued FFT over `f64` with the specified size.
pub fn create_fft_f64(size: usize) -> Box<dyn Fft<Real = f64> + Send> {
    if let Some(fft) = crate::autosort::prime_factor::create_f64(size) {
        fft
    } else {
        crate::bluesteins::create_f64(size)
    }
}