diff options
Diffstat (limited to 'packages/base/src/Data')
-rw-r--r-- | packages/base/src/Data/Packed/Internal/Numeric.hs | 29 | ||||
-rw-r--r-- | packages/base/src/Data/Packed/Numeric.hs | 8 |
2 files changed, 33 insertions, 4 deletions
diff --git a/packages/base/src/Data/Packed/Internal/Numeric.hs b/packages/base/src/Data/Packed/Internal/Numeric.hs index 7359433..9b6b55b 100644 --- a/packages/base/src/Data/Packed/Internal/Numeric.hs +++ b/packages/base/src/Data/Packed/Internal/Numeric.hs | |||
@@ -39,6 +39,7 @@ module Data.Packed.Internal.Numeric ( | |||
39 | roundVector, | 39 | roundVector, |
40 | RealOf, ComplexOf, SingleOf, DoubleOf, | 40 | RealOf, ComplexOf, SingleOf, DoubleOf, |
41 | IndexOf, | 41 | IndexOf, |
42 | CInt, | ||
42 | module Data.Complex | 43 | module Data.Complex |
43 | ) where | 44 | ) where |
44 | 45 | ||
@@ -51,6 +52,7 @@ import Data.Complex | |||
51 | 52 | ||
52 | import Numeric.LinearAlgebra.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ) | 53 | import Numeric.LinearAlgebra.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ) |
53 | import Data.Packed.Internal | 54 | import Data.Packed.Internal |
55 | import Foreign.C.Types(CInt) | ||
54 | 56 | ||
55 | ------------------------------------------------------------------- | 57 | ------------------------------------------------------------------- |
56 | 58 | ||
@@ -123,6 +125,33 @@ class (Complexable c, Fractional e, SContainer c e) => Container c e | |||
123 | 125 | ||
124 | -------------------------------------------------------------------------- | 126 | -------------------------------------------------------------------------- |
125 | 127 | ||
128 | instance SContainer Vector CInt | ||
129 | where | ||
130 | size' = dim | ||
131 | -- scale' = vectorMapValF Scale | ||
132 | -- addConstant = vectorMapValF AddConstant | ||
133 | -- add = vectorZipF Add | ||
134 | -- sub = vectorZipF Sub | ||
135 | -- mul = vectorZipF Mul | ||
136 | -- equal u v = dim u == dim v && maxElement (vectorMapF Abs (sub u v)) == 0.0 | ||
137 | scalar' x = fromList [x] | ||
138 | konst' = constantD | ||
139 | build' = buildV | ||
140 | cmap' = mapVector | ||
141 | atIndex' = (@>) | ||
142 | -- minIndex' = emptyErrorV "minIndex" (round . toScalarF MinIdx) | ||
143 | -- maxIndex' = emptyErrorV "maxIndex" (round . toScalarF MaxIdx) | ||
144 | -- minElement' = emptyErrorV "minElement" (toScalarF Min) | ||
145 | -- maxElement' = emptyErrorV "maxElement" (toScalarF Max) | ||
146 | -- sumElements' = sumF | ||
147 | -- prodElements' = prodF | ||
148 | -- step' = stepF | ||
149 | find' = findV | ||
150 | assoc' = assocV | ||
151 | accum' = accumV | ||
152 | -- cond' = condV condI | ||
153 | |||
154 | |||
126 | instance SContainer Vector Float | 155 | instance SContainer Vector Float |
127 | where | 156 | where |
128 | size' = dim | 157 | size' = dim |
diff --git a/packages/base/src/Data/Packed/Numeric.hs b/packages/base/src/Data/Packed/Numeric.hs index ae5fad7..4d66f27 100644 --- a/packages/base/src/Data/Packed/Numeric.hs +++ b/packages/base/src/Data/Packed/Numeric.hs | |||
@@ -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 | ||
222 | instance Container Vector e => Konst e Int Vector | 222 | instance SContainer Vector e => Konst e Int Vector |
223 | where | 223 | where |
224 | konst = konst' | 224 | konst = konst' |
225 | 225 | ||
226 | instance Container Vector e => Konst e (Int,Int) Matrix | 226 | instance (Num e, SContainer 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 | ||
249 | instance Container Vector e => Build Int (e -> e) Vector e | 249 | instance SContainer Vector e => Build Int (e -> e) Vector e |
250 | where | 250 | where |
251 | build = build' | 251 | build = build' |
252 | 252 | ||
253 | instance Container Matrix e => Build (Int,Int) (e -> e -> e) Matrix e | 253 | instance SContainer Matrix e => Build (Int,Int) (e -> e -> e) Matrix e |
254 | where | 254 | where |
255 | build = build' | 255 | build = build' |
256 | 256 | ||