Copyright | (c) Artem Chirkin |
---|---|
License | BSD3 |
Maintainer | chirkin@arch.ethz.ch |
Safe Haskell | None |
Language | Haskell2010 |
Fold a function over all dimensions provided dimension indices or offsets. The main purpose of this module is to fold or traverse flat data arrays following the shape of dimensions associated with them.
- overDim :: Monad m => Dims ds -> (Idxs ds -> Int -> a -> m a) -> Int -> Int -> a -> m a
- overDim_ :: Monad m => Dims ds -> (Idxs ds -> Int -> m ()) -> Int -> Int -> m ()
- overDimIdx :: Monad m => Dims ds -> (Idxs ds -> a -> m a) -> a -> m a
- overDimIdx_ :: Monad m => Dims ds -> (Idxs ds -> m ()) -> m ()
- overDimOff :: Monad m => Dims ds -> (Int -> a -> m a) -> Int -> Int -> a -> m a
- overDimOff_ :: Monad m => Dims ds -> (Int -> m ()) -> Int -> Int -> m ()
- overDimReverse :: Monad m => Dims ds -> (Idxs ds -> Int -> a -> m a) -> Int -> Int -> a -> m a
- overDimReverseIdx :: Monad m => Dims ds -> (Idxs ds -> a -> m a) -> a -> m a
- foldDim :: Dims ds -> (Idxs ds -> Int -> a -> a) -> Int -> Int -> a -> a
- foldDimIdx :: Dims ds -> (Idxs ds -> a -> a) -> a -> a
- foldDimOff :: Dims ds -> (Int -> a -> a) -> Int -> Int -> a -> a
- foldDimReverse :: Dims ds -> (Idxs ds -> Int -> a -> a) -> Int -> Int -> a -> a
- foldDimReverseIdx :: Dims ds -> (Idxs ds -> a -> a) -> a -> a
- overDimPart :: (Dimensions ds, Monad m) => Idxs ds -> Idxs ds -> (Idxs ds -> Int -> a -> m a) -> Int -> Int -> a -> m a
- overDimPartIdx :: Monad m => Idxs ds -> Idxs ds -> (Idxs ds -> a -> m a) -> a -> m a
Documentation
:: Monad m | |
=> Dims ds | Shape of a space |
-> (Idxs ds -> Int -> a -> m a) | Function to call on each dimension |
-> Int | Initial offset |
-> Int | Offset step |
-> a | Initial value |
-> m a |
Go over all dimensions keeping track of index and offset
:: Monad m | |
=> Dims ds | Shape of a space |
-> (Idxs ds -> Int -> m ()) | Function to call on each dimension |
-> Int | Initial offset |
-> Int | Offset step |
-> m () |
Go over all dimensions keeping track of index and offset
:: Monad m | |
=> Dims ds | Shape of a space |
-> (Idxs ds -> a -> m a) | Function to call on each dimension |
-> a | Initial value |
-> m a |
Go over all dimensions keeping track of index
Go over all dimensions keeping track of index
:: Monad m | |
=> Dims ds | Shape of a space |
-> (Int -> a -> m a) | Function to call with each offset value |
-> Int | Initial offset |
-> Int | Offset step |
-> a | Initial value |
-> m a |
Go over all dimensions keeping track of total offset
:: Monad m | |
=> Dims ds | Shape of a space |
-> (Int -> m ()) | Function to call with each offset value |
-> Int | Initial offset |
-> Int | Offset step |
-> m () |
Go over all dimensions keeping track of total offset
:: Monad m | |
=> Dims ds | Shape of a space |
-> (Idxs ds -> Int -> a -> m a) | Function to call on each dimension |
-> Int | Initial offset |
-> Int | Offset step (substracted from initial offset) |
-> a | Initial value |
-> m a |
Go over all dimensions in reverse order keeping track of index and offset
:: Monad m | |
=> Dims ds | Shape of a space |
-> (Idxs ds -> a -> m a) | Function to call on each dimension |
-> a | Initial value |
-> m a |
Go over all dimensions in reverse order keeping track of index
:: Dims ds | Shape of a space |
-> (Idxs ds -> Int -> a -> a) | Function to call on each dimension |
-> Int | Initial offset |
-> Int | Offset step |
-> a | Initial value |
-> a |
Fold over all dimensions keeping track of index and offset
:: Dims ds | Shape of a space |
-> (Idxs ds -> a -> a) | Function to call on each dimension |
-> a | Initial value |
-> a |
Fold over all dimensions keeping track of index
:: Dims ds | Shape of a space |
-> (Int -> a -> a) | Function to call on each dimension |
-> Int | Initial offset |
-> Int | Offset step |
-> a | Initial value |
-> a |
Fold over all dimensions keeping track of total offset
:: Dims ds | Shape of a space |
-> (Idxs ds -> Int -> a -> a) | Function to call on each dimension |
-> Int | Initial offset |
-> Int | Offset step (substracted from initial offset) |
-> a | Initial value |
-> a |
Fold over all dimensions in reverse order keeping track of index and offset
:: Dims ds | Shape of a space |
-> (Idxs ds -> a -> a) | Function to call on each dimension |
-> a | Initial value |
-> a |
Fold over all dimensions in reverse order keeping track of index
:: (Dimensions ds, Monad m) | |
=> Idxs ds | Initial indices |
-> Idxs ds | Final indices |
-> (Idxs ds -> Int -> a -> m a) | Function to call on each dimension |
-> Int | Initial offset (at index |
-> Int | Offset step |
-> a | initial value |
-> m a |
Traverse from the first index to the second index in each dimension. You can combine positive and negative traversal directions along different dimensions.
Note, initial and final indices are included in the range; the argument function is guaranteed to execute at least once.
:: Monad m | |
=> Idxs ds | Initial indices |
-> Idxs ds | Final indices |
-> (Idxs ds -> a -> m a) | Function to call on each dimension |
-> a | initial value |
-> m a |
Traverse from the first index to the second index in each dimension. You can combine positive and negative traversal directions along different dimensions.
Note, initial and final indices are included in the range; the argument function is guaranteed to execute at least once.