diff options
Diffstat (limited to 'packages/base/src/Data/Packed/Internal/Numeric.hs')
-rw-r--r-- | packages/base/src/Data/Packed/Internal/Numeric.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/base/src/Data/Packed/Internal/Numeric.hs b/packages/base/src/Data/Packed/Internal/Numeric.hs index 3e6c90c..fec8c05 100644 --- a/packages/base/src/Data/Packed/Internal/Numeric.hs +++ b/packages/base/src/Data/Packed/Internal/Numeric.hs | |||
@@ -36,7 +36,7 @@ module Data.Packed.Internal.Numeric ( | |||
36 | Convert(..), | 36 | Convert(..), |
37 | Complexable(), | 37 | Complexable(), |
38 | RealElement(), | 38 | RealElement(), |
39 | roundVector, | 39 | roundVector, fromInt, |
40 | RealOf, ComplexOf, SingleOf, DoubleOf, | 40 | RealOf, ComplexOf, SingleOf, DoubleOf, |
41 | IndexOf, | 41 | IndexOf, |
42 | CInt, Extractor(..), (??), | 42 | CInt, Extractor(..), (??), |
@@ -179,6 +179,7 @@ class Element e => Container c e | |||
179 | -- element by element inverse tangent | 179 | -- element by element inverse tangent |
180 | arctan2' :: Fractional e => c e -> c e -> c e | 180 | arctan2' :: Fractional e => c e -> c e -> c e |
181 | cmod' :: Integral e => e -> c e -> c e | 181 | cmod' :: Integral e => e -> c e -> c e |
182 | fromInt' :: c CInt -> c e | ||
182 | 183 | ||
183 | 184 | ||
184 | -------------------------------------------------------------------------- | 185 | -------------------------------------------------------------------------- |
@@ -215,6 +216,7 @@ instance Container Vector CInt | |||
215 | cmod' m x | 216 | cmod' m x |
216 | | m /= 0 = vectorMapValI ModVS m x | 217 | | m /= 0 = vectorMapValI ModVS m x |
217 | | otherwise = error $ "cmod 0 on vector of size "++(show $ dim x) | 218 | | otherwise = error $ "cmod 0 on vector of size "++(show $ dim x) |
219 | fromInt' = id | ||
218 | 220 | ||
219 | instance Container Vector Float | 221 | instance Container Vector Float |
220 | where | 222 | where |
@@ -246,6 +248,7 @@ instance Container Vector Float | |||
246 | divide = vectorZipF Div | 248 | divide = vectorZipF Div |
247 | arctan2' = vectorZipF ATan2 | 249 | arctan2' = vectorZipF ATan2 |
248 | cmod' = undefined | 250 | cmod' = undefined |
251 | fromInt' = int2floatV | ||
249 | 252 | ||
250 | 253 | ||
251 | 254 | ||
@@ -279,6 +282,7 @@ instance Container Vector Double | |||
279 | divide = vectorZipR Div | 282 | divide = vectorZipR Div |
280 | arctan2' = vectorZipR ATan2 | 283 | arctan2' = vectorZipR ATan2 |
281 | cmod' = undefined | 284 | cmod' = undefined |
285 | fromInt' = int2DoubleV | ||
282 | 286 | ||
283 | 287 | ||
284 | instance Container Vector (Complex Double) | 288 | instance Container Vector (Complex Double) |
@@ -311,6 +315,7 @@ instance Container Vector (Complex Double) | |||
311 | divide = vectorZipC Div | 315 | divide = vectorZipC Div |
312 | arctan2' = vectorZipC ATan2 | 316 | arctan2' = vectorZipC ATan2 |
313 | cmod' = undefined | 317 | cmod' = undefined |
318 | fromInt' = complex . int2DoubleV | ||
314 | 319 | ||
315 | instance Container Vector (Complex Float) | 320 | instance Container Vector (Complex Float) |
316 | where | 321 | where |
@@ -342,6 +347,7 @@ instance Container Vector (Complex Float) | |||
342 | divide = vectorZipQ Div | 347 | divide = vectorZipQ Div |
343 | arctan2' = vectorZipQ ATan2 | 348 | arctan2' = vectorZipQ ATan2 |
344 | cmod' = undefined | 349 | cmod' = undefined |
350 | fromInt' = complex . int2floatV | ||
345 | 351 | ||
346 | --------------------------------------------------------------- | 352 | --------------------------------------------------------------- |
347 | 353 | ||
@@ -379,6 +385,7 @@ instance (Num a, Element a, Container Vector a) => Container Matrix a | |||
379 | cmod' m x | 385 | cmod' m x |
380 | | m /= 0 = liftMatrix (cmod' m) x | 386 | | m /= 0 = liftMatrix (cmod' m) x |
381 | | otherwise = error $ "cmod 0 on matrix "++shSize x | 387 | | otherwise = error $ "cmod 0 on matrix "++shSize x |
388 | fromInt' = liftMatrix fromInt' | ||
382 | 389 | ||
383 | 390 | ||
384 | emptyErrorV msg f v = | 391 | emptyErrorV msg f v = |
@@ -416,6 +423,9 @@ arctan2 = arctan2' | |||
416 | cmod :: (Integral e, Container c e) => e -> c e -> c e | 423 | cmod :: (Integral e, Container c e) => e -> c e -> c e |
417 | cmod = cmod' | 424 | cmod = cmod' |
418 | 425 | ||
426 | fromInt :: (Container c e) => c CInt -> c e | ||
427 | fromInt = fromInt' | ||
428 | |||
419 | 429 | ||
420 | -- | like 'fmap' (cannot implement instance Functor because of Element class constraint) | 430 | -- | like 'fmap' (cannot implement instance Functor because of Element class constraint) |
421 | cmap :: (Element b, Container c e) => (e -> b) -> c e -> c b | 431 | cmap :: (Element b, Container c e) => (e -> b) -> c e -> c b |