summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Instances.hs
diff options
context:
space:
mode:
authorVivian McPhail <haskell.vivian.mcphail@gmail.com>2010-06-29 09:03:19 +0000
committerVivian McPhail <haskell.vivian.mcphail@gmail.com>2010-06-29 09:03:19 +0000
commit4957cff8af91cbb23c12382e25f5373fe96acb95 (patch)
tree2f2968d5ca88f7d76e208982b8938c4dfc46ce8a /lib/Numeric/LinearAlgebra/Instances.hs
parentd18a86d37d55a39d4ec9b16397dd59f35aa13688 (diff)
add-vector-float
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Instances.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Instances.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Numeric/LinearAlgebra/Instances.hs b/lib/Numeric/LinearAlgebra/Instances.hs
index 1992db0..bba89c8 100644
--- a/lib/Numeric/LinearAlgebra/Instances.hs
+++ b/lib/Numeric/LinearAlgebra/Instances.hs
@@ -94,6 +94,14 @@ instance Linear Vector a => Eq (Vector a) where
94 94
95#endif 95#endif
96 96
97instance Num (Vector Float) where
98 (+) = adaptScalar addConstant add (flip addConstant)
99 negate = scale (-1)
100 (*) = adaptScalar scale mul (flip scale)
101 signum = vectorMapF Sign
102 abs = vectorMapF Abs
103 fromInteger = fromList . return . fromInteger
104
97instance Num (Vector Double) where 105instance Num (Vector Double) where
98 (+) = adaptScalar addConstant add (flip addConstant) 106 (+) = adaptScalar addConstant add (flip addConstant)
99 negate = scale (-1) 107 negate = scale (-1)
@@ -138,6 +146,27 @@ instance (Linear Vector a, Fractional (Vector a), Num (Matrix a)) => Fractional
138 146
139--------------------------------------------------------- 147---------------------------------------------------------
140 148
149instance Floating (Vector Float) where
150 sin = vectorMapF Sin
151 cos = vectorMapF Cos
152 tan = vectorMapF Tan
153 asin = vectorMapF ASin
154 acos = vectorMapF ACos
155 atan = vectorMapF ATan
156 sinh = vectorMapF Sinh
157 cosh = vectorMapF Cosh
158 tanh = vectorMapF Tanh
159 asinh = vectorMapF ASinh
160 acosh = vectorMapF ACosh
161 atanh = vectorMapF ATanh
162 exp = vectorMapF Exp
163 log = vectorMapF Log
164 sqrt = vectorMapF Sqrt
165 (**) = adaptScalar (vectorMapValF PowSV) (vectorZipF Pow) (flip (vectorMapValF PowVS))
166 pi = fromList [pi]
167
168-------------------------------------------------------------
169
141instance Floating (Vector Double) where 170instance Floating (Vector Double) where
142 sin = vectorMapR Sin 171 sin = vectorMapR Sin
143 cos = vectorMapR Cos 172 cos = vectorMapR Cos