#define Flt Float
#define VECT_Float
module Data.Vect.Flt.Instances where
import Data.Vect.Flt.Base
instance Eq Vec2 where
Vec2 x y == Vec2 a b = (x==a && y==b)
instance Num Vec2 where
(+) = (&+)
() = (&-)
negate = neg
(*) = pointwise
fromInteger a = let x = fromInteger a in Vec2 x x
abs = normalize
signum v = let x = norm v in Vec2 x x
instance Fractional Vec2 where
(Vec2 x y) / (Vec2 a b) = Vec2 (x/a) (y/b)
fromRational a = let x = fromRational a in Vec2 x x
instance Eq Vec3 where
Vec3 x y z == Vec3 a b c = (x==a && y==b && z==c)
instance Num Vec3 where
(+) = (&+)
() = (&-)
negate = neg
(*) = pointwise
fromInteger a = let x = fromInteger a in Vec3 x x x
abs = normalize
signum v = let x = norm v in Vec3 x x x
instance Fractional Vec3 where
(Vec3 x y z) / (Vec3 a b c) = Vec3 (x/a) (y/b) (z/c)
fromRational a = let x = fromRational a in Vec3 x x x
instance Eq Vec4 where
Vec4 x y z w == Vec4 a b c d = (x==a && y==b && z==c && w==d)
instance Num Vec4 where
(+) = (&+)
() = (&-)
negate = neg
(*) = pointwise
fromInteger a = let x = fromInteger a in Vec4 x x x x
abs = normalize
signum v = let x = norm v in Vec4 x x x x
instance Fractional Vec4 where
(Vec4 x y z w) / (Vec4 a b c d) = Vec4 (x/a) (y/b) (z/c) (w/d)
fromRational a = let x = fromRational a in Vec4 x x x x
instance Eq Mat2 where
Mat2 x y == Mat2 a b = (x==a && y==b)
instance Num Mat2 where
(+) = (&+)
() = (&-)
negate = neg
(*) = (.*.)
fromInteger = diag . fromInteger
abs m = m &* (1.0 / frobeniusNorm m)
signum = diag . (\x -> Vec2 x x) . frobeniusNorm
instance Fractional Mat2 where
(/) = error "Mat2/division: not implemented"
fromRational = diag . fromRational
instance Eq Mat3 where
Mat3 x y z == Mat3 a b c = (x==a && y==b && z==c)
instance Num Mat3 where
(+) = (&+)
() = (&-)
negate = neg
(*) = (.*.)
fromInteger = diag . fromInteger
abs m = m &* (1.0 / frobeniusNorm m)
signum = diag . (\x -> Vec3 x x x) . frobeniusNorm
instance Fractional Mat3 where
(/) = error "Mat3/division: not implemented"
fromRational = diag . fromRational
instance Eq Mat4 where
Mat4 x y z w == Mat4 a b c d = (x==a && y==b && z==c && w==d)
instance Num Mat4 where
(+) = (&+)
() = (&-)
negate = neg
(*) = (.*.)
fromInteger = diag . fromInteger
abs m = m &* (1.0 / frobeniusNorm m)
signum = diag . (\x -> Vec4 x x x x) . frobeniusNorm
instance Fractional Mat4 where
(/) = error "Mat4/division: not implemented"
fromRational = diag . fromRational