accelerate-utility 0.1 → 0.1.1
raw patch · 4 files changed
+43/−10 lines, 4 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Data.Array.Accelerate.Utility.Shape: class (Shape sh, Slice sh, Elt sh, Eq sh, Plain sh ~ sh, Lift Exp sh) => C sh
+ Data.Array.Accelerate.Utility.Shape: instance (C sh, i ~ Int) => C (sh :. i)
+ Data.Array.Accelerate.Utility.Shape: instance C Z
+ Data.Array.Accelerate.Utility.Shape: switch :: C sh => f Z -> (forall sh0. C sh0 => f (sh0 :. Int)) -> f sh
Files
- accelerate-utility.cabal +7/−6
- src/Data/Array/Accelerate/Utility/Shape.hs +32/−0
- src/Data/Array/Accelerate/Utility/Sliced.hs +2/−2
- src/Data/Array/Accelerate/Utility/Sliced1.hs +2/−2
accelerate-utility.cabal view
@@ -1,10 +1,10 @@ Name: accelerate-utility-Version: 0.1+Version: 0.1.1 License: BSD3 License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de> Maintainer: Henning Thielemann <haskell@henning-thielemann.de>-Homepage: http://code.haskell.org/~thielema/accelerate-utility/+Homepage: http://hub.darcs.net/thielema/accelerate-utility/ Category: Parallelism Synopsis: Utility functions for the Accelerate framework Description:@@ -15,19 +15,19 @@ Build-Type: Simple Source-Repository this- Tag: 0.1+ Tag: 0.1.1 Type: darcs- Location: http://code.haskell.org/~thielema/accelerate-utility/+ Location: http://hub.darcs.net/thielema/accelerate-utility/ Source-Repository head Type: darcs- Location: http://code.haskell.org/~thielema/accelerate-utility/+ Location: http://hub.darcs.net/thielema/accelerate-utility/ Library Build-Depends: accelerate >=0.15 && <0.16, utility-ht >=0.0.8 && <0.1,- base >=4.5 && <4.8+ base >=4.5 && <4.10 GHC-Options: -Wall -fwarn-missing-import-lists Hs-Source-Dirs: src@@ -41,3 +41,4 @@ Data.Array.Accelerate.Utility.Sliced Data.Array.Accelerate.Utility.Sliced1 Data.Array.Accelerate.Utility.Ord+ Data.Array.Accelerate.Utility.Shape
+ src/Data/Array/Accelerate/Utility/Shape.hs view
@@ -0,0 +1,32 @@+{-# LANGUAGE Rank2Types #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE FlexibleContexts #-}+{- |+An alternative Shape class that allows to add new \"methods\",+but forbids to add new instances.+You can provide new \"methods\" by calling 'switch'+with a newtype around your function type.++For the general concept, see:+<https://www.haskell.org/haskellwiki/Closed_world_instances>+-}+module Data.Array.Accelerate.Utility.Shape (+ C(..),+ ) where++import qualified Data.Array.Accelerate as A+import Data.Array.Accelerate (Exp, Z, (:.))+++class+ (A.Shape sh, A.Slice sh, A.Elt sh, Eq sh,+ A.Plain sh ~ sh, A.Lift Exp sh) =>+ C sh where+ switch :: f Z -> (forall sh0. C sh0 => f (sh0 :. Int)) -> f sh++instance C Z where+ switch f _ = f++instance (C sh, i ~ Int) => C (sh:.i) where+ switch _ f = f
src/Data/Array/Accelerate/Utility/Sliced.hs view
@@ -11,7 +11,7 @@ import qualified Data.Array.Accelerate as A import Data.Array.Accelerate (Exp, Acc, Array, Elt, Slice, Shape, DIM2, (:.)((:.)),- (!), (?), (==*), (<*), )+ (!), (?), (>*), (==*), ) length ::@@ -120,7 +120,7 @@ let sh:.m = Exp.unlift (expr:.expr) $ A.shape arr in A.generate (A.lift $ sh:.n)- (\ix -> A.indexHead ix <* m ? (arr!ix, x))+ (\ix -> m >* A.indexHead ix ? (arr!ix, x)) {- |
src/Data/Array/Accelerate/Utility/Sliced1.hs view
@@ -11,7 +11,7 @@ import qualified Data.Array.Accelerate as A import Data.Array.Accelerate (Exp, Acc, Array, Elt, (:.)((:.)), Slice, Shape,- (!), (?), (<*), (==*), )+ (!), (?), (>*), (==*), ) length ::@@ -66,7 +66,7 @@ (_shy:.ny:.leny) = Exp.unlift (expr:.expr:.expr) $ A.shape y in A.generate (A.lift $ shx :. nx+ny :. max lenx leny) $ Exp.modify (expr:.expr:.expr) $ \(ix:.k:.j) ->- k<*nx ? (x ! A.lift (ix:.k:.j), y ! A.lift (ix:.k-nx:.j))+ nx >* k ? (x ! A.lift (ix:.k:.j), y ! A.lift (ix:.k-nx:.j)) append3 :: (Shape sh, Slice sh, Elt a) =>