#include "fusion-phases.h"
module Data.Array.Parallel.Unlifted.Sequential.Segmented.Basics (
replicateSU, replicateRSU, appendSU, indicesSU, indicesSU'
) where
import Data.Array.Parallel.Stream
import Data.Array.Parallel.Unlifted.Sequential.Vector
import Data.Array.Parallel.Unlifted.Sequential.Segmented.USegd
import qualified Data.Vector.Fusion.Stream as S
replicateSU :: Unbox a => USegd -> Vector a -> Vector a
replicateSU segd xs = unstream
(replicateEachS (elementsUSegd segd)
(S.zip (stream (lengthsUSegd segd)) (stream xs)))
replicateRSU :: Unbox a => Int -> Vector a -> Vector a
replicateRSU n xs = unstream
. replicateEachRS n
$ stream xs
appendSU :: Unbox a => USegd -> Vector a -> USegd -> Vector a -> Vector a
appendSU xd xs yd ys = unstream
$ appendSS (stream (lengthsUSegd xd))
(stream xs)
(stream (lengthsUSegd yd))
(stream ys)
indicesSU' :: Int -> USegd -> Vector Int
indicesSU' i segd = unstream
. indicesSS (elementsUSegd segd) i
. stream
$ lengthsUSegd segd
indicesSU :: USegd -> Vector Int
indicesSU = indicesSU' 0