A high-level interface to the operations in the core language
(Feldspar.Core). Many of the functions defined here are imitations of
Haskell's list operations, and to a first approximation they behave
A symbolic vector (Vector) can be thought of as a representation of a
parallel core array. This view is made precise by the function
freezeVector, which converts a symbolic vector to a core vector using
Vector is instantiated under the Computable class, which means that
symbolic vectors can be used quite seamlessly with the interface in
Unlike core arrays vectors don't use any physical memory. All
operations on vectors are "fused" which means that intermediate vectors
are removed. As an example, the following function uses only constant
space despite using two intermediate vectors of length n.
sumSq n = sum (map (^2) (1...n))
Memory is only introduced when a vector is explicitly
written to memory using the function memorize or converted to a core
array using freezeVector. The function vector for creating a
vector also allocates memory.
Note also that most operations only introduce a small constant overhead on
the vector. The exceptions are
These functions introduce overhead that is linear in the length of the
Finally, note that freezeVector can be introduced implicitly by functions
overloaded by the Computable class. This means that, for example,
printCore f, where f :: Vector (Data Int) -> Vector (Data Int), will
introduce storage for the input and output of f.
|Short-hand for non-nested parallel vector
|Converts a non-nested vector to a core vector.
|Converts a non-nested core vector to a parallel vector.
|Optimizes vector lookup by computing all elements and storing them in a
|Constructs a non-nested vector. The elements are stored in a core vector.
|Introduces an ifThenElse for each element; use with care!
|Corresponds to foldl.
|Corresponds to foldl1.
|Scalar product of two vectors
|Produced by Haddock version 2.6.1|