module Data.Array.Parallel.Unlifted.Distributed.Scalars (
unitD, scalarD,
orD, andD, sumD
) where
import Data.Array.Parallel.Unlifted.Distributed.Gang (
Gang, seqGang)
import Data.Array.Parallel.Unlifted.Distributed.Types (
DT, Dist, unitD)
import Data.Array.Parallel.Unlifted.Distributed.Combinators (
mapD, foldD)
scalarD :: DT a => Gang -> a -> Dist a
scalarD g x = mapD (seqGang g) (const x) (unitD g)
orD :: Gang -> Dist Bool -> Bool
orD g = foldD g (||)
andD :: Gang -> Dist Bool -> Bool
andD g = foldD g (&&)
sumD :: (Num a, DT a) => Gang -> Dist a -> a
sumD g = foldD g (+)