{-# OPTIONS_GHC -Wall #-} module Examples where import Data.Complex.Cyclotomic import Data.Ratio -- | A Discrete Fourier Transform dft :: [Cyclotomic] -> [Cyclotomic] dft cs = [sum $ zipWith (*) [conj (e m^(k*n)) | n <- [0..]] cs | k <- [0..m-1]] where m = fromIntegral $ length cs -- | Inverse Discrete Fourier Transform dftInv :: [Cyclotomic] -> [Cyclotomic] dftInv cs = [minv * sum (zipWith (*) [e m^(k*n) | n <- [0..]] cs) | k <- [0..m-1]] where m = fromIntegral $ length cs minv = fromRational (1 % m)