dph-lifted-base-0.7.0.1: Data Parallel Haskell common definitions used by other dph-lifted packages.

Safe HaskellNone

Data.Array.Parallel.PArray.Reference

Contents

Description

Reference implementation of operators on unvectorised parallel arrays.

  • In this module we just used boxed vectors as the array representation. This won't be fast, but it means we can write the operators without needing type class dictionaries such as PA. This makes them much easier to use as reference code.
  • The operators should also all do bounds checks, sanity checks, and give nice error messages if something is wrong. The ideas is that this code can be run side-by-side production code during debugging.

Synopsis

Documentation

type PArray a = Vector a

valid :: PArray a -> Bool

Check that an array has a valid internal representation.

nf :: PArray a -> ()

Force an array to normal form.

Constructors

empty :: PArray a

O(1). An empty array.

singleton :: a -> PArray a

O(1). Produce an array containing a single element.

singletonl :: PArray a -> PArray (PArray a)

O(n). Produce an array of singleton arrays.

replicate :: Int -> a -> PArray a

O(n). Define an array of the given size, that maps all elements to the same value.

replicatel :: PArray Int -> PArray a -> PArray (PArray a)

O(sum lengths). Lifted replicate.

replicates :: Segd -> PArray a -> PArray a

O(sum lengths). Segmented replicate.

replicates' :: PArray Int -> PArray a -> PArray a

O(sum lengths). Wrapper for segmented replicate that takes replication counts and uses them to build the Segd.

append :: PArray a -> PArray a -> PArray a

Append two arrays.

appendl :: PArray (PArray a) -> PArray (PArray a) -> PArray (PArray a)

Lifted append.

concat :: PArray (PArray a) -> PArray a

Concatenation

concatl :: PArray (PArray (PArray a)) -> PArray (PArray a)

Lifted concatenation.

unconcat :: PArray (PArray a) -> PArray b -> PArray (PArray b)

Impose a nesting structure on a flat array

nestUSegd :: Segd -> PArray a -> PArray (PArray a)

Create a nested array from a segment descriptor and some flat data. The segment descriptor must represent as many elements as present in the flat data array, else error

Projections

length :: PArray a -> Int

Take the length of an array

lengthl :: PArray (PArray a) -> PArray Int

Take the length of some arrays.

index :: PArray a -> Int -> a

Lookup a single element from the source array.

indexl :: PArray (PArray a) -> PArray Int -> PArray a

Lookup a several elements from several source arrays.

extract :: PArray a -> Int -> Int -> PArray a

Extract a range of elements from an array.

extracts :: Vector (PArray a) -> SSegd -> PArray a

Segmented extract.

extracts'

Arguments

:: Vector (PArray a) 
-> PArray Int

id of source array for each segment.

-> PArray Int

starting index of each segment in its source array.

-> PArray Int

length of each segment.

-> PArray a 

Wrapper for extracts that takes arrays of sources, starts and lengths of the segments, and uses these to build the SSegd.

slice :: Int -> Int -> PArray a -> PArray a

Extract a range of elements from an arrary. Like extract but with the parameters in a different order.

slicel :: PArray Int -> PArray Int -> PArray (PArray a) -> PArray (PArray a)

Extract some slices from some arrays. The arrays of starting indices and lengths must themselves have the same length.

takeUSegd :: PArray (PArray a) -> Segd

Take the segment descriptor from a nested array. This can cause index space overflow if the number of elements in the result does not can not be represented by a single machine word.

Pack and Combine

pack :: PArray a -> PArray Bool -> PArray a

Select the elements of an array that have their tag set to True.

packl :: PArray (PArray a) -> PArray (PArray Bool) -> PArray (PArray a)

Lifted pack.

packByTag :: PArray a -> Array Tag -> Tag -> PArray a

Filter an array based on some tags.

combine2 :: Sel2 -> PArray a -> PArray a -> PArray a

Combine two arrays based on a selector.

Enumerations

enumFromTo :: Int -> Int -> PArray Int

Construct a range of integers

enumFromTol :: PArray Int -> PArray Int -> PArray (PArray Int)

Lifted enumeration

Tuples

zip :: PArray a -> PArray b -> PArray (a, b)

O(n). Zip a pair of arrays into an array of pairs.

zipl :: PArray (PArray a) -> PArray (PArray b) -> PArray (PArray (a, b))

Lifted zip

unzip :: PArray (a, b) -> (PArray a, PArray b)

O(n). Unzip an array of pairs into a pair of arrays.

unzipl :: PArray (PArray (a, b)) -> PArray (PArray a, PArray b)

Lifted unzip

Conversions

fromVector :: Vector a -> PArray a

Convert a Vector to a PArray

toVector :: PArray a -> Vector a

Convert a PArray to a Vector

fromList :: [a] -> PArray a

Convert a list to a PArray.

toList :: PArray a -> [a]

Convert a PArray to a list.

fromUArray :: Elt a => Array a -> PArray a

Convert a Array to a PArray

toUArray :: Elt a => PArray a -> Array a

Convert a PArray to a Array

fromUArray2 :: (Elt a, Elt b) => Array (a, b) -> PArray (a, b)

Convert a Array of tuples to a PArray