Copyright | (c) Alexey Kuleshevich 2018 |
---|---|

License | BSD3 |

Maintainer | Alexey Kuleshevich <lehins@yandex.ru> |

Stability | experimental |

Portability | non-portable |

Safe Haskell | None |

Language | Haskell2010 |

- type Ix1 = Int
- pattern Ix1 :: Int -> Ix1
- data Ix2 = (:.) !Int !Int
- pattern Ix2 :: Int -> Int -> Ix2
- type Ix3 = IxN 3
- pattern Ix3 :: Int -> Int -> Int -> Ix3
- type Ix4 = IxN 4
- pattern Ix4 :: Int -> Int -> Int -> Int -> Ix4
- type Ix5 = IxN 5
- pattern Ix5 :: Int -> Int -> Int -> Int -> Int -> Ix5
- data IxN (n :: Nat) where
- type family Ix (n :: Nat) = r | r -> n where ...
- toIx2 :: Ix2T -> Ix2
- fromIx2 :: Ix2 -> Ix2T
- toIx3 :: Ix3T -> Ix3
- fromIx3 :: Ix3 -> Ix3T
- toIx4 :: Ix4T -> Ix4
- fromIx4 :: Ix4 -> Ix4T
- toIx5 :: Ix5T -> Ix5
- fromIx5 :: Ix5 -> Ix5T
- data Border e
- handleBorderIndex :: Index ix => Border e -> ix -> (ix -> e) -> ix -> e
- newtype Dim = Dim Int
- data Ix0 = Ix0
- type Ix1T = Int
- type Ix2T = (Int, Int)
- type Ix3T = (Int, Int, Int)
- type Ix4T = (Int, Int, Int, Int)
- type Ix5T = (Int, Int, Int, Int, Int)
- type family Lower ix :: *
- class (Eq ix, Ord ix, Show ix, NFData ix) => Index ix where
- errorIx :: (Show ix, Show ix') => String -> ix -> ix' -> a
- isSafeSize :: Index ix => ix -> Bool
- isNonEmpty :: Index ix => ix -> Bool
- headDim :: Index ix => ix -> Int
- tailDim :: Index ix => ix -> Lower ix
- lastDim :: Index ix => ix -> Int
- initDim :: Index ix => ix -> Lower ix
- iterLinearM :: (Index ix, Monad m) => ix -> Int -> Int -> Int -> (Int -> Int -> Bool) -> a -> (Int -> ix -> a -> m a) -> m a
- iterLinearM_ :: (Index ix, Monad m) => ix -> Int -> Int -> Int -> (Int -> Int -> Bool) -> (Int -> ix -> m ()) -> m ()
- loop :: Int -> (Int -> Bool) -> (Int -> Int) -> a -> (Int -> a -> a) -> a
- loopM :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> a -> (Int -> a -> m a) -> m a
- loopM_ :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> (Int -> m a) -> m ()

# Documentation

Bounded Ix2 Source # | |

Eq Ix2 Source # | |

Num Ix2 Source # | |

Ord Ix2 Source # | |

Show Ix2 Source # | |

NFData Ix2 Source # | |

Unbox Ix2 Source # | Unboxing of a |

Index Ix2 Source # | |

Vector Vector Ix2 Source # | |

MVector MVector Ix2 Source # | |

Load DW Ix2 e Source # | |

data Vector Ix2 Source # | |

type Rank Ix2 Source # | |

type Lower Ix2 Source # | |

data MVector s Ix2 Source # | |

data IxN (n :: Nat) where Source #

Bounded Ix3 Source # | |

Num Ix3 Source # | |

((<=) 3 n, Unbox (Ix ((-) n 1))) => Vector Vector (IxN n) Source # | |

((<=) 3 n, Unbox (Ix ((-) n 1))) => MVector MVector (IxN n) Source # | |

((<=) 4 n, KnownNat n, Index (Ix ((-) n 1)), (~) * (IxN ((-) n 1)) (Ix ((-) n 1))) => Bounded (IxN n) Source # | |

Eq (Ix ((-) n 1)) => Eq (IxN n) Source # | |

((<=) 4 n, KnownNat n, Index (Ix ((-) n 1)), (~) * (IxN ((-) n 1)) (Ix ((-) n 1))) => Num (IxN n) Source # | |

Ord (Ix ((-) n 1)) => Ord (IxN n) Source # | |

Show (Ix ((-) n 1)) => Show (IxN n) Source # | |

NFData (IxN n) Source # | |

((<=) 3 n, Unbox (Ix ((-) n 1))) => Unbox (IxN n) Source # | Unboxing of a |

((<=) 4 n, KnownNat n, Index (Ix ((-) n 1)), (~) * (IxN ((-) n 1)) (Ix ((-) n 1))) => Index (IxN n) Source # | |

Index (IxN 3) Source # | |

type Rank Ix3 Source # | |

data MVector s (IxN n) Source # | |

data Vector (IxN n) Source # | |

type Rank (IxN n) Source # | |

type Lower (IxN n) Source # | |

Approach to be used near the borders during various transformations. Whenever a function needs information not only about an element of interest, but also about it's neighbours, it will go out of bounds around the image edges, hence is this set of approaches that can be used in such situtation.

Fill e | Fill in a constant element. ```
outside | Image | outside
(
``` |

Wrap | Wrap around from the opposite border of the array. ```
outside | Image | outside
``` |

Edge | Replicate the element at the edge. ```
outside | Image | outside
``` |

Reflect | Mirror like reflection. ```
outside | Image | outside
``` |

Continue | Also mirror like reflection, but without repeating the edge element. ```
outside | Image | outside
``` |

:: Index ix | |

=> Border e | Broder resolution technique |

-> ix | Size |

-> (ix -> e) | Index function that produces an element |

-> ix | Index |

-> e |

Apply a border resolution technique to an index

class (Eq ix, Ord ix, Show ix, NFData ix) => Index ix where Source #

rank, totalElem, consDim, unconsDim, snocDim, unsnocDim, dropDim, getIndex, setIndex, pureIndex, liftIndex2

totalElem :: ix -> Int Source #

Total number of elements in an array of this size.

consDim :: Int -> Lower ix -> ix Source #

unconsDim :: ix -> (Int, Lower ix) Source #

snocDim :: Lower ix -> Int -> ix Source #

unsnocDim :: ix -> (Lower ix, Int) Source #

dropDim :: ix -> Dim -> Maybe (Lower ix) Source #

getIndex :: ix -> Dim -> Maybe Int Source #

setIndex :: ix -> Dim -> Int -> Maybe ix Source #

pureIndex :: Int -> ix Source #

liftIndex2 :: (Int -> Int -> Int) -> ix -> ix -> ix Source #

Zip together two indices with a function

liftIndex :: (Int -> Int) -> ix -> ix Source #

Map a function over an index

:: ix | Size |

-> ix | Index |

-> Bool |

Check whether index is within the size.

Check whether index is within the size.

:: ix | Size |

-> ix | Index |

-> Int |

Produce linear index from size and index

Produce linear index from size and index

toLinearIndexAcc :: Int -> ix -> ix -> Int Source #

toLinearIndexAcc :: Index (Lower ix) => Int -> ix -> ix -> Int Source #

fromLinearIndex :: ix -> Int -> ix Source #

Produce N Dim index from size and linear index

fromLinearIndex :: Index (Lower ix) => ix -> Int -> ix Source #

Produce N Dim index from size and linear index

fromLinearIndexAcc :: ix -> Int -> (Int, ix) Source #

fromLinearIndexAcc :: Index (Lower ix) => ix -> Int -> (Int, ix) Source #

repairIndex :: ix -> ix -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> ix Source #

repairIndex :: Index (Lower ix) => ix -> ix -> (Int -> Int -> Int) -> (Int -> Int -> Int) -> ix Source #

iter :: ix -> ix -> Int -> (Int -> Int -> Bool) -> a -> (ix -> a -> a) -> a Source #

:: Monad m | |

=> ix | Start index |

-> ix | End index |

-> Int | Increment |

-> (Int -> Int -> Bool) | Continue iteration while predicate is True (eg. until end of row) |

-> a | Initial value for an accumulator |

-> (ix -> a -> m a) | Accumulator function |

-> m a |

:: (Index (Lower ix), Monad m) | |

=> ix | Start index |

-> ix | End index |

-> Int | Increment |

-> (Int -> Int -> Bool) | Continue iteration while predicate is True (eg. until end of row) |

-> a | Initial value for an accumulator |

-> (ix -> a -> m a) | Accumulator function |

-> m a |

iterM_ :: Monad m => ix -> ix -> Int -> (Int -> Int -> Bool) -> (ix -> m a) -> m () Source #

iterM_ :: (Index (Lower ix), Monad m) => ix -> ix -> Int -> (Int -> Int -> Bool) -> (ix -> m a) -> m () Source #

isSafeSize :: Index ix => ix -> Bool Source #

Checks whether the size is valid.

isNonEmpty :: Index ix => ix -> Bool Source #

Checks whether array with this size can hold at least one element.

:: (Index ix, Monad m) | |

=> ix | Size |

-> Int | Linear start |

-> Int | Linear end |

-> Int | Increment |

-> (Int -> Int -> Bool) | Continuation condition (continue if True) |

-> a | Accumulator |

-> (Int -> ix -> a -> m a) | |

-> m a |

Iterate over N-dimensional space from start to end with accumulator

loop :: Int -> (Int -> Bool) -> (Int -> Int) -> a -> (Int -> a -> a) -> a Source #

Efficient loop with an accumulator