Hoogle Search
Within LTS Haskell 24.6 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
massiv Data.Massiv.Array O(n) - Left fold, computed with respect of array's computation strategy. Because we do potentially split the folding among many threads, we also need a combining function and an accumulator for the results. Depending on the number of threads being used, results can be different, hence is the MonadIO constraint.
Examples
>>> import Data.Massiv.Array >>> foldlP (flip (:)) [] (flip (:)) [] $ makeArrayR D Seq (Sz1 6) id [[5,4,3,2,1,0]] >>> foldlP (flip (:)) [] (++) [] $ makeArrayR D Seq (Sz1 6) id [5,4,3,2,1,0] >>> foldlP (flip (:)) [] (flip (:)) [] $ makeArrayR D (ParN 3) (Sz1 6) id [[5,4],[3,2],[1,0]] >>> foldlP (flip (:)) [] (++) [] $ makeArrayR D (ParN 3) (Sz1 6) id [1,0,3,2,5,4]
foldlS :: (Index ix, Source r e) => (a -> e -> a) -> a -> Array r ix e -> amassiv Data.Massiv.Array O(n) - Left fold, computed sequentially.
-
massiv Data.Massiv.Array Left fold along a specified dimension.
Example
>>> import Data.Massiv.Array >>> :set -XTypeApplications >>> arr = makeArrayLinear @U Seq (Sz (2 :. 5)) id >>> arr Array U Seq (Sz (2 :. 5)) [ [ 0, 1, 2, 3, 4 ] , [ 5, 6, 7, 8, 9 ] ] >>> foldlWithin Dim1 (flip (:)) [] arr Array D Seq (Sz1 2) [ [4,3,2,1,0], [9,8,7,6,5] ] >>> foldlWithin Dim2 (flip (:)) [] arr Array D Seq (Sz1 5) [ [5,0], [6,1], [7,2], [8,3], [9,4] ]
-
massiv Data.Massiv.Array Similar to foldlWithin, except that dimension is specified at a value level, which means it will throw an exception on an invalid dimension.
foldlStencil :: Index ix => (a -> e -> a) -> a -> Sz ix -> Stencil ix e amassiv Data.Massiv.Array.Stencil Stencil that does a left fold in a row-major order. Regardless of the supplied size resulting stencil will be centered at zero, although by using Padding it is possible to overcome this limitation.
Examples
>>> import Data.Massiv.Array as A >>> a = computeAs P $ iterateN (Sz2 3 4) (+1) (10 :: Int) >>> a Array P Seq (Sz (3 :. 4)) [ [ 11, 12, 13, 14 ] , [ 15, 16, 17, 18 ] , [ 19, 20, 21, 22 ] ] >>> applyStencil noPadding (foldlStencil (flip (:)) [] (Sz2 3 2)) a Array DW Seq (Sz (1 :. 3)) [ [ [20,19,16,15,12,11], [21,20,17,16,13,12], [22,21,18,17,14,13] ] ] >>> applyStencil (Padding (Sz2 1 0) 0 (Fill 10)) (foldlStencil (flip (:)) [] (Sz2 3 2)) a Array DW Seq (Sz (2 :. 3)) [ [ [16,15,12,11,10,10], [17,16,13,12,10,10], [18,17,14,13,10,10] ] , [ [20,19,16,15,12,11], [21,20,17,16,13,12], [22,21,18,17,14,13] ] ]
foldlIndex :: Index ix => (a -> Int -> a) -> a -> ix -> amassiv Data.Massiv.Core.Index Perform a left fold over the index
foldlUnliftedArray :: PrimUnlifted a => (b -> a -> b) -> b -> UnliftedArray a -> bprimitive-unlifted Data.Primitive.Unlifted.Array Lazy left-associated fold over the elements of an UnliftedArray.
foldlUnliftedArray' :: PrimUnlifted a => (b -> a -> b) -> b -> UnliftedArray a -> bprimitive-unlifted Data.Primitive.Unlifted.Array Strict left-associated fold over the elements of an UnliftedArray.
foldlUnliftedArrayM' :: (PrimUnlifted a, Monad m) => (b -> a -> m b) -> b -> UnliftedArray a -> m bprimitive-unlifted Data.Primitive.Unlifted.Array Strict effectful left-associated fold over the elements of an UnliftedArray.
foldlUnliftedArray :: PrimUnlifted a => (b -> a -> b) -> b -> UnliftedArray a -> bprimitive-unlifted Data.Primitive.Unlifted.Array.ST Lazy left-associated fold over the elements of an UnliftedArray.