A highlevel 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 accordingly.
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
parallel
.
Vector
is instantiated under the Computable
class, which means that
symbolic vectors can be used quite seamlessly with the interface in
Feldspar.Core.
Note that the only operations in this module that introduce storage (through core arrays) are
This means that vector operations not involving these operations will be completely "fused" without using any intermediate storage.
Note also that most operations only introduce a small constant overhead on the vector. The exceptions are

dropWhile

fold

fold1
 Functions that introduce storage (see above)
 "Folding" functions:
sum
,maximum
, etc.
These functions introduce overhead that is linear in the length of the vector.
Finally, note that freezeVector
can be introduced implicitly by functions
overloaded by the Computable
class. This means that, for example,
, where printCore
ff :: Vector (Data Int) > Vector (Data Int)
, will
introduce storage for the input and output of f
.
 type Ix = Int
 data Vector a = Indexed {}
 type DVector a = Vector (Data a)
 freezeVector :: Storable a => Vector (Data a) > Data [a]
 unfreezeVector :: Storable a => Data Length > Data [a] > Vector (Data a)
 memorize :: Storable a => Vector (Data a) > Vector (Data a)
 indexed :: Data Length > (Data Ix > a) > Vector a
 vector :: Storable a => [a] > Vector (Data a)
 modifyLength :: (Data Length > Data Length) > Vector a > Vector a
 setLength :: Data Length > Vector a > Vector a
 boundVector :: Int > Vector a > Vector a
 (++) :: Computable a => Vector a > Vector a > Vector a
 take :: Data Int > Vector a > Vector a
 drop :: Data Int > Vector a > Vector a
 dropWhile :: (a > Data Bool) > Vector a > Vector a
 splitAt :: Data Int > Vector a > (Vector a, Vector a)
 head :: Vector a > a
 last :: Vector a > a
 tail :: Vector a > Vector a
 init :: Vector a > Vector a
 tails :: Vector a > Vector (Vector a)
 inits :: Vector a > Vector (Vector a)
 inits1 :: Vector a > Vector (Vector a)
 permute :: (Data Length > Data Ix > Data Ix) > Vector a > Vector a
 reverse :: Vector a > Vector a
 replicate :: Data Int > a > Vector a
 enumFromTo :: Data Int > Data Int > Vector (Data Int)
 (...) :: Data Int > Data Int > Vector (Data Int)
 zip :: Vector a > Vector b > Vector (a, b)
 unzip :: Vector (a, b) > (Vector a, Vector b)
 map :: (a > b) > Vector a > Vector b
 zipWith :: (a > b > c) > Vector a > Vector b > Vector c
 fold :: Computable a => (a > b > a) > a > Vector b > a
 fold1 :: Computable a => (a > a > a) > Vector a > a
 unfoldVec :: (Computable state, Storable a) => Data Length > state > (Data Int > state > (Data a, state)) > (Vector (Data a), state)
 unfold :: (Computable state, Storable a) => Data Length > state > (state > (Data a, state)) > Vector (Data a)
 scan :: (Storable a, Computable b) => (Data a > b > Data a) > Data a > Vector b > Vector (Data a)
 mapAccum :: (Storable a, Computable acc, Storable b) => (acc > Data a > (acc, Data b)) > acc > Vector (Data a) > (acc, Vector (Data b))
 sum :: (Num a, Computable a) => Vector a > a
 maximum :: Storable a => Vector (Data a) > Data a
 minimum :: Storable a => Vector (Data a) > Data a
 scalarProd :: Numeric a => Vector (Data a) > Vector (Data a) > Data a
Types
Symbolic vector
RandomAccess (Vector a)  
Storable a => Computable (Vector (Data a))  
Storable a => Computable (Vector (Vector (Data a))) 
Construction/conversion
freezeVector :: Storable a => Vector (Data a) > Data [a]Source
Converts a nonnested vector to a core vector.
unfreezeVector :: Storable a => Data Length > Data [a] > Vector (Data a)Source
Converts a nonnested core vector to a parallel vector.
memorize :: Storable a => Vector (Data a) > Vector (Data a)Source
Optimizes vector lookup by computing all elements and storing them in a core array.
vector :: Storable a => [a] > Vector (Data a)Source
Constructs a nonnested vector. The elements are stored in a core vector.
boundVector :: Int > Vector a > Vector aSource
Operations
(++) :: Computable a => Vector a > Vector a > Vector aSource
Introduces an ifThenElse
for each element; use with care!
fold :: Computable a => (a > b > a) > a > Vector b > aSource
Corresponds to foldl
.
fold1 :: Computable a => (a > a > a) > Vector a > aSource
Corresponds to foldl1
.
unfoldVec :: (Computable state, Storable a) => Data Length > state > (Data Int > state > (Data a, state)) > (Vector (Data a), state)Source
Like unfoldCore
, but for symbolic vectors. The output elements are stored
in a core vector.
unfold :: (Computable state, Storable a) => Data Length > state > (state > (Data a, state)) > Vector (Data a)Source
scan :: (Storable a, Computable b) => (Data a > b > Data a) > Data a > Vector b > Vector (Data a)Source
Corresponds to scanl
. The output elements are stored in a core vector.
mapAccum :: (Storable a, Computable acc, Storable b) => (acc > Data a > (acc, Data b)) > acc > Vector (Data a) > (acc, Vector (Data b))Source
Corresponds to mapAccumL
. The output elements are stored in a
core vector.
sum :: (Num a, Computable a) => Vector a > aSource