diff options
Diffstat (limited to 'packages/base/src/Numeric/Vector.hs')
-rw-r--r-- | packages/base/src/Numeric/Vector.hs | 25 |
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 | ||
20 | module Numeric.Vector () where | 20 | module Numeric.Vector () where |
21 | 21 | ||
22 | import Numeric.Vectorized | 22 | import Internal.Vectorized |
23 | import Data.Packed.Vector | 23 | import Internal.Vector |
24 | import Data.Packed.Internal.Numeric | 24 | import Internal.Numeric |
25 | import Internal.Conversion | ||
25 | 26 | ||
26 | ------------------------------------------------------------------- | 27 | ------------------------------------------------------------------- |
27 | 28 | ||
@@ -32,6 +33,22 @@ adaptScalar f1 f2 f3 x y | |||
32 | 33 | ||
33 | ------------------------------------------------------------------ | 34 | ------------------------------------------------------------------ |
34 | 35 | ||
36 | instance 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 | |||
44 | instance 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 | |||
35 | instance Num (Vector Float) where | 52 | instance 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 | ||
69 | instance (Container Vector a, Num (Vector a)) => Fractional (Vector a) where | 86 | instance (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 |