module BLAS.Elem.Base (
Elem(..),
module BLAS.Conj,
) where
import BLAS.Conj
import Data.Complex ( Complex(..), magnitude )
import Foreign ( Storable )
import Foreign.Storable.Complex ()
class (Storable e, Fractional e, Conj e) => Elem e where
norm :: e -> Double
norm1 :: e -> Double
fromReal :: Double -> e
toReal :: e -> Double
instance Elem Double where
norm = abs
norm1 = abs
fromReal = id
toReal = id
instance Elem (Complex Double) where
norm = magnitude
norm1 (x :+ y) = abs x + abs y
fromReal x = x :+ 0
toReal (x :+ _) = x