#include "fusion-phases.h"
module Data.Array.Parallel.PArray.PRepr.Nested
( mkPNestedPA
, concatPA, concatlPA
, unconcatPA
, appendlPA
, indexlPA
, slicelPA)
where
import Data.Array.Parallel.PArray.PRepr.Base
import Data.Array.Parallel.PArray.PData.Base
import Data.Array.Parallel.PArray.PData.Nested
import qualified Data.Array.Parallel.Unlifted as U
import qualified Data.Vector as V
type instance PRepr (PArray a)
= PArray (PRepr a)
instance PA a => PA (PArray a) where
toPRepr (PArray n xs)
= PArray n $ toArrPRepr xs
fromPRepr (PArray n xs)
= PArray n $ fromArrPRepr xs
toArrPRepr (PNested vsegd xs segd flat)
= PNested vsegd (toArrPReprs xs) segd (toArrPRepr flat)
fromArrPRepr (PNested vsegd xs segd flat)
= PNested vsegd (fromArrPReprs xs) segd (fromArrPRepr flat)
toArrPReprs (PNesteds vec)
= PNesteds $ V.map toArrPRepr vec
fromArrPReprs (PNesteds vec)
= PNesteds $ V.map fromArrPRepr vec
mkPNestedPA
:: PA a
=> U.VSegd -> PDatas a
-> U.Segd -> PData a
-> PData (PArray a)
mkPNestedPA vsegd pdatas segd pdata
= let pdatas' = toArrPReprs pdatas
pdata' = toArrPRepr pdata
in fromArrPRepr $ mkPNested vsegd pdatas' segd pdata'
concatPA :: PA a => PData (PArray a) -> PData a
concatPA arr
= fromArrPRepr $ concatPR $ toArrPRepr arr
unconcatPA :: (PA a, PA b) => PData (PArray a) -> PData b -> PData (PArray b)
unconcatPA arr1 arr2
= fromArrPRepr $ unconcatPR (toArrPRepr arr1) (toArrPRepr arr2)
concatlPA :: PA a => PData (PArray (PArray a)) -> PData (PArray a)
concatlPA arr
= fromArrPRepr $ concatlPR (toArrPRepr arr)
appendlPA :: PA a => PData (PArray a) -> PData (PArray a) -> PData (PArray a)
appendlPA arr1 arr2
= fromArrPRepr $ appendlPR (toArrPRepr arr1) (toArrPRepr arr2)
indexlPA :: PA a => PData (PArray a) -> PData Int -> PData a
indexlPA arr ixs
= fromArrPRepr $ indexlPR (toArrPRepr arr) ixs
slicelPA :: PA a => PData Int -> PData Int -> PData (PArray a) -> PData (PArray a)
slicelPA starts lens arr
= fromArrPRepr $ slicelPR starts lens (toArrPRepr arr)