dph-prim-seq-0.5.1.1: Sequential Primitives for Data-Parallel Haskell.

Data.Array.Parallel.Unlifted.Sequential.Segmented

Contents

Description

Interface to operations on segmented unlifted arrays.

Synopsis

Documentation

appendSU :: Unbox a => USegd -> Vector a -> USegd -> Vector a -> Vector aSource

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

data USegd Source

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 

Instances

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.

mkUSegdSource

Arguments

:: Vector Int

length of each segment

-> Vector Int

starting index of each segment

-> Int

total number of elements in the flat array

-> USegd 

O(1). Construct a new segment descriptor.