Interface to operations on segmented unlifted arrays.
- replicateSU :: Unbox a => USegd -> Vector a -> Vector a
- replicateRSU :: Unbox a => Int -> Vector a -> Vector a
- appendSU :: Unbox a => USegd -> Vector a -> USegd -> Vector a -> Vector a
- indicesSU :: USegd -> Vector Int
- indicesSU' :: Int -> USegd -> Vector Int
- foldlSU :: (Unbox a, Unbox b) => (b -> a -> b) -> b -> USegd -> Vector a -> Vector b
- foldSU :: Unbox a => (a -> a -> a) -> a -> USegd -> Vector a -> Vector a
- fold1SU :: Unbox a => (a -> a -> a) -> USegd -> Vector a -> Vector a
- foldlRU :: (Unbox a, Unbox b) => (b -> a -> b) -> b -> Int -> Vector a -> Vector b
- combineSU :: Unbox a => Vector Bool -> USegd -> Vector a -> USegd -> Vector a -> Vector a
- andSU :: USegd -> Vector Bool -> Vector Bool
- orSU :: USegd -> Vector Bool -> Vector Bool
- sumSU :: (Num e, Unbox e) => USegd -> Vector e -> Vector e
- productSU :: (Num e, Unbox e) => USegd -> Vector e -> Vector e
- maximumSU :: (Ord e, Unbox e) => USegd -> Vector e -> Vector e
- minimumSU :: (Ord e, Unbox e) => USegd -> Vector e -> Vector e
- sumRU :: (Num e, Unbox e) => Int -> Vector e -> Vector e
- data USegd
- lengthUSegd :: USegd -> Int
- lengthsUSegd :: USegd -> Vector Int
- indicesUSegd :: USegd -> Vector Int
- elementsUSegd :: USegd -> Int
- lengthsToUSegd :: Vector Int -> USegd
- mkUSegd :: Vector Int -> Vector Int -> Int -> USegd
Documentation
foldlSU :: (Unbox a, Unbox b) => (b -> a -> b) -> b -> USegd -> Vector a -> Vector bSource
Segmented array reduction proceeding from the left
foldSU :: Unbox a => (a -> a -> a) -> a -> USegd -> Vector a -> Vector aSource
Segmented array reduction that requires an associative combination function with its unit
fold1SU :: Unbox a => (a -> a -> a) -> USegd -> Vector a -> Vector aSource
Segmented array reduction with non-empty subarrays and an associative combination function
foldlRU :: (Unbox a, Unbox b) => (b -> a -> b) -> b -> Int -> Vector a -> Vector bSource
Regular arrar reduction
combineSU :: Unbox a => Vector Bool -> USegd -> Vector a -> USegd -> Vector a -> Vector aSource
Merge two segmented arrays according to flag array
Logical operations
andSU :: USegd -> Vector Bool -> Vector BoolSource
Compute the boolean AND of all segments in a segmented array.
orSU :: USegd -> Vector Bool -> Vector BoolSource
Compute the boolean OR of all segments in a segmented array.
Arithmetic operations
sumSU :: (Num e, Unbox e) => USegd -> Vector e -> Vector eSource
Compute the segmented sum of an array of numerals
productSU :: (Num e, Unbox e) => USegd -> Vector e -> Vector eSource
Compute the segmented product of an array of numerals
maximumSU :: (Ord e, Unbox e) => USegd -> Vector e -> Vector eSource
Determine the maximum element in each subarray
minimumSU :: (Ord e, Unbox e) => USegd -> Vector e -> Vector eSource
Determine the minimum element in each subarray
sumRU :: (Num e, Unbox e) => Int -> Vector e -> Vector eSource
Compute the segmented sum of an array of numerals
Segment descriptors represent the structure of nested arrays. For each segment, it stores the length and the starting index in the flat data array.
Example:
flat array data: [1, 2, 3, 4, 5, 6, 7, 8] (segmentation) ---- ------- - ---- segd lengths: [2, 3, 1, 2] indices: [0, 2, 5, 6] elements: 8
Operations on segment descriptors
lengthUSegd :: USegd -> IntSource
O(1). Yield the overall number of segments.
lengthsUSegd :: USegd -> Vector IntSource
O(1). Yield the lengths of the individual segments.
indicesUSegd :: USegd -> Vector IntSource
O(1). Yield the segment indices of a segment descriptor.
elementsUSegd :: USegd -> IntSource
O(1). Yield the number of data elements.
lengthsToUSegd :: Vector Int -> USegdSource
O(n). Convert a length array into a segment descriptor.
The array contains the length of each segment, and we compute the indices from that. Runtime is O(n) in the number of segments.