-{-# LANGUAGE FlexibleInstances #-}
-
--- | The 'Vector' class represents elements of a normed vector
--- space. We define instances for all common numeric types.
-module Vector
-where
-
-import Data.Number.BigFloat
-
-class (Num a) => Vector a where
- norm_2 :: RealFrac b => a -> b
- norm_infty :: RealFrac b => a -> b
-
--- Define instances for common numeric types.
-instance Vector Integer where
- norm_2 = fromInteger
- norm_infty = fromInteger
-
-instance Vector Rational where
- norm_2 = fromRational
- norm_infty = fromRational
-
-instance Epsilon e => Vector (BigFloat e) where
- norm_2 = fromRational . toRational
- norm_infty = fromRational . toRational
-
-instance Vector Double where
- norm_2 = fromRational . toRational
- norm_infty = fromRational . toRational