Safe Haskell | Safe-Infered |
---|

Functions that work on parallel arrays of scalar elements. Unlike the functions defined in D.A.P.PArray, these only need Scalar dictionaries, instead of PR or PA dictionaries.

They are used when defining vectorised Prelude functions, eg in D.A.P.Prelude.Int and D.A.P.Prelude.Double.

The map and zipWith functions are also used by the vectoriser when vectorising uses of scalar operators like (+).

- class (PA a, Elt a) => Scalar a where
- fromScalarPData :: PData a -> Array a
- toScalarPData :: Array a -> PData a
- fromScalarPDatas :: PDatas a -> Arrays a
- toScalarPDatas :: Arrays a -> PDatas a

- toUArray :: Scalar a => PArray a -> Array a
- fromUArray :: Scalar a => Array a -> PArray a
- fromUArray2 :: (Scalar a, Scalar b) => Array (a, b) -> PArray (a, b)
- map :: (Scalar a, Scalar b) => (a -> b) -> PArray a -> PArray b
- zipWith :: (Scalar a, Scalar b, Scalar c) => (a -> b -> c) -> PArray a -> PArray b -> PArray c
- zipWith3 :: (Scalar a, Scalar b, Scalar c, Scalar d) => (a -> b -> c -> d) -> PArray a -> PArray b -> PArray c -> PArray d
- fold :: Scalar a => (a -> a -> a) -> a -> PArray a -> a
- folds :: (Scalar a, Elts a) => (a -> a -> a) -> a -> PArray (PArray a) -> PArray a
- fold1 :: Scalar a => (a -> a -> a) -> PArray a -> a
- fold1s :: (Scalar a, Elts a) => (a -> a -> a) -> PArray (PArray a) -> PArray a
- fold1Index :: Scalar a => ((Int, a) -> (Int, a) -> (Int, a)) -> PArray a -> Int
- fold1sIndex :: Scalar a => ((Int, a) -> (Int, a) -> (Int, a)) -> PArray (PArray a) -> PArray Int
- enumFromTo :: Int -> Int -> PArray Int
- enumFromTol :: PArray Int -> PArray Int -> PArray (PArray Int)

# Documentation

class (PA a, Elt a) => Scalar a whereSource

Class of Scalar data that can be converted to and from single unboxed vectors.

fromScalarPData :: PData a -> Array aSource

toScalarPData :: Array a -> PData aSource

fromScalarPDatas :: PDatas a -> Arrays aSource

toScalarPDatas :: Arrays a -> PDatas aSource

# Conversions

fromUArray :: Scalar a => Array a -> PArray aSource

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

Convert an U.Array of pairs to a PArray.

# Maps and Zips

map :: (Scalar a, Scalar b) => (a -> b) -> PArray a -> PArray bSource

Apply a worker function to every element of an array, yielding a new array.

zipWith :: (Scalar a, Scalar b, Scalar c) => (a -> b -> c) -> PArray a -> PArray b -> PArray cSource

Zip two arrays, yielding a new array.

zipWith3 :: (Scalar a, Scalar b, Scalar c, Scalar d) => (a -> b -> c -> d) -> PArray a -> PArray b -> PArray c -> PArray dSource

Zip three arrays, yielding a new array.

# Folds

folds :: (Scalar a, Elts a) => (a -> a -> a) -> a -> PArray (PArray a) -> PArray aSource

Segmented fold of an array of arrays.

fold1 :: Scalar a => (a -> a -> a) -> PArray a -> aSource

Left fold over an array, using the first element to initialise the state.

fold1s :: (Scalar a, Elts a) => (a -> a -> a) -> PArray (PArray a) -> PArray aSource

Segmented fold of an array of arrays, using the first element of each segment to initialse the state for that segment.

fold1Index :: Scalar a => ((Int, a) -> (Int, a) -> (Int, a)) -> PArray a -> IntSource

Left fold over an array, also passing the index of each element to the parameter function.

fold1sIndex :: Scalar a => ((Int, a) -> (Int, a) -> (Int, a)) -> PArray (PArray a) -> PArray IntSource

Segmented fold over an array, also passing the index of each element to the parameter function. TODO: fold the psegs then replicate, like in the other folds. this currently has the wrong complexity.