Safe Haskell | None |
---|
- type Fold sh a b = IO b -> (sh -> IO a) -> sh -> sh -> IO b
- reduceL :: Foldl sh a b -> (b -> a -> b) -> Fold sh a b
- reduceLeftM :: Foldl sh a b -> (b -> a -> IO b) -> Fold sh a b
- reduceR :: Foldr sh a b -> (a -> b -> b) -> Fold sh a b
- reduceRightM :: Foldr sh a b -> (a -> b -> IO b) -> Fold sh a b
- runFold :: (USource r l sh a, Reduce l sh fsh) => Fold fsh a b -> IO b -> UArray r l sh a -> IO b
- runFoldP :: (USource r l sh a, Reduce l sh fsh) => Threads -> Fold fsh a b -> IO b -> (b -> b -> IO b) -> UArray r l sh a -> IO b
- runFoldSlicesSeparate :: (UVecSource r slr l sh v e, Reduce l sh fsh) => Fold fsh e b -> IO b -> UArray r l sh (v e) -> IO (VecList (Dim v) b)
- runFoldSlicesSeparateP :: (UVecSource r slr l sh v e, Reduce l sh fsh) => Threads -> Fold fsh e b -> IO b -> (b -> b -> IO b) -> UArray r l sh (v e) -> IO (VecList (Dim v) b)
- toList :: (USource r l sh a, Reduce l sh fsh) => UArray r l sh a -> IO [a]
Fold support
:: Foldl sh a b |
|
-> (b -> a -> b) | Pure left reduce |
-> Fold sh a b | Curried fold to be passed to |
O(0)
:: Foldl sh a b |
|
-> (b -> a -> IO b) | Monaric left reduce |
-> Fold sh a b | Curried fold to be passed to |
O(0)
:: Foldr sh a b |
|
-> (a -> b -> b) | Pure right reduce |
-> Fold sh a b | Curried fold to be passed to |
O(0)
:: Foldr sh a b |
|
-> (a -> b -> IO b) | Monaric right reduce |
-> Fold sh a b | Curried fold to be passed to |
O(0)
Fold runners
:: (USource r l sh a, Reduce l sh fsh) | |
=> Threads | Number of threads to parallelize folding on |
-> Fold fsh a b | Curried folding worker function |
-> IO b | Monadic fold zero. Wrap pure zero in |
-> (b -> b -> IO b) | Associative monadic result joining function |
-> UArray r l sh a | Source array |
-> IO b | Fold result |
O(n) Run associative fold in parallel.
Example -- associative image histogram filling in the test: https://github.com/leventov/yarr/blob/master/tests/lum-equalization.hs
:: (UVecSource r slr l sh v e, Reduce l sh fsh) | |
=> Fold fsh e b | Curried folding function to work on slices |
-> IO b | Monadic fold zero. Wrap pure zero in |
-> UArray r l sh (v e) | Source array of vectors |
-> IO (VecList (Dim v) b) | Vector of fold results |
O(n)
:: (UVecSource r slr l sh v e, Reduce l sh fsh) | |
=> Threads | Number of threads to parallelize folding on |
-> Fold fsh e b | Curried folding function to work on slices |
-> IO b | Monadic fold zero. Wrap pure zero in |
-> (b -> b -> IO b) | Associative monadic result joining function |
-> UArray r l sh (v e) | Source array of vectors |
-> IO (VecList (Dim v) b) | Vector of fold results |
O(n) Run associative fold over slices of array of vectors in parallel.