feldspar-language-0.7: A functional embedded language for DSP and parallelism

Safe HaskellNone
LanguageHaskell2010

Feldspar.Vector.Push

Synopsis

Documentation

data PushVector a where Source

Constructors

Push :: ((Data Index -> a -> M ()) -> M ()) -> Data Length -> PushVector a 

freezePush :: Syntax a => PushVector a -> Data [Internal a] Source

Store push vectors in memory.

freezeToVector :: Syntax a => PushVector a -> Vector a Source

Store a push vector to memory and return it as an ordinary vector.

thawPush :: Syntax a => Data [Internal a] -> PushVector a Source

Create a push vector from an array stored in memory.

class Pushy arr where Source

Any kind of vector, push or pull, can cheaply be converted to a push vector

Methods

toPush :: Syntax a => arr a -> PushVector a Source

(++) :: (Pushy arr1, Pushy arr2, Syntax a) => arr1 a -> arr2 a -> PushVector a Source

Concatenating two arrays.

unpair :: (Pushy arr, Syntax a) => arr (a, a) -> PushVector a Source

Given an array of pairs, flatten the array so that the elements of the pairs end up next to each other in the resulting vector.

unpairWith :: (Pushy arr, Syntax a) => ((Data Index -> a -> M ()) -> Data Index -> (a, a) -> M ()) -> arr (a, a) -> PushVector a Source

everyOther :: (Data Index -> a -> M b) -> Data Index -> (a, a) -> M b Source

zipUnpair :: Syntax a => Vector a -> Vector a -> PushVector a Source

Interleaves the elements of two vectors.

class Ixmap arr where Source

An overloaded function for reordering elements of a vector.

Methods

ixmap :: Syntax a => (Data Index -> Data Index) -> arr a -> arr a Source

reverse :: (Ixmap arr, Len arr, Syntax a) => arr a -> arr a Source

Reverse a vector. Works for both push and pull vectors.

halve :: Syntax a => Vector a -> (Vector a, Vector a) Source

Split a pull vector in half.

If the input vector has an odd length the second result vector will be one element longer than the first.

riffle :: Syntax a => Vector a -> PushVector a Source

Split a vector in half and interleave the two two halves.

class Len arr where Source

A class for overloading length for both pull and push vectors

Methods

length :: arr a -> Data Length Source

Instances

chunk Source

Arguments

:: (Pushy arr1, Pushy arr2, Syntax b) 
=> Data Length

Size of the chunks

-> (Vector a -> arr1 b)

Applied to every chunk

-> (Vector a -> arr2 b)

Applied to the rest of the vector

-> Vector a 
-> PushVector b 

This function can distribute array computations on chunks of a large pull vector. A call `chunk l f g v` will split the vector v into chunks of size l and apply f to these chunks. In case the length of v is not a multiple of l then the rest of v will be processed by g.

scanl :: (Syntax a, Syntax b) => (a -> b -> a) -> a -> Vector b -> PushVector a Source

scanl is similar to fold, but returns a PushVector of successive reduced values from the left.

empty :: PushVector a Source

The empty push vector.

flatten :: Syntax a => Vector (PushVector a) -> PushVector a Source

Flattens a pull vector containing push vectors into an unnested push vector

Note that there are no restrictions on the lengths of the push vectors inside the pull vector.