knead-0.5: Repa-like array processing using LLVM JIT

Synopsis

# Documentation

data Exp a

Instances

 Value Exp (Transcendental a, Real a, RationalConstant a) => Floating (Exp a) (Field a, Real a, RationalConstant a) => Fractional (Exp a) (PseudoRing a, Real a, IntegerConstant a) => Num (Exp a) Compose (Exp a) (Transcendental a, RationalConstant a) => C (Exp a) (Transcendental a, RationalConstant a) => C (Exp a) (Field a, RationalConstant a) => C (Exp a) (Real a, PseudoRing a, IntegerConstant a) => C (Exp a) (PseudoRing a, IntegerConstant a) => C (Exp a) Additive a => C (Exp a) We do not require a numeric prelude superclass, thus also LLVM only types like vectors are instances. MV a => Argument (Exp a) (C a, C a) => C (Exp a) (~ * a (Scalar v), PseudoModule v, IntegerConstant a) => C (Exp a) (Exp v)

class Value val where

Methods

lift0 :: T a -> val a

lift1 :: (T a -> T b) -> val a -> val b

lift2 :: (T a -> T b -> T c) -> val a -> val b -> val c

Instances

 Value Exp Value T

lift0 :: Value val => forall a. T a -> val a

lift1 :: Value val => forall a b. (T a -> T b) -> val a -> val b

lift2 :: Value val => forall a b c. (T a -> T b -> T c) -> val a -> val b -> val c

lift3 :: Value val => (T a -> T b -> T c -> T d) -> val a -> val b -> val c -> val d

lift4 :: Value val => (T a -> T b -> T c -> T d -> T e) -> val a -> val b -> val c -> val d -> val e

liftM :: (forall r. T a -> CodeGenFunction r (T b)) -> Exp a -> Exp b

liftM2 :: (forall r. T a -> T b -> CodeGenFunction r (T c)) -> Exp a -> Exp b -> Exp c

liftM3 :: (forall r. T a -> T b -> T c -> CodeGenFunction r (T d)) -> Exp a -> Exp b -> Exp c -> Exp d

unliftM1 :: (Exp a -> Exp b) -> T a -> CodeGenFunction r (T b)

unliftM2 :: (Exp a -> Exp b -> Exp c) -> T a -> T b -> CodeGenFunction r (T c)

unliftM3 :: (Exp a -> Exp b -> Exp c -> Exp d) -> T a -> T b -> T c -> CodeGenFunction r (T d)

liftTupleM :: (forall r. ValueOf a -> CodeGenFunction r (ValueOf b)) -> Exp a -> Exp b

liftTupleM2 :: (forall r. ValueOf a -> ValueOf b -> CodeGenFunction r (ValueOf c)) -> Exp a -> Exp b -> Exp c

liftTupleM3 :: (forall r. ValueOf a -> ValueOf b -> ValueOf c -> CodeGenFunction r (ValueOf d)) -> Exp a -> Exp b -> Exp c -> Exp d

zip :: Value val => val a -> val b -> val (a, b)

zip3 :: Value val => val a -> val b -> val c -> val (a, b, c)

zip4 :: Value val => val a -> val b -> val c -> val d -> val (a, b, c, d)

unzip :: Value val => val (a, b) -> (val a, val b)

unzip3 :: Value val => val (a, b, c) -> (val a, val b, val c)

unzip4 :: Value val => val (a, b, c, d) -> (val a, val b, val c, val d)

fst :: Value val => val (a, b) -> val a

snd :: Value val => val (a, b) -> val b

mapFst :: (Exp a -> Exp b) -> Exp (a, c) -> Exp (b, c)

mapSnd :: (Exp b -> Exp c) -> Exp (a, b) -> Exp (a, c)

mapPair :: (Exp a0 -> Exp a1, Exp b0 -> Exp b1) -> Exp (a0, b0) -> Exp (a1, b1)

swap :: Value val => val (a, b) -> val (b, a)

curry :: (Exp (a, b) -> c) -> Exp a -> Exp b -> c

uncurry :: (Exp a -> Exp b -> c) -> Exp (a, b) -> c

fst3 :: Value val => val (a, b, c) -> val a

snd3 :: Value val => val (a, b, c) -> val b

thd3 :: Value val => val (a, b, c) -> val c

mapFst3 :: (Exp a0 -> Exp a1) -> Exp (a0, b, c) -> Exp (a1, b, c)

mapSnd3 :: (Exp b0 -> Exp b1) -> Exp (a, b0, c) -> Exp (a, b1, c)

mapThd3 :: (Exp c0 -> Exp c1) -> Exp (a, b, c0) -> Exp (a, b, c1)

mapTriple :: (Exp a0 -> Exp a1, Exp b0 -> Exp b1, Exp c0 -> Exp c1) -> Exp (a0, b0, c0) -> Exp (a1, b1, c1)

tuple :: Exp tuple -> Exp (Tuple tuple)

untuple :: Exp (Tuple tuple) -> Exp tuple

modifyMultiValue :: (Value val, Compose a, Decompose pattern, ~ * (PatternTuple pattern) tuple) => pattern -> (Decomposed T pattern -> a) -> val tuple -> val (Composed a)

modifyMultiValue2 :: (Value val, Compose a, Decompose patternA, Decompose patternB, ~ * (PatternTuple patternA) tupleA, ~ * (PatternTuple patternB) tupleB) => patternA -> patternB -> (Decomposed T patternA -> Decomposed T patternB -> a) -> val tupleA -> val tupleB -> val (Composed a)

modifyMultiValueM :: (Compose a, Decompose pattern, ~ * (PatternTuple pattern) tuple) => pattern -> (forall r. Decomposed T pattern -> CodeGenFunction r a) -> Exp tuple -> Exp (Composed a)

modifyMultiValueM2 :: (Compose a, Decompose patternA, Decompose patternB, ~ * (PatternTuple patternA) tupleA, ~ * (PatternTuple patternB) tupleB) => patternA -> patternB -> (forall r. Decomposed T patternA -> Decomposed T patternB -> CodeGenFunction r a) -> Exp tupleA -> Exp tupleB -> Exp (Composed a)

class Compose multituple where

Associated Types

type Composed multituple :: *

Methods

compose :: multituple -> Exp (Composed multituple)

A nested `zip`.

Instances

 Compose () Compose a => Compose (Complex a) Compose n => Compose (ZeroBased n) (Enum enum, Bounded enum) => Compose (Enumeration enum) Compose (Exp a) Compose tuple => Compose (Tuple tuple) (Compose a, Compose b) => Compose (a, b) (Compose sh, ~ * (Composed sh) (T (Tag (Composed sh)) (Rank (Composed sh))), Compose s, ~ * (Composed s) Int) => Compose (:. sh s) (Compose a, Compose b, Compose c) => Compose (a, b, c) (Compose a, Compose b, Compose c, Compose d) => Compose (a, b, c, d)

class ~ * (Composed (Decomposed Exp pattern)) (PatternTuple pattern) => Decompose pattern where

Methods

decompose :: pattern -> Exp (PatternTuple pattern) -> Decomposed Exp pattern

Analogous to `decompose`.

Instances

 Decompose () Decompose p => Decompose (Complex p) Decompose pn => Decompose (ZeroBased pn) Decompose (Enumeration enum) Decompose (Atom a) Decompose p => Decompose (Tuple p) (Decompose pa, Decompose pb) => Decompose (pa, pb) (Decompose sh, Decompose s, ~ * (Decomposed Exp s) (Exp Int), ~ * (PatternTuple s) Int, ~ * (PatternTuple sh) (T (AtomTag sh) (AtomRank sh)), Natural (AtomRank sh)) => Decompose (:. sh s) (Decompose pa, Decompose pb, Decompose pc) => Decompose (pa, pb, pc) (Decompose pa, Decompose pb, Decompose pc, Decompose pd) => Decompose (pa, pb, pc, pd)

modify :: (Compose a, Decompose pattern) => pattern -> (Decomposed Exp pattern -> a) -> Exp (PatternTuple pattern) -> Exp (Composed a)

Analogus to `modifyMultiValue`.

modify2 :: (Compose a, Decompose patternA, Decompose patternB) => patternA -> patternB -> (Decomposed Exp patternA -> Decomposed Exp patternB -> a) -> Exp (PatternTuple patternA) -> Exp (PatternTuple patternB) -> Exp (Composed a)

consComplex :: Exp a -> Exp a -> Exp (Complex a)

You can construct complex numbers this way, but they will not make you happy, because the numeric operations require a RealFloat instance that we could only provide with lots of undefined methods (also in its superclasses). You may either define your own arithmetic or use the NumericPrelude type classes.

deconsComplex :: Exp (Complex a) -> (Exp a, Exp a)

cons :: C a => a -> Exp a

unit :: Exp ()

zero :: C a => Exp a

add :: Additive a => Exp a -> Exp a -> Exp a

sub :: Additive a => Exp a -> Exp a -> Exp a

mul :: PseudoRing a => Exp a -> Exp a -> Exp a

sqr :: PseudoRing a => Exp a -> Exp a

sqrt :: Algebraic a => Exp a -> Exp a

idiv :: Integral a => Exp a -> Exp a -> Exp a

irem :: Integral a => Exp a -> Exp a -> Exp a

shl :: BitShift a => Exp a -> Exp a -> Exp a

shr :: BitShift a => Exp a -> Exp a -> Exp a

fromFastMath :: Exp (Number flags a) -> Exp a

toFastMath :: Exp a -> Exp (Number flags a)

minBound :: Bounded a => Exp a

maxBound :: Bounded a => Exp a

cmp :: Comparison a => CmpPredicate -> Exp a -> Exp a -> Exp Bool

(==*) :: Comparison a => Exp a -> Exp a -> Exp Bool

(/=*) :: Comparison a => Exp a -> Exp a -> Exp Bool

(<*) :: Comparison a => Exp a -> Exp a -> Exp Bool

(>=*) :: Comparison a => Exp a -> Exp a -> Exp Bool

(>*) :: Comparison a => Exp a -> Exp a -> Exp Bool

(<=*) :: Comparison a => Exp a -> Exp a -> Exp Bool

min :: Real a => Exp a -> Exp a -> Exp a

max :: Real a => Exp a -> Exp a -> Exp a

select :: Select a => Exp Bool -> Exp a -> Exp a -> Exp a

Like `ifThenElse` but computes both alternative expressions and then uses LLVM's efficient `select` instruction.

ifThenElse :: C a => Exp Bool -> Exp a -> Exp a -> Exp a

complement :: Logic a => Exp a -> Exp a

(.&.*) :: Logic a => Exp a -> Exp a -> Exp a

(.|.*) :: Logic a => Exp a -> Exp a -> Exp a

xor :: Logic a => Exp a -> Exp a -> Exp a

toMaybe :: Exp Bool -> Exp a -> Exp (Maybe a)

maybe :: C b => Exp b -> (Exp a -> Exp b) -> Exp (Maybe a) -> Exp b