From 0c8a545e67ebef2b3a4e376fac8f23a651dfbe6d Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Fri, 22 May 2015 09:02:42 +0200 Subject: initial CInt SContainer --- packages/base/src/Data/Packed/Internal/Numeric.hs | 29 +++++++++++++++++++++++ packages/base/src/Data/Packed/Numeric.hs | 8 +++---- 2 files changed, 33 insertions(+), 4 deletions(-) (limited to 'packages/base/src/Data/Packed') 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 ( roundVector, RealOf, ComplexOf, SingleOf, DoubleOf, IndexOf, + CInt, module Data.Complex ) where @@ -51,6 +52,7 @@ import Data.Complex import Numeric.LinearAlgebra.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ) import Data.Packed.Internal +import Foreign.C.Types(CInt) ------------------------------------------------------------------- @@ -123,6 +125,33 @@ class (Complexable c, Fractional e, SContainer c e) => Container c e -------------------------------------------------------------------------- +instance SContainer Vector CInt + where + size' = dim +-- scale' = vectorMapValF Scale +-- addConstant = vectorMapValF AddConstant +-- add = vectorZipF Add +-- sub = vectorZipF Sub +-- mul = vectorZipF Mul +-- equal u v = dim u == dim v && maxElement (vectorMapF Abs (sub u v)) == 0.0 + scalar' x = fromList [x] + konst' = constantD + build' = buildV + cmap' = mapVector + atIndex' = (@>) +-- minIndex' = emptyErrorV "minIndex" (round . toScalarF MinIdx) +-- maxIndex' = emptyErrorV "maxIndex" (round . toScalarF MaxIdx) +-- minElement' = emptyErrorV "minElement" (toScalarF Min) +-- maxElement' = emptyErrorV "maxElement" (toScalarF Max) +-- sumElements' = sumF +-- prodElements' = prodF +-- step' = stepF + find' = findV + assoc' = assocV + accum' = accumV +-- cond' = condV condI + + instance SContainer Vector Float where 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 -- konst :: e -> d -> c e -instance Container Vector e => Konst e Int Vector +instance SContainer Vector e => Konst e Int Vector where konst = konst' -instance Container Vector e => Konst e (Int,Int) Matrix +instance (Num e, SContainer Vector e) => Konst e (Int,Int) Matrix where konst = konst' @@ -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 -- build :: d -> f -> c e -instance Container Vector e => Build Int (e -> e) Vector e +instance SContainer Vector e => Build Int (e -> e) Vector e where build = build' -instance Container Matrix e => Build (Int,Int) (e -> e -> e) Matrix e +instance SContainer Matrix e => Build (Int,Int) (e -> e -> e) Matrix e where build = build' -- cgit v1.2.3