summaryrefslogtreecommitdiff
path: root/packages/base/src/Data/Packed/Numeric.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-05-23 12:31:32 +0200
committerAlberto Ruiz <aruiz@um.es>2015-05-23 12:31:32 +0200
commitb1b445697db31b1603a31747ca31151f97ee7263 (patch)
tree453bbe1e16e2abd0b605e7807a33de4eaba4a866 /packages/base/src/Data/Packed/Numeric.hs
parent36379e29fe99b033313f42464897c32b9805559d (diff)
join SContainer and Container using Fractional contexts
Diffstat (limited to 'packages/base/src/Data/Packed/Numeric.hs')
-rw-r--r--packages/base/src/Data/Packed/Numeric.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/packages/base/src/Data/Packed/Numeric.hs b/packages/base/src/Data/Packed/Numeric.hs
index 4d66f27..d11ecf9 100644
--- a/packages/base/src/Data/Packed/Numeric.hs
+++ b/packages/base/src/Data/Packed/Numeric.hs
@@ -31,7 +31,7 @@ module Data.Packed.Numeric (
31 diag, ident, 31 diag, ident,
32 ctrans, 32 ctrans,
33 -- * Generic operations 33 -- * Generic operations
34 SContainer(..), Container(..), Numeric, 34 Container(..), Numeric,
35 -- add, mul, sub, divide, equal, scaleRecip, addConstant, 35 -- add, mul, sub, divide, equal, scaleRecip, addConstant,
36 scalar, conj, scale, arctan2, cmap, 36 scalar, conj, scale, arctan2, cmap,
37 atIndex, minIndex, maxIndex, minElement, maxElement, 37 atIndex, minIndex, maxIndex, minElement, maxElement,
@@ -88,7 +88,7 @@ Logarithmic spacing can be defined as follows:
88 88
89@logspace n (a,b) = 10 ** linspace n (a,b)@ 89@logspace n (a,b) = 10 ** linspace n (a,b)@
90-} 90-}
91linspace :: (Container Vector e) => Int -> (e, e) -> Vector e 91linspace :: (Fractional e, Container Vector e) => Int -> (e, e) -> Vector e
92linspace 0 _ = fromList[] 92linspace 0 _ = fromList[]
93linspace 1 (a,b) = fromList[(a+b)/2] 93linspace 1 (a,b) = fromList[(a+b)/2]
94linspace n (a,b) = addConstant a $ scale s $ fromList $ map fromIntegral [0 .. n-1] 94linspace n (a,b) = addConstant a $ scale s $ fromList $ map fromIntegral [0 .. n-1]
@@ -219,11 +219,11 @@ class Konst e d c | d -> c, c -> d
219 -- 219 --
220 konst :: e -> d -> c e 220 konst :: e -> d -> c e
221 221
222instance SContainer Vector e => Konst e Int Vector 222instance Container Vector e => Konst e Int Vector
223 where 223 where
224 konst = konst' 224 konst = konst'
225 225
226instance (Num e, SContainer Vector e) => Konst e (Int,Int) Matrix 226instance (Num e, Container Vector e) => Konst e (Int,Int) Matrix
227 where 227 where
228 konst = konst' 228 konst = konst'
229 229
@@ -246,11 +246,11 @@ class Build d f c e | d -> c, c -> d, f -> e, f -> d, f -> c, c e -> f, d e -> f
246 -- 246 --
247 build :: d -> f -> c e 247 build :: d -> f -> c e
248 248
249instance SContainer Vector e => Build Int (e -> e) Vector e 249instance Container Vector e => Build Int (e -> e) Vector e
250 where 250 where
251 build = build' 251 build = build'
252 252
253instance SContainer Matrix e => Build (Int,Int) (e -> e -> e) Matrix e 253instance Container Matrix e => Build (Int,Int) (e -> e -> e) Matrix e
254 where 254 where
255 build = build' 255 build = build'
256 256
@@ -299,5 +299,6 @@ instance Numeric Double
299instance Numeric (Complex Double) 299instance Numeric (Complex Double)
300instance Numeric Float 300instance Numeric Float
301instance Numeric (Complex Float) 301instance Numeric (Complex Float)
302instance Numeric CInt
302 303
303 304