comp package:massiv

Computation strategy to use when scheduling work.
Compute array ordering by applying a comparing function to each element. The exact ordering is unspecified so this is only intended for use in maps and the like where you need an ordering but do not care about which one is used.
Ensure that Array is computed, i.e. represented with concrete elements in memory, hence is the Mutable type class restriction. Use setComp if you'd like to change computation strategy before calling compute
Just as compute, but let's you supply resulting representation type as an argument.

Examples

>>> import Data.Massiv.Array

>>> computeAs P $ range Seq (Ix1 0) 10
Array P Seq (Sz1 10)
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
Very similar to compute, but computes an array inside the IO monad. Despite being deterministic and referentially transparent, because this is an IO action it can be very useful for enforcing the order of evaluation. Should be a prefered way of computing an array during benchmarking.
Compute array in parallel using all cores disregarding predefined computation strategy. Computation stategy of the resulting array will match the source, despite that it is diregarded.
Compute an array in PrimMonad sequentially disregarding predefined computation strategy.
Same as compute and computeAs, but let's you supply resulting representation type as a proxy argument.

Examples

Useful only really for cases when representation constructor or TypeApplications extension aren't desireable for some reason:
>>> import Data.Proxy

>>> import Data.Massiv.Array

>>> computeProxy (Proxy :: Proxy P) $ (^ (2 :: Int)) <$> range Seq (Ix1 0) 10
Array P Seq (Sz1 10)
[ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 ]
Compute array sequentially disregarding predefined computation strategy. Very much the same as computePrimM, but executed in ST, thus pure.
This is just like convert, but restricted to Source arrays. Will be a noop if resulting type is the same as the input.
Same as compute, but with Stride. O(n div k) - Where n is number of elements in the source array and k is number of elements in the stride.
Same as computeWithStride, but with ability to specify resulting array representation.
Compute an Array while loading the results into the supplied mutable target array. Number of elements for arrays must agree, otherwise SizeElementsMismatchException exception is thrown.
Append computation strategy using Comp's Monoid instance.
Get computation strategy of this array
Set computation strategy for this array

Example

>>> :set -XTypeApplications

>>> import Data.Massiv.Array

>>> a = singleton @DL @Ix1 @Int 0

>>> a
Array DL Seq (Sz1 1)
[ 0 ]

>>> setComp (ParN 6) a -- use 6 capabilities
Array DL (ParN 6) (Sz1 1)
[ 0 ]
Very similar to computeAs S except load the source array into memory allocated with malloc on C heap. It can potentially be useful when iteroperating with some C programs.