Safe Haskell  SafeInfered 

Repa arrays are wrappers around a linear structure that holds the element data. The representation tag determines what structure holds the data.
Delayed Representations (functions that compute elements)
Manifest Representations (real data)

U
 Adaptive unboxed vectors. 
V
 Boxed vectors. 
B
 Strict ByteStrings. 
F
 Foreign memory buffers.
Meta Representations

P
 Arrays that are partitioned into several representations. 
S
 Hints that computing this array is a small amount of work, so computation should be sequential rather than parallel to avoid scheduling overheads. 
I
 Hints that computing this array will be an unbalanced workload, so computation of successive elements should be interleaved between the processors 
X
 Arrays whose elements are all undefined.
Array fusion is achieved via the delayed (D
) and cursored (C
)
representations. At compile time, the GHC simplifier combines the functions
contained within D
and C
arrays without needing to create manifest
intermediate arrays.
Advice for writing fast code:
 Repa does not support nested parallellism.
This means that you cannot
map
a parallel worker function across an array and then callcomputeP
to evaluate it, or pass a parallel worker to parallel reductions such asfoldP
. If you do then you will get a runtime warning and the code will run very slowly.  Arrays of type
(Array D sh a)
or(Array C sh a)
are not real arrays. They are represented as functions that compute each element on demand. You need to usecomputeS
,computeP
,computeUnboxedP
and so on to actually evaluate the elements.  Add
INLINE
pragmas to all leaffunctions in your code, expecially ones that compute numeric results. Noninlined lazy function calls can cost upwards of 50 cycles each, while each numeric operator only costs one (or less). Inlining leaf functions also ensures they are specialised at the appropriate numeric types.  Add bang patterns to all function arguments, and all fields of your data types. In a highperformance Haskell program, the cost of lazy evaluation can easily dominate the run time if not handled correctly. You don't want to rely on the strictness analyser in numeric code because if it does not return a perfect result then the performance of your program will be awful. This is less of a problem for general Haskell code, and in a different context relying on strictness analysis is fine.
 Scheduling a parallel computation takes about 200us on an OSX machine.
You should switch to sequential evaluation functions like
computeS
andfoldS
for small arrays in inner loops, and at the bottom of a divideandconquer algorithm. Consider using acomputeP
that evaluates an array defined usingcomputeS
orfoldS
for each element.  Compile the modules that use Repa with the following flags:
Odph rtsopts threaded
fnoliberatecase funfoldingusethreshold1000 funfoldingkeenessfactor1000
fllvm optloO3
You don't want the liberatecase transform because it tends to duplicate too much intermediate code, and is not needed if you use bang patterns as per point 4. The unfolding flags tell the inliner to not to fool around with heuristics, and just inline everything. If the binaries become too big then split the array part of your program into separate modules and only compile those with the unfolding flags.  Repa writes to the GHC eventlog at the start and end of each parallel computation. Use threadscope to see what your program is doing.
 When you're sure your program works, switch to the unsafe versions
of functions like
traverse
. These don't do bounds checks.
 module Data.Array.Repa.Shape
 module Data.Array.Repa.Index
 data family Array r sh e
 class Repr r e where
 extent :: Shape sh => Array r sh e > sh
 index, unsafeIndex :: Shape sh => Array r sh e > sh > e
 linearIndex, unsafeLinearIndex :: Shape sh => Array r sh e > Int > e
 deepSeqArray :: Shape sh => Array r sh e > b > b
 (!) :: (Repr r e, Shape sh) => Array r sh e > sh > e
 toList :: (Shape sh, Repr r e) => Array r sh e > [e]
 deepSeqArrays :: (Shape sh, Repr r e) => [Array r sh e] > b > b
 computeP :: (Shape sh, Fill r1 r2 sh e, Repr r2 e, Monad m) => Array r1 sh e > m (Array r2 sh e)
 computeS :: Fill r1 r2 sh e => Array r1 sh e > Array r2 sh e
 copyP :: (Shape sh, Fill D r2 sh e, Repr r1 e, Repr r2 e, Monad m) => Array r1 sh e > m (Array r2 sh e)
 copyS :: (Repr r1 e, Fill D r2 sh e) => Array r1 sh e > Array r2 sh e
 data D
 fromFunction :: sh > (sh > a) > Array D sh a
 toFunction :: (Shape sh, Repr r1 a) => Array r1 sh a > (sh, sh > a)
 delay :: (Shape sh, Repr r e) => Array r sh e > Array D sh e
 data U
 computeUnboxedP :: (Fill r1 U sh e, Monad m, Unbox e) => Array r1 sh e > m (Array U sh e)
 computeUnboxedS :: Fill r1 U sh e => Array r1 sh e > Array U sh e
 fromListUnboxed :: (Shape sh, Unbox a) => sh > [a] > Array U sh a
 fromUnboxed :: (Shape sh, Unbox e) => sh > Vector e > Array U sh e
 toUnboxed :: Unbox e => Array U sh e > Vector e
 reshape :: (Shape sh2, Shape sh1, Repr r1 e) => sh2 > Array r1 sh1 e > Array D sh2 e
 append, (++) :: (Shape sh, Repr r1 e, Repr r2 e) => Array r1 (sh :. Int) e > Array r2 (sh :. Int) e > Array D (sh :. Int) e
 extract :: (Shape sh, Repr r e) => sh > sh > Array r sh e > Array D sh e
 transpose :: (Shape sh, Repr r e) => Array r ((sh :. Int) :. Int) e > Array D ((sh :. Int) :. Int) e
 backpermute :: forall r sh1 sh2 e. (Shape sh1, Shape sh2, Repr r e) => sh2 > (sh2 > sh1) > Array r sh1 e > Array D sh2 e
 backpermuteDft :: forall r0 r1 sh1 sh2 e. (Shape sh1, Shape sh2, Repr r0 e, Repr r1 e) => Array r0 sh2 e > (sh2 > Maybe sh1) > Array r1 sh1 e > Array D sh2 e
 module Data.Array.Repa.Slice
 slice :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Repr r e) => Array r (FullShape sl) e > sl > Array D (SliceShape sl) e
 extend :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Repr r e) => sl > Array r (SliceShape sl) e > Array D (FullShape sl) e
 map :: (Shape sh, Repr r a) => (a > b) > Array r sh a > Array D sh b
 zipWith :: (Shape sh, Repr r1 a, Repr r2 b) => (a > b > c) > Array r1 sh a > Array r2 sh b > Array D sh c
 (+^) :: (Num c, Shape sh, Repr r2 c, Repr r1 c) => Array r1 sh c > Array r2 sh c > Array D sh c
 (^) :: (Num c, Shape sh, Repr r2 c, Repr r1 c) => Array r1 sh c > Array r2 sh c > Array D sh c
 (*^) :: (Num c, Shape sh, Repr r2 c, Repr r1 c) => Array r1 sh c > Array r2 sh c > Array D sh c
 (/^) :: (Fractional c, Shape sh, Repr r2 c, Repr r1 c) => Array r1 sh c > Array r2 sh c > Array D sh c
 class Combine r1 a r2 b  r1 > r2 where
 traverse :: forall r sh sh' a b. (Shape sh, Shape sh', Repr r a) => Array r sh a > (sh > sh') > ((sh > a) > sh' > b) > Array D sh' b
 traverse2 :: forall r1 r2 sh sh' sh'' a b c. (Shape sh, Shape sh', Shape sh'', Repr r1 a, Repr r2 b) => Array r1 sh a > Array r2 sh' b > (sh > sh' > sh'') > ((sh > a) > (sh' > b) > sh'' > c) > Array D sh'' c
 traverse3 :: forall r1 r2 r3 sh1 sh2 sh3 sh4 a b c d. (Shape sh1, Shape sh2, Shape sh3, Shape sh4, Repr r1 a, Repr r2 b, Repr r3 c) => Array r1 sh1 a > Array r2 sh2 b > Array r3 sh3 c > (sh1 > sh2 > sh3 > sh4) > ((sh1 > a) > (sh2 > b) > (sh3 > c) > sh4 > d) > Array D sh4 d
 traverse4 :: forall r1 r2 r3 r4 sh1 sh2 sh3 sh4 sh5 a b c d e. (Shape sh1, Shape sh2, Shape sh3, Shape sh4, Shape sh5, Repr r1 a, Repr r2 b, Repr r3 c, Repr r4 d) => Array r1 sh1 a > Array r2 sh2 b > Array r3 sh3 c > Array r4 sh4 d > (sh1 > sh2 > sh3 > sh4 > sh5) > ((sh1 > a) > (sh2 > b) > (sh3 > c) > (sh4 > d) > sh5 > e) > Array D sh5 e
 interleave2 :: (Shape sh, Repr r1 a, Repr r2 a) => Array r1 (sh :. Int) a > Array r2 (sh :. Int) a > Array D (sh :. Int) a
 interleave3 :: (Shape sh, Repr r1 a, Repr r2 a, Repr r3 a) => Array r1 (sh :. Int) a > Array r2 (sh :. Int) a > Array r3 (sh :. Int) a > Array D (sh :. Int) a
 interleave4 :: (Shape sh, Repr r1 a, Repr r2 a, Repr r3 a, Repr r4 a) => Array r1 (sh :. Int) a > Array r2 (sh :. Int) a > Array r3 (sh :. Int) a > Array r4 (sh :. Int) a > Array D (sh :. Int) a
 foldP :: (Shape sh, Elt a, Unbox a, Repr r a, Monad m) => (a > a > a) > a > Array r (sh :. Int) a > m (Array U sh a)
 foldS :: (Shape sh, Elt a, Unbox a, Repr r a) => (a > a > a) > a > Array r (sh :. Int) a > Array U sh a
 foldAllP :: (Shape sh, Elt a, Unbox a, Repr r a, Monad m) => (a > a > a) > a > Array r sh a > m a
 foldAllS :: (Shape sh, Elt a, Unbox a, Repr r a) => (a > a > a) > a > Array r sh a > a
 sumP :: (Shape sh, Num a, Elt a, Unbox a, Repr r a, Monad m) => Array r (sh :. Int) a > m (Array U sh a)
 sumS :: (Shape sh, Num a, Elt a, Unbox a, Repr r a) => Array r (sh :. Int) a > Array U sh a
 sumAllP :: (Shape sh, Elt a, Unbox a, Num a, Repr r a, Monad m) => Array r sh a > m a
 sumAllS :: (Shape sh, Elt a, Unbox a, Num a, Repr r a) => Array r sh a > a
 equalsP :: (Shape sh, Repr r1 e, Repr r2 e, Eq e, Monad m) => Array r1 sh e > Array r2 sh e > m Bool
 equalsS :: (Shape sh, Repr r1 e, Repr r2 e, Eq e) => Array r1 sh e > Array r2 sh e > Bool
 selectP :: (Unbox a, Monad m) => (Int > Bool) > (Int > a) > Int > m (Array U DIM1 a)
Abstract array representation
module Data.Array.Repa.Shape
module Data.Array.Repa.Index
data family Array r sh e Source
Arrays with a representation tag, shape, and element type.
Use one of the type tags like D
, U
and so on for r
,
one of DIM1
, DIM2
... for sh
.
Class of array representations that we can read elements from.
extent :: Shape sh => Array r sh e > shSource
O(1). Take the extent (size) of an array.
index, unsafeIndex :: Shape sh => Array r sh e > sh > eSource
O(1). Shape polymorphic indexing.
linearIndex, unsafeLinearIndex :: Shape sh => Array r sh e > Int > eSource
O(1). Linear indexing into underlying, rowmajor, array representation.
deepSeqArray :: Shape sh => Array r sh e > b > bSource
Ensure an array's data structure is fully evaluated.
Repr X e  Undefined array elements. Inspecting them yields 
Repr D a  Compute elements of a delayed array. 
Repr B Word8  Read elements from a 
Repr C a  Compute elements of a cursored array. 
Storable a => Repr F a  Read elements from a foreign buffer. 
Unbox a => Repr U a  Read elements from an unboxed vector array. 
Repr V a  Read elements from a boxed vector array. 
Repr r1 a => Repr (S r1) a  
Repr r1 a => Repr (I r1) a  
(Repr r1 e, Repr r2 e) => Repr (P r1 r2) e  Read elements from a partitioned array. 
deepSeqArrays :: (Shape sh, Repr r e) => [Array r sh e] > b > bSource
Apply deepSeqArray
to up to four arrays.
Computation
computeP :: (Shape sh, Fill r1 r2 sh e, Repr r2 e, Monad m) => Array r1 sh e > m (Array r2 sh e)Source
Parallel computation of array elements.
 The source array must have a delayed representation like
D
,C
orP
, and the result a manifest representation likeU
orF
.  If you want to copy data between manifest representations then use
copyP
instead.  If you want to convert a manifest array back to a delayed representation
then use
delay
instead.
computeS :: Fill r1 r2 sh e => Array r1 sh e > Array r2 sh eSource
Sequential computation of array elements.
copyP :: (Shape sh, Fill D r2 sh e, Repr r1 e, Repr r2 e, Monad m) => Array r1 sh e > m (Array r2 sh e)Source
Parallel copying of arrays.
 This is a wrapper that delays an array before calling
computeP
.  You can use it to copy manifest arrays between representations.
copyS :: (Repr r1 e, Fill D r2 sh e) => Array r1 sh e > Array r2 sh eSource
Sequential copying of arrays.
Concrete array representations
Delayed representation
Delayed arrays are represented as functions from the index to element value.
Every time you index into a delayed array the element at that position is recomputed.
Repr D a  Compute elements of a delayed array. 
(Fillable r2 e, Elt e) => FillRange D r2 DIM2 e  Compute a range of elements in a rank2 array. 
(Fillable r2 e, Shape sh) => Fill D r2 sh e  Compute all elements in an array. 
Combine D a D b  
Combine B Word8 D b  
Storable a => Combine F a D b  
Unbox a => Combine U a D b  
(Shape sh, Fill D r2 sh e) => Fill (I D) r2 sh e 
fromFunction :: sh > (sh > a) > Array D sh aSource
O(1). Wrap a function as a delayed array.
toFunction :: (Shape sh, Repr r1 a) => Array r1 sh a > (sh, sh > a)Source
O(1). Produce the extent of an array, and a function to retrieve an arbitrary element.
delay :: (Shape sh, Repr r e) => Array r sh e > Array D sh eSource
O(1). Delay an array. This wraps the internal representation to be a function from indices to elements, so consumers don't need to worry about what the previous representation was.
Unboxed vector representation
Unboxed arrays are represented as unboxed vectors.
The implementation uses Data.Vector.Unboxed
which is based on type
families and picks an efficient, specialised representation for every
element type. In particular, unboxed vectors of pairs are represented
as pairs of unboxed vectors.
This is the most efficient representation for numerical data.
computeUnboxedP :: (Fill r1 U sh e, Monad m, Unbox e) => Array r1 sh e > m (Array U sh e)Source
Parallel computation of array elements.
 This is an alias for
computeP
with a more specific type.
computeUnboxedS :: Fill r1 U sh e => Array r1 sh e > Array U sh eSource
Sequential computation of array elements..
 This is an alias for
computeS
with a more specific type.
fromListUnboxed :: (Shape sh, Unbox a) => sh > [a] > Array U sh aSource
O(n). Convert a list to an unboxed vector array.
 This is an alias for
fromList
with a more specific type.
fromUnboxed :: (Shape sh, Unbox e) => sh > Vector e > Array U sh eSource
O(1). Wrap an unboxed vector as an array.
Operators
Index space transformations
reshape :: (Shape sh2, Shape sh1, Repr r1 e) => sh2 > Array r1 sh1 e > Array D sh2 eSource
Impose a new shape on the elements of an array.
The new extent must be the same size as the original, else error
.
append, (++) :: (Shape sh, Repr r1 e, Repr r2 e) => Array r1 (sh :. Int) e > Array r2 (sh :. Int) e > Array D (sh :. Int) eSource
Append two arrays.
Extract a subrange of elements from an array.
transpose :: (Shape sh, Repr r e) => Array r ((sh :. Int) :. Int) e > Array D ((sh :. Int) :. Int) eSource
Transpose the lowest two dimensions of an array. Transposing an array twice yields the original.
:: forall r sh1 sh2 e . (Shape sh1, Shape sh2, Repr r e)  
=> sh2  Extent of result array. 
> (sh2 > sh1)  Function mapping each index in the result array to an index of the source array. 
> Array r sh1 e  Source array. 
> Array D sh2 e 
Backwards permutation of an array's elements. The result array has the same extent as the original.
:: forall r0 r1 sh1 sh2 e . (Shape sh1, Shape sh2, Repr r0 e, Repr r1 e)  
=> Array r0 sh2 e  Default values ( 
> (sh2 > Maybe sh1)  Function mapping each index in the result array to an index in the source array. 
> Array r1 sh1 e  Source array. 
> Array D sh2 e 
Default backwards permutation of an array's elements.
If the function returns Nothing
then the value at that index is taken
from the default array (arrDft
)
Slice transformations
module Data.Array.Repa.Slice
slice :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Repr r e) => Array r (FullShape sl) e > sl > Array D (SliceShape sl) eSource
Take a slice from an array, according to a given specification.
For example, to take a row from a matrix use the following:
slice arr (Any :. (5::Int) :. All)
To take a column use:
slice arr (Any :. (5::Int))
extend :: (Slice sl, Shape (FullShape sl), Shape (SliceShape sl), Repr r e) => sl > Array r (SliceShape sl) e > Array D (FullShape sl) eSource
Extend an array, according to a given slice specification.
For example, to replicate the rows of an array use the following:
extend arr (Any :. (5::Int) :. All)
Structure preserving operations
map :: (Shape sh, Repr r a) => (a > b) > Array r sh a > Array D sh bSource
Apply a worker function to each element of an array, yielding a new array with the same extent.
zipWith :: (Shape sh, Repr r1 a, Repr r2 b) => (a > b > c) > Array r1 sh a > Array r2 sh b > Array D sh cSource
Combine two arrays, elementwise, with a binary operator. If the extent of the two array arguments differ, then the resulting array's extent is their intersection.
(+^) :: (Num c, Shape sh, Repr r2 c, Repr r1 c) => Array r1 sh c > Array r2 sh c > Array D sh cSource
(^) :: (Num c, Shape sh, Repr r2 c, Repr r1 c) => Array r1 sh c > Array r2 sh c > Array D sh cSource
(*^) :: (Num c, Shape sh, Repr r2 c, Repr r1 c) => Array r1 sh c > Array r2 sh c > Array D sh cSource
(/^) :: (Fractional c, Shape sh, Repr r2 c, Repr r1 c) => Array r1 sh c > Array r2 sh c > Array D sh cSource
class Combine r1 a r2 b  r1 > r2 whereSource
Combining versions of map
and zipWith
that preserve the representation
of cursored and partitioned arrays.
For cursored (C
) arrays, the cursoring of the source array is preserved.
For partitioned (P
) arrays, the worker function is fused with each array
partition separately, instead of treating the whole array as a single
bulk object.
Preserving the cursored and/or paritioned representation of an array
is will make followon computation more efficient than if the array was
converted to a vanilla Delayed (D
) array as with plain map
and zipWith
.
If the source array is not cursored or partitioned then cmap
and
czipWith
are identical to the plain functions.
cmap :: Shape sh => (a > b) > Array r1 sh a > Array r2 sh bSource
Combining map
.
czipWith :: (Shape sh, Repr r c) => (c > a > b) > Array r sh c > Array r1 sh a > Array r2 sh bSource
Combining zipWith
.
If you have a cursored or partitioned source array then use that as
the third argument (corresponding to r1
here)
Generic traversal
:: forall r sh sh' a b . (Shape sh, Shape sh', Repr r a)  
=> Array r sh a  Source array. 
> (sh > sh')  Function to produce the extent of the result. 
> ((sh > a) > sh' > b)  Function to produce elements of the result. It is passed a lookup function to get elements of the source. 
> Array D sh' b 
Unstructured traversal.
:: forall r1 r2 sh sh' sh'' a b c . (Shape sh, Shape sh', Shape sh'', Repr r1 a, Repr r2 b)  
=> Array r1 sh a  First source array. 
> Array r2 sh' b  Second source array. 
> (sh > sh' > sh'')  Function to produce the extent of the result. 
> ((sh > a) > (sh' > b) > sh'' > c)  Function to produce elements of the result. It is passed lookup functions to get elements of the source arrays. 
> Array D sh'' c 
Unstructured traversal over two arrays at once.
traverse3 :: forall r1 r2 r3 sh1 sh2 sh3 sh4 a b c d. (Shape sh1, Shape sh2, Shape sh3, Shape sh4, Repr r1 a, Repr r2 b, Repr r3 c) => Array r1 sh1 a > Array r2 sh2 b > Array r3 sh3 c > (sh1 > sh2 > sh3 > sh4) > ((sh1 > a) > (sh2 > b) > (sh3 > c) > sh4 > d) > Array D sh4 dSource
Unstructured traversal over three arrays at once.
traverse4 :: forall r1 r2 r3 r4 sh1 sh2 sh3 sh4 sh5 a b c d e. (Shape sh1, Shape sh2, Shape sh3, Shape sh4, Shape sh5, Repr r1 a, Repr r2 b, Repr r3 c, Repr r4 d) => Array r1 sh1 a > Array r2 sh2 b > Array r3 sh3 c > Array r4 sh4 d > (sh1 > sh2 > sh3 > sh4 > sh5) > ((sh1 > a) > (sh2 > b) > (sh3 > c) > (sh4 > d) > sh5 > e) > Array D sh5 eSource
Unstructured traversal over four arrays at once.
Interleaving
interleave2 :: (Shape sh, Repr r1 a, Repr r2 a) => Array r1 (sh :. Int) a > Array r2 (sh :. Int) a > Array D (sh :. Int) aSource
Interleave the elements of two arrays.
All the input arrays must have the same extent, else error
.
The lowest dimension of the result array is twice the size of the inputs.
interleave2 a1 a2 b1 b2 => a1 b1 a2 b2 a3 a4 b3 b4 a3 b3 a4 b4
interleave3 :: (Shape sh, Repr r1 a, Repr r2 a, Repr r3 a) => Array r1 (sh :. Int) a > Array r2 (sh :. Int) a > Array r3 (sh :. Int) a > Array D (sh :. Int) aSource
Interleave the elements of three arrays.
interleave4 :: (Shape sh, Repr r1 a, Repr r2 a, Repr r3 a, Repr r4 a) => Array r1 (sh :. Int) a > Array r2 (sh :. Int) a > Array r3 (sh :. Int) a > Array r4 (sh :. Int) a > Array D (sh :. Int) aSource
Interleave the elements of four arrays.
Reduction
foldP :: (Shape sh, Elt a, Unbox a, Repr r 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.
foldS :: (Shape sh, Elt a, Unbox a, Repr r a) => (a > a > a) > a > Array r (sh :. Int) a > Array U sh aSource
Sequential reduction of the innermost dimension of an arbitrary rank array.
Combine this with transpose
to fold any other dimension.
foldAllP :: (Shape sh, Elt a, Unbox a, Repr r a, Monad m) => (a > a > a) > a > Array r sh a > m aSource
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.
foldAllS :: (Shape sh, Elt a, Unbox a, Repr r a) => (a > a > a) > a > Array r sh a > aSource
Sequential reduction of an array of arbitrary rank to a single scalar value.
sumP :: (Shape sh, Num a, Elt a, Unbox a, Repr r a, Monad m) => Array r (sh :. Int) a > m (Array U sh a)Source
Parallel sum the innermost dimension of an array.
sumS :: (Shape sh, Num a, Elt a, Unbox a, Repr r a) => Array r (sh :. Int) a > Array U sh aSource
Sequential sum the innermost dimension of an array.
sumAllP :: (Shape sh, Elt a, Unbox a, Num a, Repr r a, Monad m) => Array r sh a > m aSource
Parallel sum all the elements of an array.
sumAllS :: (Shape sh, Elt a, Unbox a, Num a, Repr r a) => Array r sh a > aSource
Sequential sum of all the elements of an array.
equalsP :: (Shape sh, Repr r1 e, Repr r2 e, Eq e, Monad m) => Array r1 sh e > Array r2 sh e > m BoolSource
Check whether two arrays have the same shape and contain equal elements, in parallel.
equalsS :: (Shape sh, Repr r1 e, Repr r2 e, Eq e) => Array r1 sh e > Array r2 sh e > BoolSource
Check whether two arrays have the same shape and contain equal elements, sequentially.
Selection
:: (Unbox a, Monad m)  
=> (Int > Bool)  If the Int matches this predicate, 
> (Int > a)  ... then pass it to this fn to produce a value 
> Int  Range between 0 and this maximum. 
> m (Array U DIM1 a)  Array containing produced values. 
Produce an array by applying a predicate to a range of integers. If the predicate matches, then use the second function to generate the element.
 This is a lowlevel function helpful for writing filtering operations on arrays.
 Use the integer as the index into the array you're filtering.