dimensions-1.0.0.0: Safe type-level dimensionality for multidimensional data.

Copyright(c) Artem Chirkin
LicenseBSD3
Maintainerchirkin@arch.ethz.ch
Safe HaskellNone
LanguageHaskell2010

Numeric.Dimensions.Fold

Description

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.

Synopsis

Documentation

overDim Source #

Arguments

:: 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

overDim_ Source #

Arguments

:: 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

overDimIdx Source #

Arguments

:: 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

overDimIdx_ Source #

Arguments

:: Monad m 
=> Dims ds

Shape of a space

-> (Idxs ds -> m ())

Function to call on each dimension

-> m () 

Go over all dimensions keeping track of index

overDimOff Source #

Arguments

:: 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

overDimOff_ Source #

Arguments

:: 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

overDimReverse Source #

Arguments

:: 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

overDimReverseIdx Source #

Arguments

:: 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

foldDim Source #

Arguments

:: 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

foldDimIdx Source #

Arguments

:: 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

foldDimOff Source #

Arguments

:: 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

foldDimReverse Source #

Arguments

:: 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

foldDimReverseIdx Source #

Arguments

:: 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

overDimPart Source #

Arguments

:: (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 minBound :: Idxs ds) Note, this is not an offset value at initial indices.

-> 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.

overDimPartIdx Source #

Arguments

:: 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.