Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- foldS :: (Shape sh, Source r a, Unbox a) => (a -> a -> a) -> a -> Array r (sh :. Int) a -> Array U sh a
- foldP :: (Shape sh, Source r a, Unbox a, Monad m) => (a -> a -> a) -> a -> Array r (sh :. Int) a -> m (Array U sh a)
- foldAllS :: (Shape sh, Source r a) => (a -> a -> a) -> a -> Array r sh a -> a
- foldAllP :: (Shape sh, Source r a, Unbox a, Monad m) => (a -> a -> a) -> a -> Array r sh a -> m a
- sumS :: (Shape sh, Source r a, Num a, Unbox a) => Array r (sh :. Int) a -> Array U sh a
- sumP :: (Shape sh, Source r a, Num a, Unbox a, Monad m) => Array r (sh :. Int) a -> m (Array U sh a)
- sumAllS :: (Shape sh, Source r a, Num a) => Array r sh a -> a
- sumAllP :: (Shape sh, Source r a, Unbox a, Num a, Monad m) => Array r sh a -> m a
- equalsS :: (Shape sh, Source r1 a, Source r2 a, Eq a) => Array r1 sh a -> Array r2 sh a -> Bool
- equalsP :: (Shape sh, Source r1 a, Source r2 a, Eq a, Monad m) => Array r1 sh a -> Array r2 sh a -> m Bool
Documentation
foldS :: (Shape sh, Source r a, Unbox a) => (a -> a -> a) -> a -> Array r (sh :. Int) a -> Array U sh a Source #
Sequential reduction of the innermost dimension of an arbitrary rank array.
Combine this with transpose
to fold any other dimension.
Elements are reduced in the order of their indices, from lowest to highest. Applications of the operator are associatied arbitrarily.
>>>
let c 0 x = x; c x 0 = x; c x y = y
>>>
let a = fromListUnboxed (Z :. 2 :. 2) [1,2,3,4] :: Array U (Z :. Int :. Int) Int
>>>
foldS c 0 a
AUnboxed (Z :. 2) (fromList [2,4])
foldP :: (Shape sh, Source r a, Unbox a, Monad m) => (a -> a -> a) -> a -> Array r (sh :. Int) a -> m (Array U sh a) Source #
Parallel reduction of the innermost dimension of an arbitray rank array.
The first argument needs to be an associative sequential operator.
The starting element must be neutral with respect to the operator, for
example 0
is neutral with respect to (+)
as 0 + a = a
.
These restrictions are required to support parallel evaluation, as the
starting element may be used multiple times depending on the number of threads.
Elements are reduced in the order of their indices, from lowest to highest. Applications of the operator are associatied arbitrarily.
>>>
let c 0 x = x; c x 0 = x; c x y = y
>>>
let a = fromListUnboxed (Z :. 2 :. 2) [1,2,3,4] :: Array U (Z :. Int :. Int) Int
>>>
foldP c 0 a
AUnboxed (Z :. 2) (fromList [2,4])
foldAllS :: (Shape sh, Source r a) => (a -> a -> a) -> a -> Array r sh a -> a Source #
Sequential reduction of an array of arbitrary rank to a single scalar value.
Elements are reduced in row-major order. Applications of the operator are associated arbitrarily.
foldAllP :: (Shape sh, Source r a, Unbox a, Monad m) => (a -> a -> a) -> a -> Array r sh a -> m a Source #
Parallel reduction of an array of arbitrary rank to a single scalar value.
The first argument needs to be an associative sequential operator.
The starting element must be neutral with respect to the operator,
for example 0
is neutral with respect to (+)
as 0 + a = a
.
These restrictions are required to support parallel evaluation, as the
starting element may be used multiple times depending on the number of threads.
Elements are reduced in row-major order. Applications of the operator are associated arbitrarily.
sumS :: (Shape sh, Source r a, Num a, Unbox a) => Array r (sh :. Int) a -> Array U sh a Source #
Sequential sum the innermost dimension of an array.
sumP :: (Shape sh, Source r a, Num a, Unbox a, Monad m) => Array r (sh :. Int) a -> m (Array U sh a) Source #
Parallel sum the innermost dimension of an array.
sumAllS :: (Shape sh, Source r a, Num a) => Array r sh a -> a Source #
Sequential sum of all the elements of an array.
sumAllP :: (Shape sh, Source r a, Unbox a, Num a, Monad m) => Array r sh a -> m a Source #
Parallel sum all the elements of an array.
equalsS :: (Shape sh, Source r1 a, Source r2 a, Eq a) => Array r1 sh a -> Array r2 sh a -> Bool Source #
Check whether two arrays have the same shape and contain equal elements, sequentially.
equalsP :: (Shape sh, Source r1 a, Source r2 a, Eq a, Monad m) => Array r1 sh a -> Array r2 sh a -> m Bool Source #
Check whether two arrays have the same shape and contain equal elements, in parallel.