dph-prim-seq: shift indexs
[packages/dph.git] / dph-prim-seq / Data / Array / Parallel / Unlifted / Sequential / Extracts.hs
1 {-# LANGUAGE CPP #-}
2 #include "fusion-phases.h"
3
4 -- | Standard combinators for segmented unlifted arrays.
5 module Data.Array.Parallel.Unlifted.Sequential.Extracts
6 ( -- * Scattered indexing.
7 indexsFromVectorsUVSegd
8
9 -- * Scattered extracts
10 , extractsFromNestedUSSegd
11 , extractsFromVectorsUSSegd
12 , extractsFromVectorsUVSegd)
13 where
14 import Data.Array.Parallel.Unlifted.Stream as US
15 import Data.Array.Parallel.Unlifted.Vectors as US
16 import Data.Array.Parallel.Unlifted.Sequential.Vector as U
17 import Data.Array.Parallel.Unlifted.Sequential.USSegd (USSegd)
18 import qualified Data.Array.Parallel.Unlifted.Sequential.UVSegd as UVSegd
19 import qualified Data.Vector as V
20
21
22 -- Indexs --------------------------------------------------------------------
23 -- | Lookup elements from some `Vectors` through a `UPVSegd`.
24 indexsFromVectorsUVSegd
25 :: (Unbox a, US.Unboxes a)
26 => Vectors a -> UVSegd -> Vector (Int, Int) -> Vector a
27
28 indexsFromVectorsUVSegd vectors uvsegd vsrcixs
29 = U.unstream
30 $ streamElemsFromVectorsVSegd vectors uvsegd
31 $ U.stream vsrcixs
32 {-# INLINE_U indexsFromVectorsUVSegd #-}
33
34
35 -- Extracts wrappers ---------------------------------------------------------
36 -- | Copy segments from a `Vectors`, concatenating them into a new array.
37 extractsFromNestedUSSegd
38 :: (U.Unbox a)
39 => USSegd -> V.Vector (Vector a) -> U.Vector a
40
41 extractsFromNestedUSSegd ussegd vectors
42 = U.unstream $ streamSegsFromNestedUSSegd vectors ussegd
43 {-# INLINE_U extractsFromNestedUSSegd #-}
44
45
46 -- | Copy segments from a `Vectors`, concatenating them into a new array.
47 extractsFromVectorsUSSegd
48 :: (Unboxes a, U.Unbox a)
49 => USSegd -> Vectors a -> U.Vector a
50
51 extractsFromVectorsUSSegd ussegd vectors
52 = U.unstream $ streamSegsFromVectorsUSSegd vectors ussegd
53 {-# INLINE_U extractsFromVectorsUSSegd #-}
54
55
56 -- | Copy segments from a `Vectors`, concatenating them into a new array.
57 extractsFromVectorsUVSegd
58 :: (Unbox a, US.Unboxes a)
59 => UVSegd
60 -> Vectors a
61 -> Vector a
62
63 extractsFromVectorsUVSegd uvsegd vectors
64 = U.unstream $ US.streamSegsFromVectorsUVSegd vectors uvsegd
65 {-# INLINE_U extractsFromVectorsUVSegd #-}