summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/Vector.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Numeric/Vector.hs')
-rw-r--r--packages/base/src/Numeric/Vector.hs25
1 files changed, 21 insertions, 4 deletions
diff --git a/packages/base/src/Numeric/Vector.hs b/packages/base/src/Numeric/Vector.hs
index 28b453f..017196c 100644
--- a/packages/base/src/Numeric/Vector.hs
+++ b/packages/base/src/Numeric/Vector.hs
@@ -19,9 +19,10 @@
19 19
20module Numeric.Vector () where 20module Numeric.Vector () where
21 21
22import Numeric.Vectorized 22import Internal.Vectorized
23import Data.Packed.Vector 23import Internal.Vector
24import Data.Packed.Internal.Numeric 24import Internal.Numeric
25import Internal.Conversion
25 26
26------------------------------------------------------------------- 27-------------------------------------------------------------------
27 28
@@ -32,6 +33,22 @@ adaptScalar f1 f2 f3 x y
32 33
33------------------------------------------------------------------ 34------------------------------------------------------------------
34 35
36instance Num (Vector I) where
37 (+) = adaptScalar addConstant add (flip addConstant)
38 negate = scale (-1)
39 (*) = adaptScalar scale mul (flip scale)
40 signum = vectorMapI Sign
41 abs = vectorMapI Abs
42 fromInteger = fromList . return . fromInteger
43
44instance Num (Vector Z) where
45 (+) = adaptScalar addConstant add (flip addConstant)
46 negate = scale (-1)
47 (*) = adaptScalar scale mul (flip scale)
48 signum = vectorMapL Sign
49 abs = vectorMapL Abs
50 fromInteger = fromList . return . fromInteger
51
35instance Num (Vector Float) where 52instance Num (Vector Float) where
36 (+) = adaptScalar addConstant add (flip addConstant) 53 (+) = adaptScalar addConstant add (flip addConstant)
37 negate = scale (-1) 54 negate = scale (-1)
@@ -66,7 +83,7 @@ instance Num (Vector (Complex Float)) where
66 83
67--------------------------------------------------- 84---------------------------------------------------
68 85
69instance (Container Vector a, Num (Vector a)) => Fractional (Vector a) where 86instance (Container Vector a, Num (Vector a), Fractional a) => Fractional (Vector a) where
70 fromRational n = fromList [fromRational n] 87 fromRational n = fromList [fromRational n]
71 (/) = adaptScalar f divide g where 88 (/) = adaptScalar f divide g where
72 r `f` v = scaleRecip r v 89 r `f` v = scaleRecip r v