summaryrefslogtreecommitdiff
path: root/lib/GSL/Compat.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-09-08 09:46:33 +0000
committerAlberto Ruiz <aruiz@um.es>2007-09-08 09:46:33 +0000
commit34380f2b5d7b048a4d68197f16a8db0e53742030 (patch)
tree444aff88cda5c247d49bac0d294d8cfb9ef7bf23 /lib/GSL/Compat.hs
parent0c38c1b0e122a56ea98c494e60ba90afe2688664 (diff)
type classes
Diffstat (limited to 'lib/GSL/Compat.hs')
-rw-r--r--lib/GSL/Compat.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/GSL/Compat.hs b/lib/GSL/Compat.hs
index 560a7d8..809a1f5 100644
--- a/lib/GSL/Compat.hs
+++ b/lib/GSL/Compat.hs
@@ -1,4 +1,4 @@
1{-# OPTIONS_GHC -fglasgow-exts #-} 1{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances #-}
2----------------------------------------------------------------------------- 2-----------------------------------------------------------------------------
3{- | 3{- |
4Module : GSL.Compat 4Module : GSL.Compat
@@ -23,6 +23,7 @@ import Data.Packed.Internal hiding (dsp)
23import Data.Packed.Vector 23import Data.Packed.Vector
24import Data.Packed.Matrix 24import Data.Packed.Matrix
25import GSL.Vector 25import GSL.Vector
26import LinearAlgebra.Linear
26import GSL.Matrix 27import GSL.Matrix
27import LinearAlgebra.Algorithms 28import LinearAlgebra.Algorithms
28import Complex 29import Complex
@@ -49,7 +50,7 @@ compat' m1 m2 = rows m1 == 1 && cols m1 == 1
49instance (Eq a, Field a) => Eq (Vector a) where 50instance (Eq a, Field a) => Eq (Vector a) where
50 a == b = dim a == dim b && toList a == toList b 51 a == b = dim a == dim b && toList a == toList b
51 52
52instance (Num a, Field a) => Num (Vector a) where 53instance (Linear Vector a) => Num (Vector a) where
53 (+) = adaptScalar addConstant add (flip addConstant) 54 (+) = adaptScalar addConstant add (flip addConstant)
54 negate = scale (-1) 55 negate = scale (-1)
55 (*) = adaptScalar scale mul (flip scale) 56 (*) = adaptScalar scale mul (flip scale)
@@ -60,7 +61,7 @@ instance (Num a, Field a) => Num (Vector a) where
60instance (Eq a, Field a) => Eq (Matrix a) where 61instance (Eq a, Field a) => Eq (Matrix a) where
61 a == b = rows a == rows b && cols a == cols b && cdat a == cdat b && fdat a == fdat b 62 a == b = rows a == rows b && cols a == cols b && cdat a == cdat b && fdat a == fdat b
62 63
63instance (Num a, Field a) => Num (Matrix a) where 64instance (Field a, Linear Vector a) => Num (Matrix a) where
64 (+) = liftMatrix2' (+) 65 (+) = liftMatrix2' (+)
65 negate = liftMatrix negate 66 negate = liftMatrix negate
66 (*) = liftMatrix2' (*) 67 (*) = liftMatrix2' (*)