Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- data Shape (rank :: Nat) a where
- foldl :: forall a b r. Foldable (Shape r) => (b -> a -> b) -> b -> Shape r a -> b
- foldr :: forall a b r. Foldable (Shape r) => (a -> b -> b) -> b -> Shape r a -> b
- foldl' :: forall a b r. Foldable (Shape r) => (b -> a -> b) -> b -> Shape r a -> b
- foldl1 :: forall b r. Foldable (Shape (S r)) => (b -> b -> b) -> Shape (S r) b -> b
- foldr1 :: forall b r. Foldable (Shape (S r)) => (b -> b -> b) -> Shape (S r) b -> b
- map :: forall a b r. Applicative (Shape r) => (a -> b) -> Shape r a -> Shape r b
- map2 :: forall a b c r. Applicative (Shape r) => (a -> b -> c) -> Shape r a -> Shape r b -> Shape r c
- reverseShape :: Shape n a -> Shape n a
- data Nat
- shapeSize :: Foldable (Shape n) => Shape n a -> Int
- data SNat :: Nat -> * where
- weaklyDominates :: (Ord a, Applicative (Shape n), Foldable (Shape n)) => Shape n a -> Shape n a -> Bool
- strictlyDominates :: (Ord a, Applicative (Shape n), Foldable (Shape n)) => Shape n a -> Shape n a -> Bool
- shapeToList :: Shape n a -> [a]
- type Index rank = Shape rank Int
- backwards :: (Traversable t, Applicative f) => ((a -> Backwards f b) -> t a -> Backwards f (t b)) -> (a -> f b) -> t a -> f (t b)
- class Unbox (Shape n a) => UnBoxedShapeMorphism n a where
- unShapeVector :: (UnBoxedShapeMorphism n a, Traversable (Shape n), Unbox a) => Vector (Shape n a) -> (Int, Shape n (Vector a))
- reShapeVector :: (UnBoxedShapeMorphism n a, Traversable (Shape n), Unbox a) => (Int, Shape n (Vector a)) -> Vector (Shape n a)
- traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

# Shape

data Shape (rank :: Nat) a where Source #

## Instances

(Unbox a, Unbox (Shape (S n) a)) => Vector Vector (Shape (S (S n)) a) Source # | |

Defined in Numerical.Array.Shape basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Shape (S (S n)) a) -> m (Vector (Shape (S (S n)) a)) # basicUnsafeThaw :: PrimMonad m => Vector (Shape (S (S n)) a) -> m (Mutable Vector (PrimState m) (Shape (S (S n)) a)) # basicLength :: Vector (Shape (S (S n)) a) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (Shape (S (S n)) a) -> Vector (Shape (S (S n)) a) # basicUnsafeIndexM :: Monad m => Vector (Shape (S (S n)) a) -> Int -> m (Shape (S (S n)) a) # basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Shape (S (S n)) a) -> Vector (Shape (S (S n)) a) -> m () # elemseq :: Vector (Shape (S (S n)) a) -> Shape (S (S n)) a -> b -> b # | |

Unbox a => Vector Vector (Shape (S Z) a) Source # | |

Defined in Numerical.Array.Shape basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Shape (S Z) a) -> m (Vector (Shape (S Z) a)) # basicUnsafeThaw :: PrimMonad m => Vector (Shape (S Z) a) -> m (Mutable Vector (PrimState m) (Shape (S Z) a)) # basicLength :: Vector (Shape (S Z) a) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (Shape (S Z) a) -> Vector (Shape (S Z) a) # basicUnsafeIndexM :: Monad m => Vector (Shape (S Z) a) -> Int -> m (Shape (S Z) a) # basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Shape (S Z) a) -> Vector (Shape (S Z) a) -> m () # elemseq :: Vector (Shape (S Z) a) -> Shape (S Z) a -> b -> b # | |

Unbox a => Vector Vector (Shape Z a) Source # | |

Defined in Numerical.Array.Shape basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Shape Z a) -> m (Vector (Shape Z a)) # basicUnsafeThaw :: PrimMonad m => Vector (Shape Z a) -> m (Mutable Vector (PrimState m) (Shape Z a)) # basicLength :: Vector (Shape Z a) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (Shape Z a) -> Vector (Shape Z a) # basicUnsafeIndexM :: Monad m => Vector (Shape Z a) -> Int -> m (Shape Z a) # basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Shape Z a) -> Vector (Shape Z a) -> m () # | |

(Unbox a, Unbox (Shape (S n) a)) => MVector MVector (Shape (S (S n)) a) Source # | |

Defined in Numerical.Array.Shape basicLength :: MVector s (Shape (S (S n)) a) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (Shape (S (S n)) a) -> MVector s (Shape (S (S n)) a) # basicOverlaps :: MVector s (Shape (S (S n)) a) -> MVector s (Shape (S (S n)) a) -> Bool # basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Shape (S (S n)) a)) # basicInitialize :: PrimMonad m => MVector (PrimState m) (Shape (S (S n)) a) -> m () # basicUnsafeReplicate :: PrimMonad m => Int -> Shape (S (S n)) a -> m (MVector (PrimState m) (Shape (S (S n)) a)) # basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Shape (S (S n)) a) -> Int -> m (Shape (S (S n)) a) # basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Shape (S (S n)) a) -> Int -> Shape (S (S n)) a -> m () # basicClear :: PrimMonad m => MVector (PrimState m) (Shape (S (S n)) a) -> m () # basicSet :: PrimMonad m => MVector (PrimState m) (Shape (S (S n)) a) -> Shape (S (S n)) a -> m () # basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Shape (S (S n)) a) -> MVector (PrimState m) (Shape (S (S n)) a) -> m () # basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Shape (S (S n)) a) -> MVector (PrimState m) (Shape (S (S n)) a) -> m () # basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Shape (S (S n)) a) -> Int -> m (MVector (PrimState m) (Shape (S (S n)) a)) # | |

Unbox a => MVector MVector (Shape (S Z) a) Source # | |

Defined in Numerical.Array.Shape basicLength :: MVector s (Shape (S Z) a) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (Shape (S Z) a) -> MVector s (Shape (S Z) a) # basicOverlaps :: MVector s (Shape (S Z) a) -> MVector s (Shape (S Z) a) -> Bool # basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Shape (S Z) a)) # basicInitialize :: PrimMonad m => MVector (PrimState m) (Shape (S Z) a) -> m () # basicUnsafeReplicate :: PrimMonad m => Int -> Shape (S Z) a -> m (MVector (PrimState m) (Shape (S Z) a)) # basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Shape (S Z) a) -> Int -> m (Shape (S Z) a) # basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Shape (S Z) a) -> Int -> Shape (S Z) a -> m () # basicClear :: PrimMonad m => MVector (PrimState m) (Shape (S Z) a) -> m () # basicSet :: PrimMonad m => MVector (PrimState m) (Shape (S Z) a) -> Shape (S Z) a -> m () # basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Shape (S Z) a) -> MVector (PrimState m) (Shape (S Z) a) -> m () # basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Shape (S Z) a) -> MVector (PrimState m) (Shape (S Z) a) -> m () # basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Shape (S Z) a) -> Int -> m (MVector (PrimState m) (Shape (S Z) a)) # | |

Unbox a => MVector MVector (Shape Z a) Source # | |

Defined in Numerical.Array.Shape basicLength :: MVector s (Shape Z a) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (Shape Z a) -> MVector s (Shape Z a) # basicOverlaps :: MVector s (Shape Z a) -> MVector s (Shape Z a) -> Bool # basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Shape Z a)) # basicInitialize :: PrimMonad m => MVector (PrimState m) (Shape Z a) -> m () # basicUnsafeReplicate :: PrimMonad m => Int -> Shape Z a -> m (MVector (PrimState m) (Shape Z a)) # basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Shape Z a) -> Int -> m (Shape Z a) # basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Shape Z a) -> Int -> Shape Z a -> m () # basicClear :: PrimMonad m => MVector (PrimState m) (Shape Z a) -> m () # basicSet :: PrimMonad m => MVector (PrimState m) (Shape Z a) -> Shape Z a -> m () # basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Shape Z a) -> MVector (PrimState m) (Shape Z a) -> m () # basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Shape Z a) -> MVector (PrimState m) (Shape Z a) -> m () # basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Shape Z a) -> Int -> m (MVector (PrimState m) (Shape Z a)) # | |

Functor (Shape r) => Functor (Shape (S r)) Source # | |

Functor (Shape Z) Source # | |

Applicative (Shape r) => Applicative (Shape (S r)) Source # | |

Defined in Numerical.Array.Shape | |

Applicative (Shape Z) Source # | |

Foldable (Shape (S r)) => Foldable (Shape (S (S r))) Source # | |

Defined in Numerical.Array.Shape fold :: Monoid m => Shape (S (S r)) m -> m # foldMap :: Monoid m => (a -> m) -> Shape (S (S r)) a -> m # foldr :: (a -> b -> b) -> b -> Shape (S (S r)) a -> b # foldr' :: (a -> b -> b) -> b -> Shape (S (S r)) a -> b # foldl :: (b -> a -> b) -> b -> Shape (S (S r)) a -> b # foldl' :: (b -> a -> b) -> b -> Shape (S (S r)) a -> b # foldr1 :: (a -> a -> a) -> Shape (S (S r)) a -> a # foldl1 :: (a -> a -> a) -> Shape (S (S r)) a -> a # toList :: Shape (S (S r)) a -> [a] # null :: Shape (S (S r)) a -> Bool # length :: Shape (S (S r)) a -> Int # elem :: Eq a => a -> Shape (S (S r)) a -> Bool # maximum :: Ord a => Shape (S (S r)) a -> a # minimum :: Ord a => Shape (S (S r)) a -> a # | |

Foldable (Shape (S Z)) Source # | |

Defined in Numerical.Array.Shape fold :: Monoid m => Shape (S Z) m -> m # foldMap :: Monoid m => (a -> m) -> Shape (S Z) a -> m # foldr :: (a -> b -> b) -> b -> Shape (S Z) a -> b # foldr' :: (a -> b -> b) -> b -> Shape (S Z) a -> b # foldl :: (b -> a -> b) -> b -> Shape (S Z) a -> b # foldl' :: (b -> a -> b) -> b -> Shape (S Z) a -> b # foldr1 :: (a -> a -> a) -> Shape (S Z) a -> a # foldl1 :: (a -> a -> a) -> Shape (S Z) a -> a # toList :: Shape (S Z) a -> [a] # null :: Shape (S Z) a -> Bool # length :: Shape (S Z) a -> Int # elem :: Eq a => a -> Shape (S Z) a -> Bool # maximum :: Ord a => Shape (S Z) a -> a # minimum :: Ord a => Shape (S Z) a -> a # | |

Foldable (Shape Z) Source # | |

Defined in Numerical.Array.Shape fold :: Monoid m => Shape Z m -> m # foldMap :: Monoid m => (a -> m) -> Shape Z a -> m # foldr :: (a -> b -> b) -> b -> Shape Z a -> b # foldr' :: (a -> b -> b) -> b -> Shape Z a -> b # foldl :: (b -> a -> b) -> b -> Shape Z a -> b # foldl' :: (b -> a -> b) -> b -> Shape Z a -> b # foldr1 :: (a -> a -> a) -> Shape Z a -> a # foldl1 :: (a -> a -> a) -> Shape Z a -> a # elem :: Eq a => a -> Shape Z a -> Bool # maximum :: Ord a => Shape Z a -> a # minimum :: Ord a => Shape Z a -> a # | |

Traversable (Shape (S n)) => Traversable (Shape (S (S n))) Source # | |

Defined in Numerical.Array.Shape traverse :: Applicative f => (a -> f b) -> Shape (S (S n)) a -> f (Shape (S (S n)) b) # sequenceA :: Applicative f => Shape (S (S n)) (f a) -> f (Shape (S (S n)) a) # mapM :: Monad m => (a -> m b) -> Shape (S (S n)) a -> m (Shape (S (S n)) b) # sequence :: Monad m => Shape (S (S n)) (m a) -> m (Shape (S (S n)) a) # | |

Traversable (Shape (S Z)) Source # | |

Defined in Numerical.Array.Shape | |

Traversable (Shape Z) Source # | |

(Eq a, Eq (Shape s a)) => Eq (Shape (S s) a) Source # | |

Eq (Shape Z a) Source # | |

(Data a, Data (Shape n a), Typeable (S n)) => Data (Shape (S n) a) Source # | |

Defined in Numerical.Array.Shape gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Shape (S n) a -> c (Shape (S n) a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Shape (S n) a) # toConstr :: Shape (S n) a -> Constr # dataTypeOf :: Shape (S n) a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Shape (S n) a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Shape (S n) a)) # gmapT :: (forall b. Data b => b -> b) -> Shape (S n) a -> Shape (S n) a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Shape (S n) a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Shape (S n) a -> r # gmapQ :: (forall d. Data d => d -> u) -> Shape (S n) a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Shape (S n) a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Shape (S n) a -> m (Shape (S n) a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Shape (S n) a -> m (Shape (S n) a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Shape (S n) a -> m (Shape (S n) a) # | |

(Data a, Typeable Z) => Data (Shape Z a) Source # | |

Defined in Numerical.Array.Shape gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Shape Z a -> c (Shape Z a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Shape Z a) # toConstr :: Shape Z a -> Constr # dataTypeOf :: Shape Z a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Shape Z a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Shape Z a)) # gmapT :: (forall b. Data b => b -> b) -> Shape Z a -> Shape Z a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Shape Z a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Shape Z a -> r # gmapQ :: (forall d. Data d => d -> u) -> Shape Z a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Shape Z a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Shape Z a -> m (Shape Z a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Shape Z a -> m (Shape Z a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Shape Z a -> m (Shape Z a) # | |

(Show a, Show (Shape s a)) => Show (Shape (S s) a) Source # | |

Show (Shape Z a) Source # | |

(Semigroup a, Applicative (Shape n)) => Semigroup (Shape n a) Source # | |

(Monoid a, Applicative (Shape n)) => Monoid (Shape n a) Source # | |

(Storable a, Storable (Shape (S n) a)) => Storable (Shape (S (S n)) a) Source # | |

Defined in Numerical.Array.Shape sizeOf :: Shape (S (S n)) a -> Int # alignment :: Shape (S (S n)) a -> Int # peekElemOff :: Ptr (Shape (S (S n)) a) -> Int -> IO (Shape (S (S n)) a) # pokeElemOff :: Ptr (Shape (S (S n)) a) -> Int -> Shape (S (S n)) a -> IO () # peekByteOff :: Ptr b -> Int -> IO (Shape (S (S n)) a) # pokeByteOff :: Ptr b -> Int -> Shape (S (S n)) a -> IO () # peek :: Ptr (Shape (S (S n)) a) -> IO (Shape (S (S n)) a) # poke :: Ptr (Shape (S (S n)) a) -> Shape (S (S n)) a -> IO () # | |

Storable a => Storable (Shape (S Z) a) Source # | |

Defined in Numerical.Array.Shape sizeOf :: Shape (S Z) a -> Int # alignment :: Shape (S Z) a -> Int # peekElemOff :: Ptr (Shape (S Z) a) -> Int -> IO (Shape (S Z) a) # pokeElemOff :: Ptr (Shape (S Z) a) -> Int -> Shape (S Z) a -> IO () # peekByteOff :: Ptr b -> Int -> IO (Shape (S Z) a) # pokeByteOff :: Ptr b -> Int -> Shape (S Z) a -> IO () # | |

Storable a => Storable (Shape Z a) Source # | |

Defined in Numerical.Array.Shape | |

(Unbox a, Unbox (Shape (S n) a)) => Unbox (Shape (S (S n)) a) Source # | |

Defined in Numerical.Array.Shape | |

Unbox a => Unbox (Shape (S Z) a) Source # | |

Defined in Numerical.Array.Shape | |

Unbox a => Unbox (Shape Z a) Source # | |

Defined in Numerical.Array.Shape | |

data MVector s (Shape (S (S n)) a) Source # | |

Defined in Numerical.Array.Shape | |

data MVector s (Shape (S Z) a) Source # | |

Defined in Numerical.Array.Shape | |

data MVector s (Shape Z a) Source # | |

data Vector (Shape (S (S n)) a) Source # | |

Defined in Numerical.Array.Shape | |

data Vector (Shape (S Z) a) Source # | |

data Vector (Shape Z a) Source # | |

# Shape Utilities

map2 :: forall a b c r. Applicative (Shape r) => (a -> b -> c) -> Shape r a -> Shape r b -> Shape r c Source #

reverseShape :: Shape n a -> Shape n a Source #

## Instances

Eq Nat Source # | |

Data Nat Source # | |

Defined in Numerical.Nat gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Nat -> c Nat # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Nat # dataTypeOf :: Nat -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Nat) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Nat) # gmapT :: (forall b. Data b => b -> b) -> Nat -> Nat # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Nat -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Nat -> r # gmapQ :: (forall d. Data d => d -> u) -> Nat -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Nat -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Nat -> m Nat # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Nat -> m Nat # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Nat -> m Nat # | |

Read Nat Source # | |

Show Nat Source # | |

weaklyDominates :: (Ord a, Applicative (Shape n), Foldable (Shape n)) => Shape n a -> Shape n a -> Bool Source #

`weaklyDominates`

is the `<=`

operator lifted onto a sized vector to
induce a partial order relation

strictlyDominates :: (Ord a, Applicative (Shape n), Foldable (Shape n)) => Shape n a -> Shape n a -> Bool Source #

`strictlyDominates`

is the `<`

operator lifted onto a sized vector to
induce a partial order relation

shapeToList :: Shape n a -> [a] Source #

backwards :: (Traversable t, Applicative f) => ((a -> Backwards f b) -> t a -> Backwards f (t b)) -> (a -> f b) -> t a -> f (t b) Source #

# Unboxed Vector Morphism

class Unbox (Shape n a) => UnBoxedShapeMorphism n a where Source #

unShapeMVector :: MVector s (Shape n a) -> (Int, Shape n (MVector s a)) Source #

reShapeMVector :: (Int, Shape n (MVector s a)) -> MVector s (Shape n a) Source #

## Instances

Unbox a => UnBoxedShapeMorphism Z a Source # | |

(Unbox a, UnBoxedShapeMorphism (S n) a) => UnBoxedShapeMorphism (S (S n)) a Source # | |

Unbox a => UnBoxedShapeMorphism (S Z) a Source # | |

unShapeVector :: (UnBoxedShapeMorphism n a, Traversable (Shape n), Unbox a) => Vector (Shape n a) -> (Int, Shape n (Vector a)) Source #

reShapeVector :: (UnBoxedShapeMorphism n a, Traversable (Shape n), Unbox a) => (Int, Shape n (Vector a)) -> Vector (Shape n a) Source #

traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) #

Map each element of a structure to an action, evaluate these actions
from left to right, and collect the results. For a version that ignores
the results see `traverse_`

.