accelerate-utility-0.1.1: Utility functions for the Accelerate framework

Data.Array.Accelerate.Utility.Lift.Exp

Synopsis

# Documentation

class (Elt (Tuple pattern), Plain (Unlifted pattern) ~ Tuple pattern) => Unlift pattern where Source

This class simplifies untupling of expressions. If you have a function

`g :: ((Exp a, Exp b), Exp (c,d)) -> (Exp e, Exp f)`

you cannot apply it to an array `arr :: Array sh ((a,b),(c,d))` using `map`. Here, the `modify` function helps:

`modify ((expr,expr),expr) g :: Exp ((a,b),(c,d)) -> Exp (e,f)`

The `expr`-pattern tells, how deep the tuple shall be unlifted. This way you can write:

```A.map
(Exp.modify ((expr,expr),expr) \$ \((a,b), cd) -> g ((a,b), cd))
arr```

`modify` is based on `unlift`. In contrast to `unlift` it does not only unlift one level of tupels, but is guided by an `expr`-pattern. In the example I have demonstrated, how the pair `(a,b)` is unlifted, but the pair `(c,d)` is not. For the result tuple, `modify` simply calls `lift`. In contrast to `unlift`, `lift` lifts over all tupel levels until it obtains a single `Exp`.

Associated Types

type Unlifted pattern Source

type Tuple pattern Source

Methods

unlift :: pattern -> Exp (Tuple pattern) -> Unlifted pattern Source

Instances

 Unlift p => Unlift (Complex p) Elt a => Unlift (Exp a) (Unlift pa, Unlift pb) => Unlift (pa, pb) (Unlift pa, Slice (Tuple pa), (~) * int (Exp Int)) => Unlift ((:.) pa int) (Unlift pa, Unlift pb, Unlift pc) => Unlift (pa, pb, pc)

modify :: (Lift Exp a, Unlift pattern) => pattern -> (Unlifted pattern -> a) -> Exp (Tuple pattern) -> Exp (Plain a) Source

modify2 :: (Lift Exp a, Unlift patternA, Unlift patternB) => patternA -> patternB -> (Unlifted patternA -> Unlifted patternB -> a) -> Exp (Tuple patternA) -> Exp (Tuple patternB) -> Exp (Plain a) Source

modify3 :: (Lift Exp a, Unlift patternA, Unlift patternB, Unlift patternC) => patternA -> patternB -> patternC -> (Unlifted patternA -> Unlifted patternB -> Unlifted patternC -> a) -> Exp (Tuple patternA) -> Exp (Tuple patternB) -> Exp (Tuple patternC) -> Exp (Plain a) Source

modify4 :: (Lift Exp a, Unlift patternA, Unlift patternB, Unlift patternC, Unlift patternD) => patternA -> patternB -> patternC -> patternD -> (Unlifted patternA -> Unlifted patternB -> Unlifted patternC -> Unlifted patternD -> a) -> Exp (Tuple patternA) -> Exp (Tuple patternB) -> Exp (Tuple patternC) -> Exp (Tuple patternD) -> Exp (Plain a) Source

data Exp e Source

Constructors

 Exp

Instances

 Elt a => Unlift (Exp a) Elt a => Unlift (Exp a) type Unlifted (Exp a) = Exp a type Tuple (Exp a) = a type Unlifted (Exp a) = Exp a type Tuple (Exp a) = Scalar a

Deprecated: use expr instead

for compatibility with accelerate-utility-0.0

unliftPair :: (Elt a, Elt b) => Exp (a, b) -> (Exp a, Exp b) Source

unliftTriple :: (Elt a, Elt b, Elt c) => Exp (a, b, c) -> (Exp a, Exp b, Exp c) Source

unliftQuadruple :: (Elt a, Elt b, Elt c, Elt d) => Exp (a, b, c, d) -> (Exp a, Exp b, Exp c, Exp d) Source

asExp :: Exp a -> Exp a Source

mapFst :: (Elt a, Elt b, Elt c) => (Exp a -> Exp b) -> Exp (a, c) -> Exp (b, c) Source

mapSnd :: (Elt a, Elt b, Elt c) => (Exp b -> Exp c) -> Exp (a, b) -> Exp (a, c) Source

fst3 :: (Elt a, Elt b, Elt c) => Exp (a, b, c) -> Exp a Source

snd3 :: (Elt a, Elt b, Elt c) => Exp (a, b, c) -> Exp b Source

thd3 :: (Elt a, Elt b, Elt c) => Exp (a, b, c) -> Exp c Source

indexCons :: Slice ix => Exp ix -> Exp Int -> Exp (ix :. Int) Source