{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
module Data.Array.Accelerate.Language (
use, unit, replicate, generate,
reshape,
slice,
map, zipWith,
fold, fold1, foldSeg', fold1Seg',
scanl, scanl', scanl1, scanr, scanr', scanr1,
permute, backpermute,
stencil, stencil2,
Boundary, Stencil,
clamp, mirror, wrap, function,
Stencil3, Stencil5, Stencil7, Stencil9,
Stencil3x3, Stencil5x3, Stencil3x5, Stencil5x5,
Stencil3x3x3, Stencil5x3x3, Stencil3x5x3, Stencil3x3x5, Stencil5x5x3, Stencil5x3x5,
Stencil3x5x5, Stencil5x5x5,
foreignAcc,
foreignExp,
(>->),
indexHead, indexTail, toIndex, fromIndex,
intersect, union,
acond, awhile,
cond, while,
(!), (!!), shape, size, shapeSize,
subtract, even, odd, gcd, lcm, (^), (^^),
ord, chr, boolToInt, bitcast,
) where
import Data.Array.Accelerate.AST ( PrimFun(..) )
import Data.Array.Accelerate.Pattern
import Data.Array.Accelerate.Representation.Array ( ArrayR(..) )
import Data.Array.Accelerate.Representation.Shape ( ShapeR(..) )
import Data.Array.Accelerate.Representation.Type
import Data.Array.Accelerate.Smart hiding ( arraysR )
import Data.Array.Accelerate.Sugar.Array ( Arrays(..), Array, Scalar, Segments, arrayR )
import Data.Array.Accelerate.Sugar.Elt
import Data.Array.Accelerate.Sugar.Foreign
import Data.Array.Accelerate.Sugar.Shape ( Shape(..), Slice(..), (:.) )
import Data.Array.Accelerate.Type
import qualified Data.Array.Accelerate.Representation.Array as R
import Data.Array.Accelerate.Classes.Eq
import Data.Array.Accelerate.Classes.Fractional
import Data.Array.Accelerate.Classes.Integral
import Data.Array.Accelerate.Classes.Num
import Data.Array.Accelerate.Classes.Ord
import Prelude ( ($), (.), Maybe(..), Char )
use :: forall arrays. Arrays arrays => arrays -> Acc arrays
use :: arrays -> Acc arrays
use = SmartAcc (ArraysR arrays) -> Acc arrays
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR arrays) -> Acc arrays)
-> (arrays -> SmartAcc (ArraysR arrays)) -> arrays -> Acc arrays
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ArraysR (ArraysR arrays)
-> ArraysR arrays -> SmartAcc (ArraysR arrays)
forall a. ArraysR a -> a -> SmartAcc a
use' (Arrays arrays => ArraysR (ArraysR arrays)
forall a. Arrays a => ArraysR (ArraysR a)
arraysR @arrays) (ArraysR arrays -> SmartAcc (ArraysR arrays))
-> (arrays -> ArraysR arrays)
-> arrays
-> SmartAcc (ArraysR arrays)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. arrays -> ArraysR arrays
forall a. Arrays a => a -> ArraysR a
fromArr
where
use' :: R.ArraysR a -> a -> SmartAcc a
use' :: ArraysR a -> a -> SmartAcc a
use' ArraysR a
TupRunit () = PreSmartAcc SmartAcc SmartExp () -> SmartAcc ()
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp () -> SmartAcc ())
-> PreSmartAcc SmartAcc SmartExp () -> SmartAcc ()
forall a b. (a -> b) -> a -> b
$ PreSmartAcc SmartAcc SmartExp ()
forall (acc :: * -> *) (exp :: * -> *). PreSmartAcc acc exp ()
Anil
use' (TupRsingle repr :: ArrayR a
repr@ArrayR{}) a
a = PreSmartAcc SmartAcc SmartExp (Array sh e) -> SmartAcc (Array sh e)
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (Array sh e)
-> SmartAcc (Array sh e))
-> PreSmartAcc SmartAcc SmartExp (Array sh e)
-> SmartAcc (Array sh e)
forall a b. (a -> b) -> a -> b
$ ArrayR (Array sh e)
-> Array sh e -> PreSmartAcc SmartAcc SmartExp (Array sh e)
forall sh e (acc :: * -> *) (exp :: * -> *).
ArrayR (Array sh e)
-> Array sh e -> PreSmartAcc acc exp (Array sh e)
Use ArrayR a
ArrayR (Array sh e)
repr a
Array sh e
a
use' (TupRpair TupR ArrayR a
r1 TupR ArrayR b
r2) (a1, a2) = PreSmartAcc SmartAcc SmartExp (a, b) -> SmartAcc (a, b)
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (a, b) -> SmartAcc (a, b))
-> PreSmartAcc SmartAcc SmartExp (a, b) -> SmartAcc (a, b)
forall a b. (a -> b) -> a -> b
$ TupR ArrayR a -> a -> SmartAcc a
forall a. ArraysR a -> a -> SmartAcc a
use' TupR ArrayR a
r1 a
a1 SmartAcc a -> SmartAcc b -> PreSmartAcc SmartAcc SmartExp (a, b)
forall (acc :: * -> *) arrs1 arrs2 (exp :: * -> *).
acc arrs1 -> acc arrs2 -> PreSmartAcc acc exp (arrs1, arrs2)
`Apair` TupR ArrayR b -> b -> SmartAcc b
forall a. ArraysR a -> a -> SmartAcc a
use' TupR ArrayR b
r2 b
a2
unit :: forall e. Elt e => Exp e -> Acc (Scalar e)
unit :: Exp e -> Acc (Scalar e)
unit (Exp SmartExp (EltR e)
e) = SmartAcc (ArraysR (Scalar e)) -> Acc (Scalar e)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR (Scalar e)) -> Acc (Scalar e))
-> SmartAcc (ArraysR (Scalar e)) -> Acc (Scalar e)
forall a b. (a -> b) -> a -> b
$ PreSmartAcc SmartAcc SmartExp (Scalar (EltR e))
-> SmartAcc (Scalar (EltR e))
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (Scalar (EltR e))
-> SmartAcc (Scalar (EltR e)))
-> PreSmartAcc SmartAcc SmartExp (Scalar (EltR e))
-> SmartAcc (Scalar (EltR e))
forall a b. (a -> b) -> a -> b
$ TypeR (EltR e)
-> SmartExp (EltR e)
-> PreSmartAcc SmartAcc SmartExp (Scalar (EltR e))
forall e (exp :: * -> *) (acc :: * -> *).
TypeR e -> exp e -> PreSmartAcc acc exp (Scalar e)
Unit (Elt e => TypeR (EltR e)
forall a. Elt a => TypeR (EltR a)
eltR @e) SmartExp (EltR e)
e
replicate
:: forall slix e.
(Slice slix, Elt e)
=> Exp slix
-> Acc (Array (SliceShape slix) e)
-> Acc (Array (FullShape slix) e)
replicate :: Exp slix
-> Acc (Array (SliceShape slix) e)
-> Acc (Array (FullShape slix) e)
replicate = SmartAcc (Array (EltR (FullShape slix)) (EltR e))
-> Acc (Array (FullShape slix) e)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR (FullShape slix)) (EltR e))
-> Acc (Array (FullShape slix) e))
-> (Exp slix
-> Acc (Array (SliceShape slix) e)
-> SmartAcc (Array (EltR (FullShape slix)) (EltR e)))
-> Exp slix
-> Acc (Array (SliceShape slix) e)
-> Acc (Array (FullShape slix) e)
forall b a c d. (b -> a) -> (c -> d -> b) -> c -> d -> a
$$ FromApplyAcc
(Exp slix
-> Acc (Array (SliceShape slix) e)
-> SmartAcc (Array (EltR (FullShape slix)) (EltR e)))
-> Exp slix
-> Acc (Array (SliceShape slix) e)
-> SmartAcc (Array (EltR (FullShape slix)) (EltR e))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (SliceIndex
(EltR slix)
(EltR (SliceShape slix))
(EltR (CoSliceShape slix))
(EltR (FullShape slix))
-> SmartExp (EltR slix)
-> SmartAcc (Array (EltR (SliceShape slix)) (EltR e))
-> PreSmartAcc
SmartAcc SmartExp (Array (EltR (FullShape slix)) (EltR e))
forall slix sl co sh (exp :: * -> *) (acc :: * -> *) e.
SliceIndex slix sl co sh
-> exp slix -> acc (Array sl e) -> PreSmartAcc acc exp (Array sh e)
Replicate (SliceIndex
(EltR slix)
(EltR (SliceShape slix))
(EltR (CoSliceShape slix))
(EltR (FullShape slix))
-> SmartExp (EltR slix)
-> SmartAcc (Array (EltR (SliceShape slix)) (EltR e))
-> PreSmartAcc
SmartAcc SmartExp (Array (EltR (FullShape slix)) (EltR e)))
-> SliceIndex
(EltR slix)
(EltR (SliceShape slix))
(EltR (CoSliceShape slix))
(EltR (FullShape slix))
-> SmartExp (EltR slix)
-> SmartAcc (Array (EltR (SliceShape slix)) (EltR e))
-> PreSmartAcc
SmartAcc SmartExp (Array (EltR (FullShape slix)) (EltR e))
forall a b. (a -> b) -> a -> b
$ Slice slix =>
SliceIndex
(EltR slix)
(EltR (SliceShape slix))
(EltR (CoSliceShape slix))
(EltR (FullShape slix))
forall sl.
Slice sl =>
SliceIndex
(EltR sl)
(EltR (SliceShape sl))
(EltR (CoSliceShape sl))
(EltR (FullShape sl))
sliceIndex @slix)
generate
:: forall sh a.
(Shape sh, Elt a)
=> Exp sh
-> (Exp sh -> Exp a)
-> Acc (Array sh a)
generate :: Exp sh -> (Exp sh -> Exp a) -> Acc (Array sh a)
generate = SmartAcc (Array (EltR sh) (EltR a)) -> Acc (Array sh a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh) (EltR a)) -> Acc (Array sh a))
-> (Exp sh
-> (Exp sh -> Exp a) -> SmartAcc (Array (EltR sh) (EltR a)))
-> Exp sh
-> (Exp sh -> Exp a)
-> Acc (Array sh a)
forall b a c d. (b -> a) -> (c -> d -> b) -> c -> d -> a
$$ FromApplyAcc
(Exp sh
-> (Exp sh -> Exp a) -> SmartAcc (Array (EltR sh) (EltR a)))
-> Exp sh
-> (Exp sh -> Exp a)
-> SmartAcc (Array (EltR sh) (EltR a))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (ArrayR (Array (EltR sh) (EltR a))
-> SmartExp (EltR sh)
-> (SmartExp (EltR sh) -> SmartExp (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR a))
forall sh e (exp :: * -> *) (acc :: * -> *).
ArrayR (Array sh e)
-> exp sh
-> (SmartExp sh -> exp e)
-> PreSmartAcc acc exp (Array sh e)
Generate (ArrayR (Array (EltR sh) (EltR a))
-> SmartExp (EltR sh)
-> (SmartExp (EltR sh) -> SmartExp (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR a)))
-> ArrayR (Array (EltR sh) (EltR a))
-> SmartExp (EltR sh)
-> (SmartExp (EltR sh) -> SmartExp (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR a))
forall a b. (a -> b) -> a -> b
$ (Shape sh, Elt a) => ArrayR (Array (EltR sh) (EltR a))
forall sh e. (Shape sh, Elt e) => ArrayR (Array (EltR sh) (EltR e))
arrayR @sh @a)
reshape
:: forall sh sh' e.
(Shape sh, Shape sh', Elt e)
=> Exp sh
-> Acc (Array sh' e)
-> Acc (Array sh e)
reshape :: Exp sh -> Acc (Array sh' e) -> Acc (Array sh e)
reshape = SmartAcc (Array (EltR sh) (EltR e)) -> Acc (Array sh e)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh) (EltR e)) -> Acc (Array sh e))
-> (Exp sh
-> Acc (Array sh' e) -> SmartAcc (Array (EltR sh) (EltR e)))
-> Exp sh
-> Acc (Array sh' e)
-> Acc (Array sh e)
forall b a c d. (b -> a) -> (c -> d -> b) -> c -> d -> a
$$ FromApplyAcc
(Exp sh
-> Acc (Array sh' e) -> SmartAcc (Array (EltR sh) (EltR e)))
-> Exp sh
-> Acc (Array sh' e)
-> SmartAcc (Array (EltR sh) (EltR e))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (ShapeR (EltR sh)
-> SmartExp (EltR sh)
-> SmartAcc (Array (EltR sh') (EltR e))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR e))
forall sh (exp :: * -> *) (acc :: * -> *) sh' e.
ShapeR sh
-> exp sh -> acc (Array sh' e) -> PreSmartAcc acc exp (Array sh e)
Reshape (ShapeR (EltR sh)
-> SmartExp (EltR sh)
-> SmartAcc (Array (EltR sh') (EltR e))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR e)))
-> ShapeR (EltR sh)
-> SmartExp (EltR sh)
-> SmartAcc (Array (EltR sh') (EltR e))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR e))
forall a b. (a -> b) -> a -> b
$ Shape sh => ShapeR (EltR sh)
forall sh. Shape sh => ShapeR (EltR sh)
shapeR @sh)
slice :: forall slix e.
(Slice slix, Elt e)
=> Acc (Array (FullShape slix) e)
-> Exp slix
-> Acc (Array (SliceShape slix) e)
slice :: Acc (Array (FullShape slix) e)
-> Exp slix -> Acc (Array (SliceShape slix) e)
slice = SmartAcc (Array (EltR (SliceShape slix)) (EltR e))
-> Acc (Array (SliceShape slix) e)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR (SliceShape slix)) (EltR e))
-> Acc (Array (SliceShape slix) e))
-> (Acc (Array (FullShape slix) e)
-> Exp slix -> SmartAcc (Array (EltR (SliceShape slix)) (EltR e)))
-> Acc (Array (FullShape slix) e)
-> Exp slix
-> Acc (Array (SliceShape slix) e)
forall b a c d. (b -> a) -> (c -> d -> b) -> c -> d -> a
$$ FromApplyAcc
(Acc (Array (FullShape slix) e)
-> Exp slix -> SmartAcc (Array (EltR (SliceShape slix)) (EltR e)))
-> Acc (Array (FullShape slix) e)
-> Exp slix
-> SmartAcc (Array (EltR (SliceShape slix)) (EltR e))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (SliceIndex
(EltR slix)
(EltR (SliceShape slix))
(EltR (CoSliceShape slix))
(EltR (FullShape slix))
-> SmartAcc (Array (EltR (FullShape slix)) (EltR e))
-> SmartExp (EltR slix)
-> PreSmartAcc
SmartAcc SmartExp (Array (EltR (SliceShape slix)) (EltR e))
forall slix sl co sh (acc :: * -> *) e' (exp :: * -> *).
SliceIndex slix sl co sh
-> acc (Array sh e')
-> exp slix
-> PreSmartAcc acc exp (Array sl e')
Slice (SliceIndex
(EltR slix)
(EltR (SliceShape slix))
(EltR (CoSliceShape slix))
(EltR (FullShape slix))
-> SmartAcc (Array (EltR (FullShape slix)) (EltR e))
-> SmartExp (EltR slix)
-> PreSmartAcc
SmartAcc SmartExp (Array (EltR (SliceShape slix)) (EltR e)))
-> SliceIndex
(EltR slix)
(EltR (SliceShape slix))
(EltR (CoSliceShape slix))
(EltR (FullShape slix))
-> SmartAcc (Array (EltR (FullShape slix)) (EltR e))
-> SmartExp (EltR slix)
-> PreSmartAcc
SmartAcc SmartExp (Array (EltR (SliceShape slix)) (EltR e))
forall a b. (a -> b) -> a -> b
$ Slice slix =>
SliceIndex
(EltR slix)
(EltR (SliceShape slix))
(EltR (CoSliceShape slix))
(EltR (FullShape slix))
forall sl.
Slice sl =>
SliceIndex
(EltR sl)
(EltR (SliceShape sl))
(EltR (CoSliceShape sl))
(EltR (FullShape sl))
sliceIndex @slix)
map :: forall sh a b.
(Shape sh, Elt a, Elt b)
=> (Exp a -> Exp b)
-> Acc (Array sh a)
-> Acc (Array sh b)
map :: (Exp a -> Exp b) -> Acc (Array sh a) -> Acc (Array sh b)
map = SmartAcc (Array (EltR sh) (EltR b)) -> Acc (Array sh b)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh) (EltR b)) -> Acc (Array sh b))
-> ((Exp a -> Exp b)
-> Acc (Array sh a) -> SmartAcc (Array (EltR sh) (EltR b)))
-> (Exp a -> Exp b)
-> Acc (Array sh a)
-> Acc (Array sh b)
forall b a c d. (b -> a) -> (c -> d -> b) -> c -> d -> a
$$ FromApplyAcc
((Exp a -> Exp b)
-> Acc (Array sh a) -> SmartAcc (Array (EltR sh) (EltR b)))
-> (Exp a -> Exp b)
-> Acc (Array sh a)
-> SmartAcc (Array (EltR sh) (EltR b))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (TypeR (EltR a)
-> TypeR (EltR b)
-> (SmartExp (EltR a) -> SmartExp (EltR b))
-> SmartAcc (Array (EltR sh) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR b))
forall e e' (exp :: * -> *) (acc :: * -> *) sh.
TypeR e
-> TypeR e'
-> (SmartExp e -> exp e')
-> acc (Array sh e)
-> PreSmartAcc acc exp (Array sh e')
Map (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) (Elt b => TypeR (EltR b)
forall a. Elt a => TypeR (EltR a)
eltR @b))
zipWith :: forall sh a b c.
(Shape sh, Elt a, Elt b, Elt c)
=> (Exp a -> Exp b -> Exp c)
-> Acc (Array sh a)
-> Acc (Array sh b)
-> Acc (Array sh c)
zipWith :: (Exp a -> Exp b -> Exp c)
-> Acc (Array sh a) -> Acc (Array sh b) -> Acc (Array sh c)
zipWith = SmartAcc (Array (EltR sh) (EltR c)) -> Acc (Array sh c)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh) (EltR c)) -> Acc (Array sh c))
-> ((Exp a -> Exp b -> Exp c)
-> Acc (Array sh a)
-> Acc (Array sh b)
-> SmartAcc (Array (EltR sh) (EltR c)))
-> (Exp a -> Exp b -> Exp c)
-> Acc (Array sh a)
-> Acc (Array sh b)
-> Acc (Array sh c)
forall b a c d e.
(b -> a) -> (c -> d -> e -> b) -> c -> d -> e -> a
$$$ FromApplyAcc
((Exp a -> Exp b -> Exp c)
-> Acc (Array sh a)
-> Acc (Array sh b)
-> SmartAcc (Array (EltR sh) (EltR c)))
-> (Exp a -> Exp b -> Exp c)
-> Acc (Array sh a)
-> Acc (Array sh b)
-> SmartAcc (Array (EltR sh) (EltR c))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (TypeR (EltR a)
-> TypeR (EltR b)
-> TypeR (EltR c)
-> (SmartExp (EltR a) -> SmartExp (EltR b) -> SmartExp (EltR c))
-> SmartAcc (Array (EltR sh) (EltR a))
-> SmartAcc (Array (EltR sh) (EltR b))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR c))
forall e1 e2 e3 (exp :: * -> *) (acc :: * -> *) sh.
TypeR e1
-> TypeR e2
-> TypeR e3
-> (SmartExp e1 -> SmartExp e2 -> exp e3)
-> acc (Array sh e1)
-> acc (Array sh e2)
-> PreSmartAcc acc exp (Array sh e3)
ZipWith (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) (Elt b => TypeR (EltR b)
forall a. Elt a => TypeR (EltR a)
eltR @b) (Elt c => TypeR (EltR c)
forall a. Elt a => TypeR (EltR a)
eltR @c))
fold :: forall sh a.
(Shape sh, Elt a)
=> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh:.Int) a)
-> Acc (Array sh a)
fold :: (Exp a -> Exp a -> Exp a)
-> Exp a -> Acc (Array (sh :. Int) a) -> Acc (Array sh a)
fold Exp a -> Exp a -> Exp a
f (Exp SmartExp (EltR a)
x) = SmartAcc (Array (EltR sh) (EltR a)) -> Acc (Array sh a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh) (EltR a)) -> Acc (Array sh a))
-> (Acc (Array (sh :. Int) a)
-> SmartAcc (Array (EltR sh) (EltR a)))
-> Acc (Array (sh :. Int) a)
-> Acc (Array sh a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FromApplyAcc
(Acc (Array (sh :. Int) a) -> SmartAcc (Array (EltR sh) (EltR a)))
-> Acc (Array (sh :. Int) a) -> SmartAcc (Array (EltR sh) (EltR a))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> Maybe (SmartExp (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR a))
forall e (exp :: * -> *) (acc :: * -> *) i.
TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> Maybe (exp e)
-> acc (Array (i, Int) e)
-> PreSmartAcc acc exp (Array i e)
Fold (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) ((Exp a -> Exp a -> Exp a)
-> SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a)
forall a b c.
(Elt a, Elt b, Elt c) =>
(Exp a -> Exp b -> Exp c)
-> SmartExp (EltR a) -> SmartExp (EltR b) -> SmartExp (EltR c)
unExpBinaryFunction Exp a -> Exp a -> Exp a
f) (SmartExp (EltR a) -> Maybe (SmartExp (EltR a))
forall a. a -> Maybe a
Just SmartExp (EltR a)
x))
fold1 :: forall sh a.
(Shape sh, Elt a)
=> (Exp a -> Exp a -> Exp a)
-> Acc (Array (sh:.Int) a)
-> Acc (Array sh a)
fold1 :: (Exp a -> Exp a -> Exp a)
-> Acc (Array (sh :. Int) a) -> Acc (Array sh a)
fold1 Exp a -> Exp a -> Exp a
f = SmartAcc (Array (EltR sh) (EltR a)) -> Acc (Array sh a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh) (EltR a)) -> Acc (Array sh a))
-> (Acc (Array (sh :. Int) a)
-> SmartAcc (Array (EltR sh) (EltR a)))
-> Acc (Array (sh :. Int) a)
-> Acc (Array sh a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FromApplyAcc
(Acc (Array (sh :. Int) a) -> SmartAcc (Array (EltR sh) (EltR a)))
-> Acc (Array (sh :. Int) a) -> SmartAcc (Array (EltR sh) (EltR a))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> Maybe (SmartExp (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR a))
forall e (exp :: * -> *) (acc :: * -> *) i.
TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> Maybe (exp e)
-> acc (Array (i, Int) e)
-> PreSmartAcc acc exp (Array i e)
Fold (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) ((Exp a -> Exp a -> Exp a)
-> SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a)
forall a b c.
(Elt a, Elt b, Elt c) =>
(Exp a -> Exp b -> Exp c)
-> SmartExp (EltR a) -> SmartExp (EltR b) -> SmartExp (EltR c)
unExpBinaryFunction Exp a -> Exp a -> Exp a
f) Maybe (SmartExp (EltR a))
forall a. Maybe a
Nothing)
foldSeg'
:: forall sh a i.
(Shape sh, Elt a, Elt i, IsIntegral i, i ~ EltR i)
=> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh:.Int) a)
-> Acc (Segments i)
-> Acc (Array (sh:.Int) a)
foldSeg' :: (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> Acc (Segments i)
-> Acc (Array (sh :. Int) a)
foldSeg' Exp a -> Exp a -> Exp a
f (Exp SmartExp (EltR a)
x) = SmartAcc (Array (EltR sh, Int) (EltR a))
-> Acc (Array (sh :. Int) a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh, Int) (EltR a))
-> Acc (Array (sh :. Int) a))
-> (Acc (Array (sh :. Int) a)
-> Acc (Segments i) -> SmartAcc (Array (EltR sh, Int) (EltR a)))
-> Acc (Array (sh :. Int) a)
-> Acc (Segments i)
-> Acc (Array (sh :. Int) a)
forall b a c d. (b -> a) -> (c -> d -> b) -> c -> d -> a
$$ FromApplyAcc
(Acc (Array (sh :. Int) a)
-> Acc (Segments i) -> SmartAcc (Array (EltR sh, Int) (EltR a)))
-> Acc (Array (sh :. Int) a)
-> Acc (Segments i)
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (IntegralType i
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> Maybe (SmartExp (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Segments i)
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
forall i e (exp :: * -> *) (acc :: * -> *) sh.
IntegralType i
-> TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> Maybe (exp e)
-> acc (Array (sh, Int) e)
-> acc (Segments i)
-> PreSmartAcc acc exp (Array (sh, Int) e)
FoldSeg (IsIntegral i => IntegralType i
forall a. IsIntegral a => IntegralType a
integralType @i) (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) ((Exp a -> Exp a -> Exp a)
-> SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a)
forall a b c.
(Elt a, Elt b, Elt c) =>
(Exp a -> Exp b -> Exp c)
-> SmartExp (EltR a) -> SmartExp (EltR b) -> SmartExp (EltR c)
unExpBinaryFunction Exp a -> Exp a -> Exp a
f) (SmartExp (EltR a) -> Maybe (SmartExp (EltR a))
forall a. a -> Maybe a
Just SmartExp (EltR a)
x))
fold1Seg'
:: forall sh a i.
(Shape sh, Elt a, Elt i, IsIntegral i, i ~ EltR i)
=> (Exp a -> Exp a -> Exp a)
-> Acc (Array (sh:.Int) a)
-> Acc (Segments i)
-> Acc (Array (sh:.Int) a)
fold1Seg' :: (Exp a -> Exp a -> Exp a)
-> Acc (Array (sh :. Int) a)
-> Acc (Segments i)
-> Acc (Array (sh :. Int) a)
fold1Seg' Exp a -> Exp a -> Exp a
f = SmartAcc (Array (EltR sh, Int) (EltR a))
-> Acc (Array (sh :. Int) a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh, Int) (EltR a))
-> Acc (Array (sh :. Int) a))
-> (Acc (Array (sh :. Int) a)
-> Acc (Segments i) -> SmartAcc (Array (EltR sh, Int) (EltR a)))
-> Acc (Array (sh :. Int) a)
-> Acc (Segments i)
-> Acc (Array (sh :. Int) a)
forall b a c d. (b -> a) -> (c -> d -> b) -> c -> d -> a
$$ FromApplyAcc
(Acc (Array (sh :. Int) a)
-> Acc (Segments i) -> SmartAcc (Array (EltR sh, Int) (EltR a)))
-> Acc (Array (sh :. Int) a)
-> Acc (Segments i)
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (IntegralType i
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> Maybe (SmartExp (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Segments i)
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
forall i e (exp :: * -> *) (acc :: * -> *) sh.
IntegralType i
-> TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> Maybe (exp e)
-> acc (Array (sh, Int) e)
-> acc (Segments i)
-> PreSmartAcc acc exp (Array (sh, Int) e)
FoldSeg (IsIntegral i => IntegralType i
forall a. IsIntegral a => IntegralType a
integralType @i) (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) ((Exp a -> Exp a -> Exp a)
-> SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a)
forall a b c.
(Elt a, Elt b, Elt c) =>
(Exp a -> Exp b -> Exp c)
-> SmartExp (EltR a) -> SmartExp (EltR b) -> SmartExp (EltR c)
unExpBinaryFunction Exp a -> Exp a -> Exp a
f) Maybe (SmartExp (EltR a))
forall a. Maybe a
Nothing)
scanl :: forall sh a.
(Shape sh, Elt a)
=> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh:.Int) a)
-> Acc (Array (sh:.Int) a)
scanl :: (Exp a -> Exp a -> Exp a)
-> Exp a -> Acc (Array (sh :. Int) a) -> Acc (Array (sh :. Int) a)
scanl Exp a -> Exp a -> Exp a
f (Exp SmartExp (EltR a)
x) (Acc SmartAcc (ArraysR (Array (sh :. Int) a))
a) = SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a))
-> SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a)
forall a b. (a -> b) -> a -> b
$ PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a)))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a b. (a -> b) -> a -> b
$ Direction
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> Maybe (SmartExp (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
forall e (exp :: * -> *) (acc :: * -> *) e.
Direction
-> TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> Maybe (exp e)
-> acc (Array (e, Int) e)
-> PreSmartAcc acc exp (Array (e, Int) e)
Scan Direction
LeftToRight (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) ((Exp a -> Exp a -> Exp a)
-> SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a)
forall a b c.
(Elt a, Elt b, Elt c) =>
(Exp a -> Exp b -> Exp c)
-> SmartExp (EltR a) -> SmartExp (EltR b) -> SmartExp (EltR c)
unExpBinaryFunction Exp a -> Exp a -> Exp a
f) (SmartExp (EltR a) -> Maybe (SmartExp (EltR a))
forall a. a -> Maybe a
Just SmartExp (EltR a)
x) SmartAcc (Array (EltR sh, Int) (EltR a))
SmartAcc (ArraysR (Array (sh :. Int) a))
a
scanl' :: forall sh a.
(Shape sh, Elt a)
=> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh:.Int) a)
-> Acc (Array (sh:.Int) a, Array sh a)
scanl' :: (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> Acc (Array (sh :. Int) a, Array sh a)
scanl' = SmartAcc
(((), Array (EltR sh, Int) (EltR a)), Array (EltR sh) (EltR a))
-> Acc (Array (sh :. Int) a, Array sh a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc
(((), Array (EltR sh, Int) (EltR a)), Array (EltR sh) (EltR a))
-> Acc (Array (sh :. Int) a, Array sh a))
-> (SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
-> SmartAcc
(((), Array (EltR sh, Int) (EltR a)), Array (EltR sh) (EltR a)))
-> SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
-> Acc (Array (sh :. Int) a, Array sh a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SmartAcc (Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
-> SmartAcc
(((), Array (EltR sh, Int) (EltR a)), Array (EltR sh) (EltR a))
forall a b. SmartAcc (a, b) -> SmartAcc (((), a), b)
mkPairToTuple (SmartAcc (Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
-> Acc (Array (sh :. Int) a, Array sh a))
-> ((Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a)))
-> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> Acc (Array (sh :. Int) a, Array sh a)
forall b a c d e.
(b -> a) -> (c -> d -> e -> b) -> c -> d -> e -> a
$$$ FromApplyAcc
((Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a)))
-> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (Direction
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> SmartExp (EltR a)
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc
SmartAcc
SmartExp
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
forall e (exp :: * -> *) (acc :: * -> *) sh.
Direction
-> TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> exp e
-> acc (Array (sh, Int) e)
-> PreSmartAcc acc exp (Array (sh, Int) e, Array sh e)
Scan' Direction
LeftToRight (TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> SmartExp (EltR a)
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc
SmartAcc
SmartExp
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a)))
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> SmartExp (EltR a)
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc
SmartAcc
SmartExp
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
forall a b. (a -> b) -> a -> b
$ Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a)
scanl1 :: forall sh a.
(Shape sh, Elt a)
=> (Exp a -> Exp a -> Exp a)
-> Acc (Array (sh:.Int) a)
-> Acc (Array (sh:.Int) a)
scanl1 :: (Exp a -> Exp a -> Exp a)
-> Acc (Array (sh :. Int) a) -> Acc (Array (sh :. Int) a)
scanl1 Exp a -> Exp a -> Exp a
f (Acc SmartAcc (ArraysR (Array (sh :. Int) a))
a) = SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a))
-> SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a)
forall a b. (a -> b) -> a -> b
$ PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a)))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a b. (a -> b) -> a -> b
$ Direction
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> Maybe (SmartExp (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
forall e (exp :: * -> *) (acc :: * -> *) e.
Direction
-> TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> Maybe (exp e)
-> acc (Array (e, Int) e)
-> PreSmartAcc acc exp (Array (e, Int) e)
Scan Direction
LeftToRight (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) ((Exp a -> Exp a -> Exp a)
-> SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a)
forall a b c.
(Elt a, Elt b, Elt c) =>
(Exp a -> Exp b -> Exp c)
-> SmartExp (EltR a) -> SmartExp (EltR b) -> SmartExp (EltR c)
unExpBinaryFunction Exp a -> Exp a -> Exp a
f) Maybe (SmartExp (EltR a))
forall a. Maybe a
Nothing SmartAcc (Array (EltR sh, Int) (EltR a))
SmartAcc (ArraysR (Array (sh :. Int) a))
a
scanr :: forall sh a.
(Shape sh, Elt a)
=> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh:.Int) a)
-> Acc (Array (sh:.Int) a)
scanr :: (Exp a -> Exp a -> Exp a)
-> Exp a -> Acc (Array (sh :. Int) a) -> Acc (Array (sh :. Int) a)
scanr Exp a -> Exp a -> Exp a
f (Exp SmartExp (EltR a)
x) (Acc SmartAcc (ArraysR (Array (sh :. Int) a))
a) = SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a))
-> SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a)
forall a b. (a -> b) -> a -> b
$ PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a)))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a b. (a -> b) -> a -> b
$ Direction
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> Maybe (SmartExp (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
forall e (exp :: * -> *) (acc :: * -> *) e.
Direction
-> TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> Maybe (exp e)
-> acc (Array (e, Int) e)
-> PreSmartAcc acc exp (Array (e, Int) e)
Scan Direction
RightToLeft (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) ((Exp a -> Exp a -> Exp a)
-> SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a)
forall a b c.
(Elt a, Elt b, Elt c) =>
(Exp a -> Exp b -> Exp c)
-> SmartExp (EltR a) -> SmartExp (EltR b) -> SmartExp (EltR c)
unExpBinaryFunction Exp a -> Exp a -> Exp a
f) (SmartExp (EltR a) -> Maybe (SmartExp (EltR a))
forall a. a -> Maybe a
Just SmartExp (EltR a)
x) SmartAcc (Array (EltR sh, Int) (EltR a))
SmartAcc (ArraysR (Array (sh :. Int) a))
a
scanr' :: forall sh a.
(Shape sh, Elt a)
=> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh:.Int) a)
-> Acc (Array (sh:.Int) a, Array sh a)
scanr' :: (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> Acc (Array (sh :. Int) a, Array sh a)
scanr' = SmartAcc
(((), Array (EltR sh, Int) (EltR a)), Array (EltR sh) (EltR a))
-> Acc (Array (sh :. Int) a, Array sh a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc
(((), Array (EltR sh, Int) (EltR a)), Array (EltR sh) (EltR a))
-> Acc (Array (sh :. Int) a, Array sh a))
-> (SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
-> SmartAcc
(((), Array (EltR sh, Int) (EltR a)), Array (EltR sh) (EltR a)))
-> SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
-> Acc (Array (sh :. Int) a, Array sh a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SmartAcc (Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
-> SmartAcc
(((), Array (EltR sh, Int) (EltR a)), Array (EltR sh) (EltR a))
forall a b. SmartAcc (a, b) -> SmartAcc (((), a), b)
mkPairToTuple (SmartAcc (Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
-> Acc (Array (sh :. Int) a, Array sh a))
-> ((Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a)))
-> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> Acc (Array (sh :. Int) a, Array sh a)
forall b a c d e.
(b -> a) -> (c -> d -> e -> b) -> c -> d -> e -> a
$$$ FromApplyAcc
((Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a)))
-> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Acc (Array (sh :. Int) a)
-> SmartAcc
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (Direction
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> SmartExp (EltR a)
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc
SmartAcc
SmartExp
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
forall e (exp :: * -> *) (acc :: * -> *) sh.
Direction
-> TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> exp e
-> acc (Array (sh, Int) e)
-> PreSmartAcc acc exp (Array (sh, Int) e, Array sh e)
Scan' Direction
RightToLeft (TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> SmartExp (EltR a)
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc
SmartAcc
SmartExp
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a)))
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> SmartExp (EltR a)
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc
SmartAcc
SmartExp
(Array (EltR sh, Int) (EltR a), Array (EltR sh) (EltR a))
forall a b. (a -> b) -> a -> b
$ Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a)
scanr1 :: forall sh a.
(Shape sh, Elt a)
=> (Exp a -> Exp a -> Exp a)
-> Acc (Array (sh:.Int) a)
-> Acc (Array (sh:.Int) a)
scanr1 :: (Exp a -> Exp a -> Exp a)
-> Acc (Array (sh :. Int) a) -> Acc (Array (sh :. Int) a)
scanr1 Exp a -> Exp a -> Exp a
f (Acc SmartAcc (ArraysR (Array (sh :. Int) a))
a) = SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a))
-> SmartAcc (ArraysR (Array (sh :. Int) a))
-> Acc (Array (sh :. Int) a)
forall a b. (a -> b) -> a -> b
$ PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a)))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
forall a b. (a -> b) -> a -> b
$ Direction
-> TypeR (EltR a)
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> Maybe (SmartExp (EltR a))
-> SmartAcc (Array (EltR sh, Int) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh, Int) (EltR a))
forall e (exp :: * -> *) (acc :: * -> *) e.
Direction
-> TypeR e
-> (SmartExp e -> SmartExp e -> exp e)
-> Maybe (exp e)
-> acc (Array (e, Int) e)
-> PreSmartAcc acc exp (Array (e, Int) e)
Scan Direction
RightToLeft (Elt a => TypeR (EltR a)
forall a. Elt a => TypeR (EltR a)
eltR @a) ((Exp a -> Exp a -> Exp a)
-> SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a)
forall a b c.
(Elt a, Elt b, Elt c) =>
(Exp a -> Exp b -> Exp c)
-> SmartExp (EltR a) -> SmartExp (EltR b) -> SmartExp (EltR c)
unExpBinaryFunction Exp a -> Exp a -> Exp a
f) Maybe (SmartExp (EltR a))
forall a. Maybe a
Nothing SmartAcc (Array (EltR sh, Int) (EltR a))
SmartAcc (ArraysR (Array (sh :. Int) a))
a
permute
:: forall sh sh' a. (Shape sh, Shape sh', Elt a)
=> (Exp a -> Exp a -> Exp a)
-> Acc (Array sh' a)
-> (Exp sh -> Exp (Maybe sh'))
-> Acc (Array sh a)
-> Acc (Array sh' a)
permute :: (Exp a -> Exp a -> Exp a)
-> Acc (Array sh' a)
-> (Exp sh -> Exp (Maybe sh'))
-> Acc (Array sh a)
-> Acc (Array sh' a)
permute = SmartAcc (Array (EltR sh') (EltR a)) -> Acc (Array sh' a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh') (EltR a)) -> Acc (Array sh' a))
-> ((Exp a -> Exp a -> Exp a)
-> Acc (Array sh' a)
-> (Exp sh -> Exp (Maybe sh'))
-> Acc (Array sh a)
-> SmartAcc (Array (EltR sh') (EltR a)))
-> (Exp a -> Exp a -> Exp a)
-> Acc (Array sh' a)
-> (Exp sh -> Exp (Maybe sh'))
-> Acc (Array sh a)
-> Acc (Array sh' a)
forall b a c d e f.
(b -> a) -> (c -> d -> e -> f -> b) -> c -> d -> e -> f -> a
$$$$ FromApplyAcc
((Exp a -> Exp a -> Exp a)
-> Acc (Array sh' a)
-> (Exp sh -> Exp (Maybe sh'))
-> Acc (Array sh a)
-> SmartAcc (Array (EltR sh') (EltR a)))
-> (Exp a -> Exp a -> Exp a)
-> Acc (Array sh' a)
-> (Exp sh -> Exp (Maybe sh'))
-> Acc (Array sh a)
-> SmartAcc (Array (EltR sh') (EltR a))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (ArrayR (Array (EltR sh) (EltR a))
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> SmartAcc (Array (EltR sh') (EltR a))
-> (SmartExp (EltR sh) -> SmartExp (PrimMaybe (EltR sh')))
-> SmartAcc (Array (EltR sh) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh') (EltR a))
forall sh e (exp :: * -> *) (acc :: * -> *) sh'.
ArrayR (Array sh e)
-> (SmartExp e -> SmartExp e -> exp e)
-> acc (Array sh' e)
-> (SmartExp sh -> exp (PrimMaybe sh'))
-> acc (Array sh e)
-> PreSmartAcc acc exp (Array sh' e)
Permute (ArrayR (Array (EltR sh) (EltR a))
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> SmartAcc (Array (EltR sh') (EltR a))
-> (SmartExp (EltR sh) -> SmartExp (PrimMaybe (EltR sh')))
-> SmartAcc (Array (EltR sh) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh') (EltR a)))
-> ArrayR (Array (EltR sh) (EltR a))
-> (SmartExp (EltR a) -> SmartExp (EltR a) -> SmartExp (EltR a))
-> SmartAcc (Array (EltR sh') (EltR a))
-> (SmartExp (EltR sh) -> SmartExp (PrimMaybe (EltR sh')))
-> SmartAcc (Array (EltR sh) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh') (EltR a))
forall a b. (a -> b) -> a -> b
$ (Shape sh, Elt a) => ArrayR (Array (EltR sh) (EltR a))
forall sh e. (Shape sh, Elt e) => ArrayR (Array (EltR sh) (EltR e))
arrayR @sh @a)
backpermute
:: forall sh sh' a. (Shape sh, Shape sh', Elt a)
=> Exp sh'
-> (Exp sh' -> Exp sh)
-> Acc (Array sh a)
-> Acc (Array sh' a)
backpermute :: Exp sh'
-> (Exp sh' -> Exp sh) -> Acc (Array sh a) -> Acc (Array sh' a)
backpermute = SmartAcc (Array (EltR sh') (EltR a)) -> Acc (Array sh' a)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (Array (EltR sh') (EltR a)) -> Acc (Array sh' a))
-> (Exp sh'
-> (Exp sh' -> Exp sh)
-> Acc (Array sh a)
-> SmartAcc (Array (EltR sh') (EltR a)))
-> Exp sh'
-> (Exp sh' -> Exp sh)
-> Acc (Array sh a)
-> Acc (Array sh' a)
forall b a c d e.
(b -> a) -> (c -> d -> e -> b) -> c -> d -> e -> a
$$$ FromApplyAcc
(Exp sh'
-> (Exp sh' -> Exp sh)
-> Acc (Array sh a)
-> SmartAcc (Array (EltR sh') (EltR a)))
-> Exp sh'
-> (Exp sh' -> Exp sh)
-> Acc (Array sh a)
-> SmartAcc (Array (EltR sh') (EltR a))
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (ShapeR (EltR sh')
-> SmartExp (EltR sh')
-> (SmartExp (EltR sh') -> SmartExp (EltR sh))
-> SmartAcc (Array (EltR sh) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh') (EltR a))
forall sh' (exp :: * -> *) sh (acc :: * -> *) e.
ShapeR sh'
-> exp sh'
-> (SmartExp sh' -> exp sh)
-> acc (Array sh e)
-> PreSmartAcc acc exp (Array sh' e)
Backpermute (ShapeR (EltR sh')
-> SmartExp (EltR sh')
-> (SmartExp (EltR sh') -> SmartExp (EltR sh))
-> SmartAcc (Array (EltR sh) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh') (EltR a)))
-> ShapeR (EltR sh')
-> SmartExp (EltR sh')
-> (SmartExp (EltR sh') -> SmartExp (EltR sh))
-> SmartAcc (Array (EltR sh) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh') (EltR a))
forall a b. (a -> b) -> a -> b
$ Shape sh' => ShapeR (EltR sh')
forall sh. Shape sh => ShapeR (EltR sh)
shapeR @sh')
type Stencil3 a = (Exp a, Exp a, Exp a)
type Stencil5 a = (Exp a, Exp a, Exp a, Exp a, Exp a)
type Stencil7 a = (Exp a, Exp a, Exp a, Exp a, Exp a, Exp a, Exp a)
type Stencil9 a = (Exp a, Exp a, Exp a, Exp a, Exp a, Exp a, Exp a, Exp a, Exp a)
type Stencil3x3 a = (Stencil3 a, Stencil3 a, Stencil3 a)
type Stencil5x3 a = (Stencil5 a, Stencil5 a, Stencil5 a)
type Stencil3x5 a = (Stencil3 a, Stencil3 a, Stencil3 a, Stencil3 a, Stencil3 a)
type Stencil5x5 a = (Stencil5 a, Stencil5 a, Stencil5 a, Stencil5 a, Stencil5 a)
type Stencil3x3x3 a = (Stencil3x3 a, Stencil3x3 a, Stencil3x3 a)
type Stencil5x3x3 a = (Stencil5x3 a, Stencil5x3 a, Stencil5x3 a)
type Stencil3x5x3 a = (Stencil3x5 a, Stencil3x5 a, Stencil3x5 a)
type Stencil3x3x5 a = (Stencil3x3 a, Stencil3x3 a, Stencil3x3 a, Stencil3x3 a, Stencil3x3 a)
type Stencil5x5x3 a = (Stencil5x5 a, Stencil5x5 a, Stencil5x5 a)
type Stencil5x3x5 a = (Stencil5x3 a, Stencil5x3 a, Stencil5x3 a, Stencil5x3 a, Stencil5x3 a)
type Stencil3x5x5 a = (Stencil3x5 a, Stencil3x5 a, Stencil3x5 a, Stencil3x5 a, Stencil3x5 a)
type Stencil5x5x5 a = (Stencil5x5 a, Stencil5x5 a, Stencil5x5 a, Stencil5x5 a, Stencil5x5 a)
stencil
:: forall sh stencil a b.
(Stencil sh a stencil, Elt b)
=> (stencil -> Exp b)
-> Boundary (Array sh a)
-> Acc (Array sh a)
-> Acc (Array sh b)
stencil :: (stencil -> Exp b)
-> Boundary (Array sh a) -> Acc (Array sh a) -> Acc (Array sh b)
stencil stencil -> Exp b
f (Boundary PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
b) (Acc SmartAcc (ArraysR (Array sh a))
a)
= SmartAcc (ArraysR (Array sh b)) -> Acc (Array sh b)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR (Array sh b)) -> Acc (Array sh b))
-> SmartAcc (ArraysR (Array sh b)) -> Acc (Array sh b)
forall a b. (a -> b) -> a -> b
$ PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR b))
-> SmartAcc (Array (EltR sh) (EltR b))
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR b))
-> SmartAcc (Array (EltR sh) (EltR b)))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR b))
-> SmartAcc (Array (EltR sh) (EltR b))
forall a b. (a -> b) -> a -> b
$ StencilR (EltR sh) (EltR a) (StencilR sh stencil)
-> TypeR (EltR b)
-> (SmartExp (StencilR sh stencil) -> SmartExp (EltR b))
-> PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR a))
-> SmartAcc (Array (EltR sh) (EltR a))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR b))
forall sh a stencil sh (exp :: * -> *) (acc :: * -> *).
StencilR sh a stencil
-> TypeR sh
-> (SmartExp stencil -> exp sh)
-> PreBoundary acc exp (Array sh a)
-> acc (Array sh a)
-> PreSmartAcc acc exp (Array sh sh)
Stencil
(Stencil sh a stencil =>
StencilR (EltR sh) (EltR a) (StencilR sh stencil)
forall sh e stencil.
Stencil sh e stencil =>
StencilR (EltR sh) (EltR e) (StencilR sh stencil)
stencilR @sh @a @stencil)
(Elt b => TypeR (EltR b)
forall a. Elt a => TypeR (EltR a)
eltR @b)
(Exp b -> SmartExp (EltR b)
forall e. Exp e -> SmartExp (EltR e)
unExp (Exp b -> SmartExp (EltR b))
-> (SmartExp (StencilR sh stencil) -> Exp b)
-> SmartExp (StencilR sh stencil)
-> SmartExp (EltR b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. stencil -> Exp b
f (stencil -> Exp b)
-> (SmartExp (StencilR sh stencil) -> stencil)
-> SmartExp (StencilR sh stencil)
-> Exp b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Stencil sh a stencil => SmartExp (StencilR sh stencil) -> stencil
forall sh e stencil.
Stencil sh e stencil =>
SmartExp (StencilR sh stencil) -> stencil
stencilPrj @sh @a @stencil)
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR a))
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
b
SmartAcc (Array (EltR sh) (EltR a))
SmartAcc (ArraysR (Array sh a))
a
stencil2
:: forall sh stencil1 stencil2 a b c.
(Stencil sh a stencil1, Stencil sh b stencil2, Elt c)
=> (stencil1 -> stencil2 -> Exp c)
-> Boundary (Array sh a)
-> Acc (Array sh a)
-> Boundary (Array sh b)
-> Acc (Array sh b)
-> Acc (Array sh c)
stencil2 :: (stencil1 -> stencil2 -> Exp c)
-> Boundary (Array sh a)
-> Acc (Array sh a)
-> Boundary (Array sh b)
-> Acc (Array sh b)
-> Acc (Array sh c)
stencil2 stencil1 -> stencil2 -> Exp c
f (Boundary PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
b1) (Acc SmartAcc (ArraysR (Array sh a))
a1) (Boundary PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
b2) (Acc SmartAcc (ArraysR (Array sh b))
a2)
= SmartAcc (ArraysR (Array sh c)) -> Acc (Array sh c)
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR (Array sh c)) -> Acc (Array sh c))
-> SmartAcc (ArraysR (Array sh c)) -> Acc (Array sh c)
forall a b. (a -> b) -> a -> b
$ PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR c))
-> SmartAcc (Array (EltR sh) (EltR c))
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR c))
-> SmartAcc (Array (EltR sh) (EltR c)))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR c))
-> SmartAcc (Array (EltR sh) (EltR c))
forall a b. (a -> b) -> a -> b
$ StencilR (EltR sh) (EltR a) (StencilR sh stencil1)
-> StencilR (EltR sh) (EltR b) (StencilR sh stencil2)
-> TypeR (EltR c)
-> (SmartExp (StencilR sh stencil1)
-> SmartExp (StencilR sh stencil2) -> SmartExp (EltR c))
-> PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR a))
-> SmartAcc (Array (EltR sh) (EltR a))
-> PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR b))
-> SmartAcc (Array (EltR sh) (EltR b))
-> PreSmartAcc SmartAcc SmartExp (Array (EltR sh) (EltR c))
forall sh a stencil1 b stencil2 c (exp :: * -> *) (acc :: * -> *).
StencilR sh a stencil1
-> StencilR sh b stencil2
-> TypeR c
-> (SmartExp stencil1 -> SmartExp stencil2 -> exp c)
-> PreBoundary acc exp (Array sh a)
-> acc (Array sh a)
-> PreBoundary acc exp (Array sh b)
-> acc (Array sh b)
-> PreSmartAcc acc exp (Array sh c)
Stencil2
(Stencil sh a stencil1 =>
StencilR (EltR sh) (EltR a) (StencilR sh stencil1)
forall sh e stencil.
Stencil sh e stencil =>
StencilR (EltR sh) (EltR e) (StencilR sh stencil)
stencilR @sh @a @stencil1)
(Stencil sh b stencil2 =>
StencilR (EltR sh) (EltR b) (StencilR sh stencil2)
forall sh e stencil.
Stencil sh e stencil =>
StencilR (EltR sh) (EltR e) (StencilR sh stencil)
stencilR @sh @b @stencil2)
(Elt c => TypeR (EltR c)
forall a. Elt a => TypeR (EltR a)
eltR @c)
(\SmartExp (StencilR sh stencil1)
x SmartExp (StencilR sh stencil2)
y -> Exp c -> SmartExp (EltR c)
forall e. Exp e -> SmartExp (EltR e)
unExp (Exp c -> SmartExp (EltR c)) -> Exp c -> SmartExp (EltR c)
forall a b. (a -> b) -> a -> b
$ stencil1 -> stencil2 -> Exp c
f (SmartExp (StencilR sh stencil1) -> stencil1
forall sh e stencil.
Stencil sh e stencil =>
SmartExp (StencilR sh stencil) -> stencil
stencilPrj @sh @a @stencil1 SmartExp (StencilR sh stencil1)
x) (SmartExp (StencilR sh stencil2) -> stencil2
forall sh e stencil.
Stencil sh e stencil =>
SmartExp (StencilR sh stencil) -> stencil
stencilPrj @sh @b @stencil2 SmartExp (StencilR sh stencil2)
y))
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR a))
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
b1
SmartAcc (Array (EltR sh) (EltR a))
SmartAcc (ArraysR (Array sh a))
a1
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR b))
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
b2
SmartAcc (Array (EltR sh) (EltR b))
SmartAcc (ArraysR (Array sh b))
a2
clamp :: Boundary (Array sh e)
clamp :: Boundary (Array sh e)
clamp = PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e)
forall sh e.
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e)
Boundary PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
forall (acc :: * -> *) (exp :: * -> *) t. PreBoundary acc exp t
Clamp
mirror :: Boundary (Array sh e)
mirror :: Boundary (Array sh e)
mirror = PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e)
forall sh e.
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e)
Boundary PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
forall (acc :: * -> *) (exp :: * -> *) t. PreBoundary acc exp t
Mirror
wrap :: Boundary (Array sh e)
wrap :: Boundary (Array sh e)
wrap = PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e)
forall sh e.
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e)
Boundary PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
forall (acc :: * -> *) (exp :: * -> *) t. PreBoundary acc exp t
Wrap
function
:: forall sh e. (Shape sh, Elt e)
=> (Exp sh -> Exp e)
-> Boundary (Array sh e)
function :: (Exp sh -> Exp e) -> Boundary (Array sh e)
function Exp sh -> Exp e
f = PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e)
forall sh e.
PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e)
Boundary (PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e))
-> PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
-> Boundary (Array sh e)
forall a b. (a -> b) -> a -> b
$ (SmartExp (EltR sh) -> SmartExp (EltR e))
-> PreBoundary SmartAcc SmartExp (Array (EltR sh) (EltR e))
forall sh (exp :: * -> *) e (acc :: * -> *).
(SmartExp sh -> exp e) -> PreBoundary acc exp (Array sh e)
Function (SmartExp (EltR sh) -> SmartExp (EltR e)
f')
where
f' :: SmartExp (EltR sh) -> SmartExp (EltR e)
f' :: SmartExp (EltR sh) -> SmartExp (EltR e)
f' = Exp e -> SmartExp (EltR e)
forall e. Exp e -> SmartExp (EltR e)
unExp (Exp e -> SmartExp (EltR e))
-> (SmartExp (EltR sh) -> Exp e)
-> SmartExp (EltR sh)
-> SmartExp (EltR e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Exp sh -> Exp e
f (Exp sh -> Exp e)
-> (SmartExp (EltR sh) -> Exp sh) -> SmartExp (EltR sh) -> Exp e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SmartExp (EltR sh) -> Exp sh
forall t. SmartExp (EltR t) -> Exp t
Exp
foreignAcc
:: forall as bs asm. (Arrays as, Arrays bs, Foreign asm)
=> asm (ArraysR as -> ArraysR bs)
-> (Acc as -> Acc bs)
-> Acc as
-> Acc bs
foreignAcc :: asm (ArraysR as -> ArraysR bs)
-> (Acc as -> Acc bs) -> Acc as -> Acc bs
foreignAcc asm (ArraysR as -> ArraysR bs)
asm Acc as -> Acc bs
f (Acc SmartAcc (ArraysR as)
as) = SmartAcc (ArraysR bs) -> Acc bs
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR bs) -> Acc bs)
-> SmartAcc (ArraysR bs) -> Acc bs
forall a b. (a -> b) -> a -> b
$ PreSmartAcc SmartAcc SmartExp (ArraysR bs) -> SmartAcc (ArraysR bs)
forall a. PreSmartAcc SmartAcc SmartExp a -> SmartAcc a
SmartAcc (PreSmartAcc SmartAcc SmartExp (ArraysR bs)
-> SmartAcc (ArraysR bs))
-> PreSmartAcc SmartAcc SmartExp (ArraysR bs)
-> SmartAcc (ArraysR bs)
forall a b. (a -> b) -> a -> b
$ ArraysR (ArraysR bs)
-> asm (ArraysR as -> ArraysR bs)
-> (SmartAcc (ArraysR as) -> SmartAcc (ArraysR bs))
-> SmartAcc (ArraysR as)
-> PreSmartAcc SmartAcc SmartExp (ArraysR bs)
forall (asm :: * -> *) bs as (acc :: * -> *) (exp :: * -> *).
Foreign asm =>
ArraysR bs
-> asm (as -> bs)
-> (SmartAcc as -> SmartAcc bs)
-> acc as
-> PreSmartAcc acc exp bs
Aforeign (Arrays bs => ArraysR (ArraysR bs)
forall a. Arrays a => ArraysR (ArraysR a)
arraysR @bs) asm (ArraysR as -> ArraysR bs)
asm ((Acc as -> Acc bs)
-> SmartAcc (ArraysR as) -> SmartAcc (ArraysR bs)
forall a b.
(Arrays a, Arrays b) =>
(Acc a -> Acc b) -> SmartAcc (ArraysR a) -> SmartAcc (ArraysR b)
unAccFunction Acc as -> Acc bs
f) SmartAcc (ArraysR as)
as
foreignExp
:: forall x y asm. (Elt x, Elt y, Foreign asm)
=> asm (EltR x -> EltR y)
-> (Exp x -> Exp y)
-> Exp x
-> Exp y
foreignExp :: asm (EltR x -> EltR y) -> (Exp x -> Exp y) -> Exp x -> Exp y
foreignExp asm (EltR x -> EltR y)
asm Exp x -> Exp y
f (Exp SmartExp (EltR x)
x) = PreSmartExp SmartAcc SmartExp (EltR y) -> Exp y
forall t. PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
mkExp (PreSmartExp SmartAcc SmartExp (EltR y) -> Exp y)
-> PreSmartExp SmartAcc SmartExp (EltR y) -> Exp y
forall a b. (a -> b) -> a -> b
$ TypeR (EltR y)
-> asm (EltR x -> EltR y)
-> (SmartExp (EltR x) -> SmartExp (EltR y))
-> SmartExp (EltR x)
-> PreSmartExp SmartAcc SmartExp (EltR y)
forall (asm :: * -> *) y x (exp :: * -> *) (acc :: * -> *).
Foreign asm =>
TypeR y
-> asm (x -> y)
-> (SmartExp x -> SmartExp y)
-> exp x
-> PreSmartExp acc exp y
Foreign (Elt y => TypeR (EltR y)
forall a. Elt a => TypeR (EltR a)
eltR @y) asm (EltR x -> EltR y)
asm ((Exp x -> Exp y) -> SmartExp (EltR x) -> SmartExp (EltR y)
forall a b.
(Elt a, Elt b) =>
(Exp a -> Exp b) -> SmartExp (EltR a) -> SmartExp (EltR b)
unExpFunction Exp x -> Exp y
f) SmartExp (EltR x)
x
infixl 1 >->
(>->) :: forall a b c. (Arrays a, Arrays b, Arrays c) => (Acc a -> Acc b) -> (Acc b -> Acc c) -> (Acc a -> Acc c)
>-> :: (Acc a -> Acc b) -> (Acc b -> Acc c) -> Acc a -> Acc c
(>->) = SmartAcc (ArraysR c) -> Acc c
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR c) -> Acc c)
-> ((Acc a -> Acc b)
-> (Acc b -> Acc c) -> Acc a -> SmartAcc (ArraysR c))
-> (Acc a -> Acc b)
-> (Acc b -> Acc c)
-> Acc a
-> Acc c
forall b a c d e.
(b -> a) -> (c -> d -> e -> b) -> c -> d -> e -> a
$$$ FromApplyAcc
((Acc a -> Acc b)
-> (Acc b -> Acc c) -> Acc a -> SmartAcc (ArraysR c))
-> (Acc a -> Acc b)
-> (Acc b -> Acc c)
-> Acc a
-> SmartAcc (ArraysR c)
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (FromApplyAcc
((Acc a -> Acc b)
-> (Acc b -> Acc c) -> Acc a -> SmartAcc (ArraysR c))
-> (Acc a -> Acc b)
-> (Acc b -> Acc c)
-> Acc a
-> SmartAcc (ArraysR c))
-> FromApplyAcc
((Acc a -> Acc b)
-> (Acc b -> Acc c) -> Acc a -> SmartAcc (ArraysR c))
-> (Acc a -> Acc b)
-> (Acc b -> Acc c)
-> Acc a
-> SmartAcc (ArraysR c)
forall a b. (a -> b) -> a -> b
$ ArraysR (ArraysR a)
-> ArraysR (ArraysR b)
-> ArraysR (ArraysR c)
-> (SmartAcc (ArraysR a) -> SmartAcc (ArraysR b))
-> (SmartAcc (ArraysR b) -> SmartAcc (ArraysR c))
-> SmartAcc (ArraysR a)
-> PreSmartAcc SmartAcc SmartExp (ArraysR c)
forall as bs cs (acc :: * -> *) (exp :: * -> *).
ArraysR as
-> ArraysR bs
-> ArraysR cs
-> (SmartAcc as -> acc bs)
-> (SmartAcc bs -> acc cs)
-> acc as
-> PreSmartAcc acc exp cs
Pipe (Arrays a => ArraysR (ArraysR a)
forall a. Arrays a => ArraysR (ArraysR a)
arraysR @a) (Arrays b => ArraysR (ArraysR b)
forall a. Arrays a => ArraysR (ArraysR a)
arraysR @b) (Arrays c => ArraysR (ArraysR c)
forall a. Arrays a => ArraysR (ArraysR a)
arraysR @c)
acond :: Arrays a
=> Exp Bool
-> Acc a
-> Acc a
-> Acc a
acond :: Exp Bool -> Acc a -> Acc a -> Acc a
acond (Exp SmartExp (EltR Bool)
p) = SmartAcc (ArraysR a) -> Acc a
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR a) -> Acc a)
-> (Acc a -> Acc a -> SmartAcc (ArraysR a))
-> Acc a
-> Acc a
-> Acc a
forall b a c d. (b -> a) -> (c -> d -> b) -> c -> d -> a
$$ FromApplyAcc (Acc a -> Acc a -> SmartAcc (ArraysR a))
-> Acc a -> Acc a -> SmartAcc (ArraysR a)
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (FromApplyAcc (Acc a -> Acc a -> SmartAcc (ArraysR a))
-> Acc a -> Acc a -> SmartAcc (ArraysR a))
-> FromApplyAcc (Acc a -> Acc a -> SmartAcc (ArraysR a))
-> Acc a
-> Acc a
-> SmartAcc (ArraysR a)
forall a b. (a -> b) -> a -> b
$ SmartExp PrimBool
-> SmartAcc (ArraysR a)
-> SmartAcc (ArraysR a)
-> PreSmartAcc SmartAcc SmartExp (ArraysR a)
forall (exp :: * -> *) (acc :: * -> *) as.
exp PrimBool -> acc as -> acc as -> PreSmartAcc acc exp as
Acond (SmartExp (PrimBool, ()) -> SmartExp PrimBool
forall a b. Coerce a b => SmartExp a -> SmartExp b
mkCoerce' SmartExp (PrimBool, ())
SmartExp (EltR Bool)
p)
awhile :: forall a. Arrays a
=> (Acc a -> Acc (Scalar Bool))
-> (Acc a -> Acc a)
-> Acc a
-> Acc a
awhile :: (Acc a -> Acc (Scalar Bool)) -> (Acc a -> Acc a) -> Acc a -> Acc a
awhile Acc a -> Acc (Scalar Bool)
f = SmartAcc (ArraysR a) -> Acc a
forall a. SmartAcc (ArraysR a) -> Acc a
Acc (SmartAcc (ArraysR a) -> Acc a)
-> ((Acc a -> Acc a) -> Acc a -> SmartAcc (ArraysR a))
-> (Acc a -> Acc a)
-> Acc a
-> Acc a
forall b a c d. (b -> a) -> (c -> d -> b) -> c -> d -> a
$$ FromApplyAcc ((Acc a -> Acc a) -> Acc a -> SmartAcc (ArraysR a))
-> (Acc a -> Acc a) -> Acc a -> SmartAcc (ArraysR a)
forall a. ApplyAcc a => FromApplyAcc a -> a
applyAcc (FromApplyAcc ((Acc a -> Acc a) -> Acc a -> SmartAcc (ArraysR a))
-> (Acc a -> Acc a) -> Acc a -> SmartAcc (ArraysR a))
-> FromApplyAcc ((Acc a -> Acc a) -> Acc a -> SmartAcc (ArraysR a))
-> (Acc a -> Acc a)
-> Acc a
-> SmartAcc (ArraysR a)
forall a b. (a -> b) -> a -> b
$ ArraysR (ArraysR a)
-> (SmartAcc (ArraysR a) -> SmartAcc (Scalar PrimBool))
-> (SmartAcc (ArraysR a) -> SmartAcc (ArraysR a))
-> SmartAcc (ArraysR a)
-> PreSmartAcc SmartAcc SmartExp (ArraysR a)
forall arrs (acc :: * -> *) (exp :: * -> *).
ArraysR arrs
-> (SmartAcc arrs -> acc (Scalar PrimBool))
-> (SmartAcc arrs -> acc arrs)
-> acc arrs
-> PreSmartAcc acc exp arrs
Awhile (Arrays a => ArraysR (ArraysR a)
forall a. Arrays a => ArraysR (ArraysR a)
arraysR @a) ((Acc a -> Acc (Scalar PrimBool))
-> SmartAcc (ArraysR a) -> SmartAcc (ArraysR (Scalar PrimBool))
forall a b.
(Arrays a, Arrays b) =>
(Acc a -> Acc b) -> SmartAcc (ArraysR a) -> SmartAcc (ArraysR b)
unAccFunction Acc a -> Acc (Scalar PrimBool)
g)
where
g :: Acc a -> Acc (Scalar PrimBool)
g :: Acc a -> Acc (Scalar PrimBool)
g = (Exp Bool -> Exp PrimBool)
-> Acc (Scalar Bool) -> Acc (Scalar PrimBool)
forall sh a b.
(Shape sh, Elt a, Elt b) =>
(Exp a -> Exp b) -> Acc (Array sh a) -> Acc (Array sh b)
map Exp Bool -> Exp PrimBool
forall a b. Coerce (EltR a) (EltR b) => Exp a -> Exp b
mkCoerce (Acc (Scalar Bool) -> Acc (Scalar PrimBool))
-> (Acc a -> Acc (Scalar Bool)) -> Acc a -> Acc (Scalar PrimBool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Acc a -> Acc (Scalar Bool)
f
toIndex
:: forall sh. Shape sh
=> Exp sh
-> Exp sh
-> Exp Int
toIndex :: Exp sh -> Exp sh -> Exp Int
toIndex (Exp SmartExp (EltR sh)
sh) (Exp SmartExp (EltR sh)
ix) = PreSmartExp SmartAcc SmartExp (EltR Int) -> Exp Int
forall t. PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
mkExp (PreSmartExp SmartAcc SmartExp (EltR Int) -> Exp Int)
-> PreSmartExp SmartAcc SmartExp (EltR Int) -> Exp Int
forall a b. (a -> b) -> a -> b
$ ShapeR (EltR sh)
-> SmartExp (EltR sh)
-> SmartExp (EltR sh)
-> PreSmartExp SmartAcc SmartExp Int
forall sh (exp :: * -> *) (acc :: * -> *).
ShapeR sh -> exp sh -> exp sh -> PreSmartExp acc exp Int
ToIndex (Shape sh => ShapeR (EltR sh)
forall sh. Shape sh => ShapeR (EltR sh)
shapeR @sh) SmartExp (EltR sh)
sh SmartExp (EltR sh)
ix
fromIndex :: forall sh. Shape sh => Exp sh -> Exp Int -> Exp sh
fromIndex :: Exp sh -> Exp Int -> Exp sh
fromIndex (Exp SmartExp (EltR sh)
sh) (Exp SmartExp (EltR Int)
e) = PreSmartExp SmartAcc SmartExp (EltR sh) -> Exp sh
forall t. PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
mkExp (PreSmartExp SmartAcc SmartExp (EltR sh) -> Exp sh)
-> PreSmartExp SmartAcc SmartExp (EltR sh) -> Exp sh
forall a b. (a -> b) -> a -> b
$ ShapeR (EltR sh)
-> SmartExp (EltR sh)
-> SmartExp Int
-> PreSmartExp SmartAcc SmartExp (EltR sh)
forall sh (exp :: * -> *) (acc :: * -> *).
ShapeR sh -> exp sh -> exp Int -> PreSmartExp acc exp sh
FromIndex (Shape sh => ShapeR (EltR sh)
forall sh. Shape sh => ShapeR (EltR sh)
shapeR @sh) SmartExp (EltR sh)
sh SmartExp Int
SmartExp (EltR Int)
e
intersect :: forall sh. Shape sh => Exp sh -> Exp sh -> Exp sh
intersect :: Exp sh -> Exp sh -> Exp sh
intersect (Exp SmartExp (EltR sh)
shx) (Exp SmartExp (EltR sh)
shy) = SmartExp (EltR sh) -> Exp sh
forall t. SmartExp (EltR t) -> Exp t
Exp (SmartExp (EltR sh) -> Exp sh) -> SmartExp (EltR sh) -> Exp sh
forall a b. (a -> b) -> a -> b
$ ShapeR (EltR sh)
-> SmartExp (EltR sh) -> SmartExp (EltR sh) -> SmartExp (EltR sh)
forall t. ShapeR t -> SmartExp t -> SmartExp t -> SmartExp t
intersect' (Shape sh => ShapeR (EltR sh)
forall sh. Shape sh => ShapeR (EltR sh)
shapeR @sh) SmartExp (EltR sh)
shx SmartExp (EltR sh)
shy
where
intersect' :: ShapeR t -> SmartExp t -> SmartExp t -> SmartExp t
intersect' :: ShapeR t -> SmartExp t -> SmartExp t -> SmartExp t
intersect' ShapeR t
ShapeRz SmartExp t
_ SmartExp t
_ = PreSmartExp SmartAcc SmartExp () -> SmartExp ()
forall t. PreSmartExp SmartAcc SmartExp t -> SmartExp t
SmartExp PreSmartExp SmartAcc SmartExp ()
forall (acc :: * -> *) (exp :: * -> *). PreSmartExp acc exp ()
Nil
intersect' (ShapeRsnoc ShapeR sh
shR) (SmartExp t -> (SmartExp sh, SmartExp Int)
forall a b. SmartExp (a, b) -> (SmartExp a, SmartExp b)
unPair -> (SmartExp sh
xs, SmartExp Int
x)) (SmartExp t -> (SmartExp sh, SmartExp Int)
forall a b. SmartExp (a, b) -> (SmartExp a, SmartExp b)
unPair -> (SmartExp sh
ys, SmartExp Int
y))
= PreSmartExp SmartAcc SmartExp (sh, Int) -> SmartExp (sh, Int)
forall t. PreSmartExp SmartAcc SmartExp t -> SmartExp t
SmartExp
(PreSmartExp SmartAcc SmartExp (sh, Int) -> SmartExp (sh, Int))
-> PreSmartExp SmartAcc SmartExp (sh, Int) -> SmartExp (sh, Int)
forall a b. (a -> b) -> a -> b
$ ShapeR sh -> SmartExp sh -> SmartExp sh -> SmartExp sh
forall t. ShapeR t -> SmartExp t -> SmartExp t -> SmartExp t
intersect' ShapeR sh
shR SmartExp sh
xs SmartExp sh
ys SmartExp sh
-> SmartExp Int -> PreSmartExp SmartAcc SmartExp (sh, Int)
forall (exp :: * -> *) t1 t2 (acc :: * -> *).
exp t1 -> exp t2 -> PreSmartExp acc exp (t1, t2)
`Pair`
PreSmartExp SmartAcc SmartExp Int -> SmartExp Int
forall t. PreSmartExp SmartAcc SmartExp t -> SmartExp t
SmartExp (PrimFun ((Int, Int) -> Int)
-> SmartExp (Int, Int) -> PreSmartExp SmartAcc SmartExp Int
forall a r (exp :: * -> *) (acc :: * -> *).
PrimFun (a -> r) -> exp a -> PreSmartExp acc exp r
PrimApp (SingleType Int -> PrimFun ((Int, Int) -> Int)
forall a. SingleType a -> PrimFun ((a, a) -> a)
PrimMin SingleType Int
forall a. IsSingle a => SingleType a
singleType) (SmartExp (Int, Int) -> PreSmartExp SmartAcc SmartExp Int)
-> SmartExp (Int, Int) -> PreSmartExp SmartAcc SmartExp Int
forall a b. (a -> b) -> a -> b
$ PreSmartExp SmartAcc SmartExp (Int, Int) -> SmartExp (Int, Int)
forall t. PreSmartExp SmartAcc SmartExp t -> SmartExp t
SmartExp (PreSmartExp SmartAcc SmartExp (Int, Int) -> SmartExp (Int, Int))
-> PreSmartExp SmartAcc SmartExp (Int, Int) -> SmartExp (Int, Int)
forall a b. (a -> b) -> a -> b
$ SmartExp Int
-> SmartExp Int -> PreSmartExp SmartAcc SmartExp (Int, Int)
forall (exp :: * -> *) t1 t2 (acc :: * -> *).
exp t1 -> exp t2 -> PreSmartExp acc exp (t1, t2)
Pair SmartExp Int
x SmartExp Int
y)
union :: forall sh. Shape sh => Exp sh -> Exp sh -> Exp sh
union :: Exp sh -> Exp sh -> Exp sh
union (Exp SmartExp (EltR sh)
shx) (Exp SmartExp (EltR sh)
shy) = SmartExp (EltR sh) -> Exp sh
forall t. SmartExp (EltR t) -> Exp t
Exp (SmartExp (EltR sh) -> Exp sh) -> SmartExp (EltR sh) -> Exp sh
forall a b. (a -> b) -> a -> b
$ ShapeR (EltR sh)
-> SmartExp (EltR sh) -> SmartExp (EltR sh) -> SmartExp (EltR sh)
forall t. ShapeR t -> SmartExp t -> SmartExp t -> SmartExp t
union' (Shape sh => ShapeR (EltR sh)
forall sh. Shape sh => ShapeR (EltR sh)
shapeR @sh) SmartExp (EltR sh)
shx SmartExp (EltR sh)
shy
where
union' :: ShapeR t -> SmartExp t -> SmartExp t -> SmartExp t
union' :: ShapeR t -> SmartExp t -> SmartExp t -> SmartExp t
union' ShapeR t
ShapeRz SmartExp t
_ SmartExp t
_ = PreSmartExp SmartAcc SmartExp () -> SmartExp ()
forall t. PreSmartExp SmartAcc SmartExp t -> SmartExp t
SmartExp PreSmartExp SmartAcc SmartExp ()
forall (acc :: * -> *) (exp :: * -> *). PreSmartExp acc exp ()
Nil
union' (ShapeRsnoc ShapeR sh
shR) (SmartExp t -> (SmartExp sh, SmartExp Int)
forall a b. SmartExp (a, b) -> (SmartExp a, SmartExp b)
unPair -> (SmartExp sh
xs, SmartExp Int
x)) (SmartExp t -> (SmartExp sh, SmartExp Int)
forall a b. SmartExp (a, b) -> (SmartExp a, SmartExp b)
unPair -> (SmartExp sh
ys, SmartExp Int
y))
= PreSmartExp SmartAcc SmartExp (sh, Int) -> SmartExp (sh, Int)
forall t. PreSmartExp SmartAcc SmartExp t -> SmartExp t
SmartExp
(PreSmartExp SmartAcc SmartExp (sh, Int) -> SmartExp (sh, Int))
-> PreSmartExp SmartAcc SmartExp (sh, Int) -> SmartExp (sh, Int)
forall a b. (a -> b) -> a -> b
$ ShapeR sh -> SmartExp sh -> SmartExp sh -> SmartExp sh
forall t. ShapeR t -> SmartExp t -> SmartExp t -> SmartExp t
union' ShapeR sh
shR SmartExp sh
xs SmartExp sh
ys SmartExp sh
-> SmartExp Int -> PreSmartExp SmartAcc SmartExp (sh, Int)
forall (exp :: * -> *) t1 t2 (acc :: * -> *).
exp t1 -> exp t2 -> PreSmartExp acc exp (t1, t2)
`Pair`
PreSmartExp SmartAcc SmartExp Int -> SmartExp Int
forall t. PreSmartExp SmartAcc SmartExp t -> SmartExp t
SmartExp (PrimFun ((Int, Int) -> Int)
-> SmartExp (Int, Int) -> PreSmartExp SmartAcc SmartExp Int
forall a r (exp :: * -> *) (acc :: * -> *).
PrimFun (a -> r) -> exp a -> PreSmartExp acc exp r
PrimApp (SingleType Int -> PrimFun ((Int, Int) -> Int)
forall a. SingleType a -> PrimFun ((a, a) -> a)
PrimMax SingleType Int
forall a. IsSingle a => SingleType a
singleType) (SmartExp (Int, Int) -> PreSmartExp SmartAcc SmartExp Int)
-> SmartExp (Int, Int) -> PreSmartExp SmartAcc SmartExp Int
forall a b. (a -> b) -> a -> b
$ PreSmartExp SmartAcc SmartExp (Int, Int) -> SmartExp (Int, Int)
forall t. PreSmartExp SmartAcc SmartExp t -> SmartExp t
SmartExp (PreSmartExp SmartAcc SmartExp (Int, Int) -> SmartExp (Int, Int))
-> PreSmartExp SmartAcc SmartExp (Int, Int) -> SmartExp (Int, Int)
forall a b. (a -> b) -> a -> b
$ SmartExp Int
-> SmartExp Int -> PreSmartExp SmartAcc SmartExp (Int, Int)
forall (exp :: * -> *) t1 t2 (acc :: * -> *).
exp t1 -> exp t2 -> PreSmartExp acc exp (t1, t2)
Pair SmartExp Int
x SmartExp Int
y)
cond :: Elt t
=> Exp Bool
-> Exp t
-> Exp t
-> Exp t
cond :: Exp Bool -> Exp t -> Exp t -> Exp t
cond (Exp SmartExp (EltR Bool)
c) (Exp SmartExp (EltR t)
x) (Exp SmartExp (EltR t)
y) = PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
forall t. PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
mkExp (PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t)
-> PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
forall a b. (a -> b) -> a -> b
$ SmartExp PrimBool
-> SmartExp (EltR t)
-> SmartExp (EltR t)
-> PreSmartExp SmartAcc SmartExp (EltR t)
forall (exp :: * -> *) t (acc :: * -> *).
exp PrimBool -> exp t -> exp t -> PreSmartExp acc exp t
Cond (SmartExp (PrimBool, ()) -> SmartExp PrimBool
forall a b. Coerce a b => SmartExp a -> SmartExp b
mkCoerce' SmartExp (PrimBool, ())
SmartExp (EltR Bool)
c) SmartExp (EltR t)
x SmartExp (EltR t)
y
while :: forall e. Elt e
=> (Exp e -> Exp Bool)
-> (Exp e -> Exp e)
-> Exp e
-> Exp e
while :: (Exp e -> Exp Bool) -> (Exp e -> Exp e) -> Exp e -> Exp e
while Exp e -> Exp Bool
c Exp e -> Exp e
f (Exp SmartExp (EltR e)
e) =
PreSmartExp SmartAcc SmartExp (EltR e) -> Exp e
forall t. PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
mkExp (PreSmartExp SmartAcc SmartExp (EltR e) -> Exp e)
-> PreSmartExp SmartAcc SmartExp (EltR e) -> Exp e
forall a b. (a -> b) -> a -> b
$ TypeR (EltR e)
-> (SmartExp (EltR e) -> SmartExp PrimBool)
-> (SmartExp (EltR e) -> SmartExp (EltR e))
-> SmartExp (EltR e)
-> PreSmartExp SmartAcc SmartExp (EltR e)
forall t (exp :: * -> *) (acc :: * -> *).
TypeR t
-> (SmartExp t -> exp PrimBool)
-> (SmartExp t -> exp t)
-> exp t
-> PreSmartExp acc exp t
While @(EltR e) (Elt e => TypeR (EltR e)
forall a. Elt a => TypeR (EltR a)
eltR @e)
(SmartExp (PrimBool, ()) -> SmartExp PrimBool
forall a b. Coerce a b => SmartExp a -> SmartExp b
mkCoerce' (SmartExp (PrimBool, ()) -> SmartExp PrimBool)
-> (SmartExp (EltR e) -> SmartExp (PrimBool, ()))
-> SmartExp (EltR e)
-> SmartExp PrimBool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Exp Bool -> SmartExp (PrimBool, ())
forall e. Exp e -> SmartExp (EltR e)
unExp (Exp Bool -> SmartExp (PrimBool, ()))
-> (SmartExp (EltR e) -> Exp Bool)
-> SmartExp (EltR e)
-> SmartExp (PrimBool, ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Exp e -> Exp Bool
c (Exp e -> Exp Bool)
-> (SmartExp (EltR e) -> Exp e) -> SmartExp (EltR e) -> Exp Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SmartExp (EltR e) -> Exp e
forall t. SmartExp (EltR t) -> Exp t
Exp)
(Exp e -> SmartExp (EltR e)
forall e. Exp e -> SmartExp (EltR e)
unExp (Exp e -> SmartExp (EltR e))
-> (SmartExp (EltR e) -> Exp e)
-> SmartExp (EltR e)
-> SmartExp (EltR e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Exp e -> Exp e
f (Exp e -> Exp e)
-> (SmartExp (EltR e) -> Exp e) -> SmartExp (EltR e) -> Exp e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SmartExp (EltR e) -> Exp e
forall t. SmartExp (EltR t) -> Exp t
Exp) SmartExp (EltR e)
e
infixl 9 !
(!) :: forall sh e. (Shape sh, Elt e) => Acc (Array sh e) -> Exp sh -> Exp e
Acc SmartAcc (ArraysR (Array sh e))
a ! :: Acc (Array sh e) -> Exp sh -> Exp e
! Exp SmartExp (EltR sh)
ix = PreSmartExp SmartAcc SmartExp (EltR e) -> Exp e
forall t. PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
mkExp (PreSmartExp SmartAcc SmartExp (EltR e) -> Exp e)
-> PreSmartExp SmartAcc SmartExp (EltR e) -> Exp e
forall a b. (a -> b) -> a -> b
$ TypeR (EltR e)
-> SmartAcc (Array (EltR sh) (EltR e))
-> SmartExp (EltR sh)
-> PreSmartExp SmartAcc SmartExp (EltR e)
forall t (acc :: * -> *) sh (exp :: * -> *).
TypeR t -> acc (Array sh t) -> exp sh -> PreSmartExp acc exp t
Index (Elt e => TypeR (EltR e)
forall a. Elt a => TypeR (EltR a)
eltR @e) SmartAcc (Array (EltR sh) (EltR e))
SmartAcc (ArraysR (Array sh e))
a SmartExp (EltR sh)
ix
infixl 9 !!
(!!) :: forall sh e. (Shape sh, Elt e) => Acc (Array sh e) -> Exp Int -> Exp e
Acc SmartAcc (ArraysR (Array sh e))
a !! :: Acc (Array sh e) -> Exp Int -> Exp e
!! Exp SmartExp (EltR Int)
ix = PreSmartExp SmartAcc SmartExp (EltR e) -> Exp e
forall t. PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
mkExp (PreSmartExp SmartAcc SmartExp (EltR e) -> Exp e)
-> PreSmartExp SmartAcc SmartExp (EltR e) -> Exp e
forall a b. (a -> b) -> a -> b
$ TypeR (EltR e)
-> SmartAcc (Array (EltR sh) (EltR e))
-> SmartExp Int
-> PreSmartExp SmartAcc SmartExp (EltR e)
forall t (acc :: * -> *) sh (exp :: * -> *).
TypeR t -> acc (Array sh t) -> exp Int -> PreSmartExp acc exp t
LinearIndex (Elt e => TypeR (EltR e)
forall a. Elt a => TypeR (EltR a)
eltR @e) SmartAcc (Array (EltR sh) (EltR e))
SmartAcc (ArraysR (Array sh e))
a SmartExp Int
SmartExp (EltR Int)
ix
shape :: forall sh e. (Shape sh, Elt e) => Acc (Array sh e) -> Exp sh
shape :: Acc (Array sh e) -> Exp sh
shape = PreSmartExp SmartAcc SmartExp (EltR sh) -> Exp sh
forall t. PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
mkExp (PreSmartExp SmartAcc SmartExp (EltR sh) -> Exp sh)
-> (Acc (Array sh e) -> PreSmartExp SmartAcc SmartExp (EltR sh))
-> Acc (Array sh e)
-> Exp sh
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShapeR (EltR sh)
-> SmartAcc (Array (EltR sh) (EltR e))
-> PreSmartExp SmartAcc SmartExp (EltR sh)
forall sh (acc :: * -> *) e (exp :: * -> *).
ShapeR sh -> acc (Array sh e) -> PreSmartExp acc exp sh
Shape (Shape sh => ShapeR (EltR sh)
forall sh. Shape sh => ShapeR (EltR sh)
shapeR @sh) (SmartAcc (Array (EltR sh) (EltR e))
-> PreSmartExp SmartAcc SmartExp (EltR sh))
-> (Acc (Array sh e) -> SmartAcc (Array (EltR sh) (EltR e)))
-> Acc (Array sh e)
-> PreSmartExp SmartAcc SmartExp (EltR sh)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Acc (Array sh e) -> SmartAcc (Array (EltR sh) (EltR e))
forall a. Arrays a => Acc a -> SmartAcc (ArraysR a)
unAcc
size :: (Shape sh, Elt e) => Acc (Array sh e) -> Exp Int
size :: Acc (Array sh e) -> Exp Int
size = Exp sh -> Exp Int
forall sh. Shape sh => Exp sh -> Exp Int
shapeSize (Exp sh -> Exp Int)
-> (Acc (Array sh e) -> Exp sh) -> Acc (Array sh e) -> Exp Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Acc (Array sh e) -> Exp sh
forall sh e. (Shape sh, Elt e) => Acc (Array sh e) -> Exp sh
shape
shapeSize :: forall sh. Shape sh => Exp sh -> Exp Int
shapeSize :: Exp sh -> Exp Int
shapeSize (Exp SmartExp (EltR sh)
sh) = PreSmartExp SmartAcc SmartExp (EltR Int) -> Exp Int
forall t. PreSmartExp SmartAcc SmartExp (EltR t) -> Exp t
mkExp (PreSmartExp SmartAcc SmartExp (EltR Int) -> Exp Int)
-> PreSmartExp SmartAcc SmartExp (EltR Int) -> Exp Int
forall a b. (a -> b) -> a -> b
$ ShapeR (EltR sh)
-> SmartExp (EltR sh) -> PreSmartExp SmartAcc SmartExp Int
forall sh (exp :: * -> *) (acc :: * -> *).
ShapeR sh -> exp sh -> PreSmartExp acc exp Int
ShapeSize (Shape sh => ShapeR (EltR sh)
forall sh. Shape sh => ShapeR (EltR sh)
shapeR @sh) SmartExp (EltR sh)
sh
subtract :: Num a => Exp a -> Exp a -> Exp a
subtract :: Exp a -> Exp a -> Exp a
subtract Exp a
x Exp a
y = Exp a
y Exp a -> Exp a -> Exp a
forall a. Num a => a -> a -> a
- Exp a
x
even :: Integral a => Exp a -> Exp Bool
even :: Exp a -> Exp Bool
even Exp a
n = Exp a
n Exp a -> Exp a -> Exp a
forall a. Integral a => a -> a -> a
`rem` Exp a
2 Exp a -> Exp a -> Exp Bool
forall a. Eq a => Exp a -> Exp a -> Exp Bool
== Exp a
0
odd :: Integral a => Exp a -> Exp Bool
odd :: Exp a -> Exp Bool
odd Exp a
n = Exp a
n Exp a -> Exp a -> Exp a
forall a. Integral a => a -> a -> a
`rem` Exp a
2 Exp a -> Exp a -> Exp Bool
forall a. Eq a => Exp a -> Exp a -> Exp Bool
/= Exp a
0
gcd :: Integral a => Exp a -> Exp a -> Exp a
gcd :: Exp a -> Exp a -> Exp a
gcd Exp a
x Exp a
y = Exp a -> Exp a -> Exp a
forall a. Integral a => Exp a -> Exp a -> Exp a
gcd' (Exp a -> Exp a
forall a. Num a => a -> a
abs Exp a
x) (Exp a -> Exp a
forall a. Num a => a -> a
abs Exp a
y)
where
gcd' :: Integral a => Exp a -> Exp a -> Exp a
gcd' :: Exp a -> Exp a -> Exp a
gcd' Exp a
u Exp a
v =
let T2 Exp a
r Exp a
_ = (Exp (a, a) -> Exp Bool)
-> (Exp (a, a) -> Exp (a, a)) -> Exp (a, a) -> Exp (a, a)
forall e.
Elt e =>
(Exp e -> Exp Bool) -> (Exp e -> Exp e) -> Exp e -> Exp e
while (\(T2 Exp a
_ Exp a
b) -> Exp a
b Exp a -> Exp a -> Exp Bool
forall a. Eq a => Exp a -> Exp a -> Exp Bool
/= Exp a
0)
(\(T2 Exp a
a Exp a
b) -> Exp a -> Exp a -> Exp (a, a)
forall (con :: * -> *) x0 x1.
IsPattern con (x0, x1) (con x0, con x1) =>
con x0 -> con x1 -> con (x0, x1)
T2 Exp a
b (Exp a
a Exp a -> Exp a -> Exp a
forall a. Integral a => a -> a -> a
`rem` Exp a
b))
(Exp a -> Exp a -> Exp (a, a)
forall (con :: * -> *) x0 x1.
IsPattern con (x0, x1) (con x0, con x1) =>
con x0 -> con x1 -> con (x0, x1)
T2 Exp a
u Exp a
v)
in Exp a
r
lcm :: Integral a => Exp a -> Exp a -> Exp a
lcm :: Exp a -> Exp a -> Exp a
lcm Exp a
x Exp a
y
= Exp Bool -> Exp a -> Exp a -> Exp a
forall t. Elt t => Exp Bool -> Exp t -> Exp t -> Exp t
cond (Exp a
x Exp a -> Exp a -> Exp Bool
forall a. Eq a => Exp a -> Exp a -> Exp Bool
== Exp a
0 Exp Bool -> Exp Bool -> Exp Bool
|| Exp a
y Exp a -> Exp a -> Exp Bool
forall a. Eq a => Exp a -> Exp a -> Exp Bool
== Exp a
0) Exp a
0
(Exp a -> Exp a) -> Exp a -> Exp a
forall a b. (a -> b) -> a -> b
$ Exp a -> Exp a
forall a. Num a => a -> a
abs ((Exp a
x Exp a -> Exp a -> Exp a
forall a. Integral a => a -> a -> a
`quot` (Exp a -> Exp a -> Exp a
forall a. Integral a => Exp a -> Exp a -> Exp a
gcd Exp a
x Exp a
y)) Exp a -> Exp a -> Exp a
forall a. Num a => a -> a -> a
* Exp a
y)
infixr 8 ^
(^) :: forall a b. (Num a, Integral b) => Exp a -> Exp b -> Exp a
Exp a
x0 ^ :: Exp a -> Exp b -> Exp a
^ Exp b
y0 = Exp Bool -> Exp a -> Exp a -> Exp a
forall t. Elt t => Exp Bool -> Exp t -> Exp t -> Exp t
cond (Exp b
y0 Exp b -> Exp b -> Exp Bool
forall a. Ord a => Exp a -> Exp a -> Exp Bool
<= Exp b
0) Exp a
1 (Exp a -> Exp b -> Exp a
f Exp a
x0 Exp b
y0)
where
f :: Exp a -> Exp b -> Exp a
f :: Exp a -> Exp b -> Exp a
f Exp a
x Exp b
y =
let T2 Exp a
x' Exp b
y' = (Exp (a, b) -> Exp Bool)
-> (Exp (a, b) -> Exp (a, b)) -> Exp (a, b) -> Exp (a, b)
forall e.
Elt e =>
(Exp e -> Exp Bool) -> (Exp e -> Exp e) -> Exp e -> Exp e
while (\(T2 Exp a
_ Exp b
v) -> Exp b -> Exp Bool
forall a. Integral a => Exp a -> Exp Bool
even Exp b
v)
(\(T2 Exp a
u Exp b
v) -> Exp a -> Exp b -> Exp (a, b)
forall (con :: * -> *) x0 x1.
IsPattern con (x0, x1) (con x0, con x1) =>
con x0 -> con x1 -> con (x0, x1)
T2 (Exp a
u Exp a -> Exp a -> Exp a
forall a. Num a => a -> a -> a
* Exp a
u) (Exp b
v Exp b -> Exp b -> Exp b
forall a. Integral a => a -> a -> a
`quot` Exp b
2))
(Exp a -> Exp b -> Exp (a, b)
forall (con :: * -> *) x0 x1.
IsPattern con (x0, x1) (con x0, con x1) =>
con x0 -> con x1 -> con (x0, x1)
T2 Exp a
x Exp b
y)
in
Exp Bool -> Exp a -> Exp a -> Exp a
forall t. Elt t => Exp Bool -> Exp t -> Exp t -> Exp t
cond (Exp b
y' Exp b -> Exp b -> Exp Bool
forall a. Eq a => Exp a -> Exp a -> Exp Bool
== Exp b
1) Exp a
x' (Exp a -> Exp b -> Exp a -> Exp a
g (Exp a
x'Exp a -> Exp a -> Exp a
forall a. Num a => a -> a -> a
*Exp a
x') ((Exp b
y'Exp b -> Exp b -> Exp b
forall a. Num a => a -> a -> a
-Exp b
1) Exp b -> Exp b -> Exp b
forall a. Integral a => a -> a -> a
`quot` Exp b
2) Exp a
x')
g :: Exp a -> Exp b -> Exp a -> Exp a
g :: Exp a -> Exp b -> Exp a -> Exp a
g Exp a
x Exp b
y Exp a
z =
let T3 Exp a
x' Exp b
_ Exp a
z' = (Exp (a, b, a) -> Exp Bool)
-> (Exp (a, b, a) -> Exp (a, b, a))
-> Exp (a, b, a)
-> Exp (a, b, a)
forall e.
Elt e =>
(Exp e -> Exp Bool) -> (Exp e -> Exp e) -> Exp e -> Exp e
while (\(T3 Exp a
_ Exp b
v Exp a
_) -> Exp b
v Exp b -> Exp b -> Exp Bool
forall a. Eq a => Exp a -> Exp a -> Exp Bool
/= Exp b
1)
(\(T3 Exp a
u Exp b
v Exp a
w) ->
Exp Bool -> Exp (a, b, a) -> Exp (a, b, a) -> Exp (a, b, a)
forall t. Elt t => Exp Bool -> Exp t -> Exp t -> Exp t
cond (Exp b -> Exp Bool
forall a. Integral a => Exp a -> Exp Bool
even Exp b
v) (Exp a -> Exp b -> Exp a -> Exp (a, b, a)
forall (con :: * -> *) x0 x1 x2.
IsPattern con (x0, x1, x2) (con x0, con x1, con x2) =>
con x0 -> con x1 -> con x2 -> con (x0, x1, x2)
T3 (Exp a
uExp a -> Exp a -> Exp a
forall a. Num a => a -> a -> a
*Exp a
u) (Exp b
v Exp b -> Exp b -> Exp b
forall a. Integral a => a -> a -> a
`quot` Exp b
2) Exp a
w)
(Exp a -> Exp b -> Exp a -> Exp (a, b, a)
forall (con :: * -> *) x0 x1 x2.
IsPattern con (x0, x1, x2) (con x0, con x1, con x2) =>
con x0 -> con x1 -> con x2 -> con (x0, x1, x2)
T3 (Exp a
uExp a -> Exp a -> Exp a
forall a. Num a => a -> a -> a
*Exp a
u) ((Exp b
vExp b -> Exp b -> Exp b
forall a. Num a => a -> a -> a
-Exp b
1) Exp b -> Exp b -> Exp b
forall a. Integral a => a -> a -> a
`quot` Exp b
2) (Exp a
wExp a -> Exp a -> Exp a
forall a. Num a => a -> a -> a
*Exp a
u)))
(Exp a -> Exp b -> Exp a -> Exp (a, b, a)
forall (con :: * -> *) x0 x1 x2.
IsPattern con (x0, x1, x2) (con x0, con x1, con x2) =>
con x0 -> con x1 -> con x2 -> con (x0, x1, x2)
T3 Exp a
x Exp b
y Exp a
z)
in
Exp a
x' Exp a -> Exp a -> Exp a
forall a. Num a => a -> a -> a
* Exp a
z'
infixr 8 ^^
(^^) :: (Fractional a, Integral b) => Exp a -> Exp b -> Exp a
Exp a
x ^^ :: Exp a -> Exp b -> Exp a
^^ Exp b
n
= Exp Bool -> Exp a -> Exp a -> Exp a
forall t. Elt t => Exp Bool -> Exp t -> Exp t -> Exp t
cond (Exp b
n Exp b -> Exp b -> Exp Bool
forall a. Ord a => Exp a -> Exp a -> Exp Bool
>= Exp b
0)
(Exp a
x Exp a -> Exp b -> Exp a
forall a b. (Num a, Integral b) => Exp a -> Exp b -> Exp a
^ Exp b
n)
(Exp a -> Exp a
forall a. Fractional a => a -> a
recip (Exp a
x Exp a -> Exp b -> Exp a
forall a b. (Num a, Integral b) => Exp a -> Exp b -> Exp a
^ (Exp b -> Exp b
forall a. Num a => a -> a
negate Exp b
n)))
ord :: Exp Char -> Exp Int
ord :: Exp Char -> Exp Int
ord = Exp Char -> Exp Int
forall a b.
(Elt a, Elt b, IsIntegral (EltR a), IsNum (EltR b)) =>
Exp a -> Exp b
mkFromIntegral
chr :: Exp Int -> Exp Char
chr :: Exp Int -> Exp Char
chr = Exp Int -> Exp Char
forall a b.
(Elt a, Elt b, IsIntegral (EltR a), IsNum (EltR b)) =>
Exp a -> Exp b
mkFromIntegral
boolToInt :: Exp Bool -> Exp Int
boolToInt :: Exp Bool -> Exp Int
boolToInt = Exp PrimBool -> Exp Int
forall a b.
(Elt a, Elt b, IsIntegral (EltR a), IsNum (EltR b)) =>
Exp a -> Exp b
mkFromIntegral (Exp PrimBool -> Exp Int)
-> (Exp Bool -> Exp PrimBool) -> Exp Bool -> Exp Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Coerce (EltR Bool) (EltR PrimBool) => Exp Bool -> Exp PrimBool
forall a b. Coerce (EltR a) (EltR b) => Exp a -> Exp b
mkCoerce @_ @Word8
bitcast
:: (Elt a, Elt b, IsScalar (EltR a), IsScalar (EltR b), BitSizeEq (EltR a) (EltR b))
=> Exp a
-> Exp b
bitcast :: Exp a -> Exp b
bitcast = Exp a -> Exp b
forall b a.
(Elt a, Elt b, IsScalar (EltR a), IsScalar (EltR b),
BitSizeEq (EltR a) (EltR b)) =>
Exp a -> Exp b
mkBitcast