#[cfg(not(feature = "no_std"))]
use super::Complex;
#[cfg(not(feature = "no_std"))]
pub fn dft<T: Clone>(input: &[T]) -> Vec<Complex<f64>>
where
f64: From<T>,
{
let n = input.len();
let mut output = Vec::with_capacity(n);
for k in 0..n {
let mut sum = Complex::new(0.0, 0.0);
for (t, x) in input.iter().enumerate() {
let angle = -2.0 * core::f64::consts::PI * (t as f64) * (k as f64) / (n as f64);
let c = Complex::new(angle.cos(), angle.sin()) * Complex::new(x.clone().into(), 0.0f64);
sum = c + sum;
}
output.push(sum);
}
output
}