Safe Haskell | None |
---|---|

Language | Haskell98 |

- 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 #

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`

`>>>`

AUnboxed (Z :. 2) (fromList [2,4])`foldS c 0 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) #

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`

`>>>`

AUnboxed (Z :. 2) (fromList [2,4])`foldP c 0 a`

foldAllS :: (Shape sh, Source r a) => (a -> a -> a) -> a -> Array r sh a -> a #

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 #

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 #

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) #

Parallel sum the innermost dimension of an array.

sumAllS :: (Shape sh, Source r a, Num a) => Array r sh a -> a #

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 #

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 #

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 #

Check whether two arrays have the same shape and contain equal elements, in parallel.