use num_complex::Complex;
use num_traits::{Float, FromPrimitive, Zero, One};
use crate::spectrum::{base::{FFTApply, IFFTApply}, SpectrumError, lib::{fft, ifft}};

pub struct FFTImpl;

impl<T> FFTApply<T> for FFTImpl
where
    T: Float + FromPrimitive + Zero + Clone + One + 'static,
{
    fn apply(&self, data: &Vec<T>) -> Result<Vec<Complex<T>>, SpectrumError> {
        fft(data)
    }
}

pub struct IFFTImpl;

impl<T> IFFTApply<T> for IFFTImpl
where
    T: Float + FromPrimitive + Zero + Clone + One + 'static,
{
    fn apply(&self, data: &mut Vec<Complex<T>>) -> Result<Vec<T>, SpectrumError> {
        ifft(data)
    }
}
