#include "fusion-phases.h"
module Data.Array.Parallel.PArray.PData.Double
( PData (..)
, PDatas(..))
where
import Data.Array.Parallel.Pretty
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
import qualified Data.Typeable as T
data instance PData Double
= PDouble (U.Array Double)
data instance PDatas Double
= PDoubles (U.Arrays Double)
instance PR Double where
validPR _
= True
nfPR (PDouble xx)
= xx `seq` ()
similarPR = (==)
coversPR weak (PDouble uarr) ix
| weak = ix <= U.length uarr
| otherwise = ix < U.length uarr
pprpPR d
= double d
pprpDataPR (PDouble vec)
= text "PDouble"
<+> text (show $ U.toList vec)
typeRepPR x = T.typeOf x
typeRepDataPR _ = T.typeOf (5 :: Double)
typeRepDatasPR _ = T.typeOf (5 :: Double)
emptyPR
= PDouble U.empty
replicatePR len x
= PDouble $ U.replicate len x
replicatesPR segd (PDouble arr)
= PDouble $ U.replicate_s segd arr
appendPR (PDouble arr1) (PDouble arr2)
= PDouble $ arr1 U.+:+ arr2
appendvsPR segdResult segd1 (PDoubles arr1) segd2 (PDoubles arr2)
= PDouble $ U.append_vs segdResult segd1 arr1 segd2 arr2
lengthPR (PDouble uarr)
= U.length uarr
indexPR (PDouble arr) ix
= U.index "indexPR[Double]" arr ix
indexsPR (PDoubles pvecs) srcixs
= PDouble $ U.map (\(src, ix) -> U.unsafeIndex2s pvecs src ix) srcixs
indexvsPR (PDoubles arrs) vsegd srcixs
= PDouble $ U.indexs_avs arrs vsegd srcixs
extractPR (PDouble arr) start len
= PDouble $ U.extract arr start len
extractssPR (PDoubles arrs) ssegd
= PDouble $ U.extracts_ass ssegd arrs
extractvsPR (PDoubles arrs) vsegd
= PDouble $ U.extracts_avs vsegd arrs
packByTagPR (PDouble arr1) arrTags tag
= PDouble $ U.packByTag arr1 arrTags tag
combine2PR sel (PDouble arr1) (PDouble arr2)
= PDouble $ U.combine2 (U.tagsSel2 sel)
(U.repSel2 sel)
arr1 arr2
fromVectorPR xx
= PDouble (U.fromList $ V.toList xx)
toVectorPR (PDouble arr)
= V.fromList $ U.toList arr
emptydPR
= PDoubles $ U.emptys
singletondPR (PDouble pdata)
= PDoubles $ U.singletons pdata
lengthdPR (PDoubles vec)
= U.lengths vec
indexdPR (PDoubles vec) ix
= PDouble $ vec `U.unsafeIndexs` ix
appenddPR (PDoubles xs) (PDoubles ys)
= PDoubles $ xs `U.appends` ys
fromVectordPR pdatas
= PDoubles
$ U.fromVectors
$ V.map (\(PDouble vec) -> vec) pdatas
toVectordPR (PDoubles vec)
= V.map PDouble $ U.toVectors vec
deriving instance Show (PData Double)
deriving instance Show (PDatas Double)
instance PprVirtual (PData Double) where
pprv (PDouble vec)
= text (show $ U.toList vec)