fourier 0.1.0

Fast Fourier transforms (FFTs)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::float::FftFloat;
use num_complex::Complex;

#[inline]
pub fn compute_twiddle<T: FftFloat>(index: usize, size: usize, forward: bool) -> Complex<T> {
    let theta = (index * 2) as f64 * std::f64::consts::PI / size as f64;
    let twiddle = Complex::new(
        T::from_f64(theta.cos()).unwrap(),
        T::from_f64(-theta.sin()).unwrap(),
    );
    if forward {
        twiddle
    } else {
        twiddle.conj()
    }
}