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

Safe HaskellNone




data PushVector a whereSource


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 aSource

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

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

Create a push vector from an array stored in memory.

class Pushy arr whereSource

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


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

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

Concatenating two arrays.

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

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 aSource

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

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

Interleaves the elements of two vectors.

class Ixmap arr whereSource

An overloaded function for reordering elements of a vector.


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

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

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 aSource

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

class Len arr whereSource

A class for overloading length for both pull and push vectors


length :: arr a -> Data LengthSource




:: (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 aSource

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

empty :: PushVector aSource

The empty push vector.

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

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.