1   module Complex_Vectors
    2           (ComplexF, rootsOfUnity,thetas, norm,distance)
    3   where
    4   import Complex --
    5 
    6   type ComplexF = Complex Double
    7 
    8   rootsOfUnity:: Int -> [ComplexF]
    9   rootsOfUnity n = zipWith (:+) (map cos (thetas n)) 
   10                                 (map sin (thetas n))
   11 
   12   thetas:: Int -> [Double]
   13   thetas n = [(2*pi/fromInt n)*fromInt k | k<-[0 .. n-1]]
   14     -- partain addition:
   15     where
   16       fromInt :: (Num a) => Int -> a
   17       fromInt i = fromInteger (toInteger i)
   18 
   19   norm:: [ComplexF] -> Double
   20   norm = sqrt.sum.map((^2).magnitude)
   21 
   22   distance:: [ComplexF] -> [ComplexF] -> Double
   23   distance z w = norm(zipWith (-) z w)