module Data.Array.Accelerate.Language (
Acc, Exp,
constant,
use, unit,
reshape,
slice, replicate, zip, map, zipWith, scan, fold, permute, backpermute,
(?),
(!), shape,
(==*), (/=*), (<*), (<=*), (>*), (>=*), max, min,
(&&*), (||*), not,
boolToInt,
ignore
) where
import Prelude hiding (replicate, zip, map, zipWith, filter, max, min, not,
const)
import qualified Prelude
import Data.Bits
import Data.Array.Accelerate.Type
import Data.Array.Accelerate.Array.Sugar hiding ((!), ignore, shape)
import qualified Data.Array.Accelerate.Array.Sugar as Sugar
import Data.Array.Accelerate.Smart
use :: (Ix dim, Elem e) => Array dim e -> Acc (Array dim e)
use = Use
unit :: Elem e => Exp e -> Acc (Scalar e)
unit = Unit
reshape :: (Ix dim, Ix dim', Elem e)
=> Exp dim
-> Acc (Array dim' e)
-> Acc (Array dim e)
reshape = Reshape
replicate :: forall slix e. (SliceIx slix, Elem e)
=> Exp slix
-> Acc (Array (Slice slix) e)
-> Acc (Array (SliceDim slix) e)
replicate = Replicate (undefined::slix) (undefined::e)
slice :: forall slix e. (SliceIx slix, Elem e)
=> Acc (Array (SliceDim slix) e)
-> Exp slix
-> Acc (Array (Slice slix) e)
slice = Index (undefined::slix) (undefined::e)
zip :: (Ix dim, Elem a, Elem b)
=> Acc (Array dim a)
-> Acc (Array dim b)
-> Acc (Array dim (a, b))
zip = zipWith (\x y -> x `Pair` y)
map :: (Ix dim, Elem a, Elem b)
=> (Exp a -> Exp b)
-> Acc (Array dim a)
-> Acc (Array dim b)
map = Map
zipWith :: (Ix dim, Elem a, Elem b, Elem c)
=> (Exp a -> Exp b -> Exp c)
-> Acc (Array dim a)
-> Acc (Array dim b)
-> Acc (Array dim c)
zipWith = ZipWith
scan :: Elem a
=> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Vector a)
-> (Acc (Vector a), Acc (Scalar a))
scan f e arr = unpair (Scan f e arr)
fold :: Elem a
=> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Vector a)
-> Acc (Scalar a)
fold = Fold
permute :: (Ix dim, Ix dim', Elem a)
=> (Exp a -> Exp a -> Exp a)
-> Acc (Array dim' a)
-> (Exp dim -> Exp dim')
-> Acc (Array dim a)
-> Acc (Array dim' a)
permute = Permute
backpermute :: (Ix dim, Ix dim', Elem a)
=> Exp dim'
-> (Exp dim' -> Exp dim)
-> Acc (Array dim a)
-> Acc (Array dim' a)
backpermute = Backpermute
infix 0 ?
(?) :: Elem t => Exp Bool -> (Exp t, Exp t) -> Exp t
c ? (t, e) = Cond c t e
infixl 9 !
(!) :: (Ix dim, Elem e) => Acc (Array dim e) -> Exp dim -> Exp e
(!) = IndexScalar
shape :: Ix dim => Acc (Array dim e) -> Exp dim
shape = Shape
instance (Elem t, IsBounded t) => Bounded (Exp t) where
minBound = mkMinBound
maxBound = mkMaxBound
instance (Elem t, IsScalar t) => Enum (Exp t)
instance (Elem t, IsScalar t) => Prelude.Eq (Exp t)
instance (Elem t, IsScalar t) => Prelude.Ord (Exp t)
instance (Elem t, IsNum t, IsIntegral t) => Bits (Exp t) where
(.&.) = mkBAnd
(.|.) = mkBOr
xor = mkBXor
complement = mkBNot
instance (Elem t, IsNum t) => Num (Exp t) where
(+) = mkAdd
() = mkSub
(*) = mkMul
negate = mkNeg
abs = mkAbs
signum = mkSig
fromInteger = constant . fromInteger
instance (Elem t, IsNum t) => Real (Exp t)
instance (Elem t, IsIntegral t) => Integral (Exp t) where
quot = mkQuot
rem = mkRem
div = mkIDiv
mod = mkMod
instance (Elem t, IsFloating t) => Floating (Exp t) where
pi = mkPi
instance (Elem t, IsFloating t) => Fractional (Exp t) where
(/) = mkFDiv
recip = mkRecip
fromRational = exp . fromRational
instance (Elem t, IsFloating t) => RealFrac (Exp t)
instance (Elem t, IsFloating t) => RealFloat (Exp t)
infix 4 ==*, /=*, <*, <=*, >*, >=*
(==*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool
(==*) = mkEq
(/=*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool
(/=*) = mkNEq
(<*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool
(<*) = mkLt
(>=*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool
(>=*) = mkGtEq
(>*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool
(>*) = mkGt
(<=*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool
(<=*) = mkLtEq
max :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp t
max = mkMax
min :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp t
min = mkMin
infixr 3 &&*
(&&*) :: Exp Bool -> Exp Bool -> Exp Bool
(&&*) = mkLAnd
infixr 2 ||*
(||*) :: Exp Bool -> Exp Bool -> Exp Bool
(||*) = mkLOr
not :: Exp Bool -> Exp Bool
not = mkLNot
boolToInt :: Exp Bool -> Exp Int
boolToInt = mkBoolToInt
ignore :: Ix dim => Exp dim
ignore = constant Sugar.ignore