dph-prim-par-0.7.0.1: Data Parallel Haskell segmented arrays. (production version)

Data.Array.Parallel.Unlifted.Parallel.Combinators

Description

Parallel combinators for unlifted arrays.

Synopsis

# Documentation

mapUP :: (Unbox a, Unbox b) => (a -> b) -> Vector a -> Vector bSource

Apply a worker to all elements of an array.

filterUP :: Unbox a => (a -> Bool) -> Vector a -> Vector aSource

Keep elements that match the given predicate.

packUP :: Unbox e => Vector e -> Vector Bool -> Vector eSource

Take elements of an array where a flag value is true, and pack them into the result.

• The souce and flag arrays must have the same length, but this is not checked.

combineUP :: Unbox a => Vector Bool -> Vector a -> Vector a -> Vector aSource

Combine two vectors based on a selector. If the selector is true then take the element from the first vector, otherwise take it from the second.

• The data vectors must have enough elements to satisfy the flag vector, but this is not checked.

combine2UP :: Unbox a => Vector Tag -> UPSelRep2 -> Vector a -> Vector a -> Vector aSource

Combine two vectors based on a selector.

• The data vectors must have enough elements to satisfy the selector, but this is not checked.

zipWithUP :: (Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Vector a -> Vector b -> Vector cSource

Apply a worker function to correponding elements of two arrays.

foldUP :: (Unbox a, DT a) => (a -> a -> a) -> a -> Vector a -> aSource

Undirected fold. Note that this function has more constraints on its parameters than the standard fold function from the Haskell Prelude.

• The worker function must be associative.
• The provided starting element must be neutral with respect to the worker. For example 0 is neutral wrt (+) and 1 is neutral wrt (*).

We need these constraints so that we can partition the fold across several threads. Each thread folds a chunk of the input vector, then we fold together all the results in the main thread.

foldlUP :: (DT a, Unbox a) => (a -> a -> a) -> a -> Vector a -> aSource

Left fold over an array.

• If the vector is empty then this returns the provided neural element.
• The worker function must be associative.
• The provided starting element must be neutral with respect to the worker, see `foldUP` for discussion.

fold1UP :: (DT a, Unbox a) => (a -> a -> a) -> Vector a -> aSource

Alias for `foldl1UP`

foldl1UP :: (DT a, Unbox a) => (a -> a -> a) -> Vector a -> aSource

Left fold over an array, using the first element of the vector as the neural element.

• If the vector contains no elements then you'll get a bounds-check error.
• The worker function must be associative.
• The provided starting element must be neutral with respect to the worker, see `foldUP` for discussion.

scanUP :: (DT a, Unbox a) => (a -> a -> a) -> a -> Vector a -> Vector aSource

Prefix scan. Similar to fold, but produce an array of the intermediate states.

• The worker function must be associative.
• The provided starting element must be neutral with respect to the worker, see `foldUP` for discussion.