Copyright | (c) Grant Weyburne 2022 |
---|---|
License | BSD-3 |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Mat ns a
- mVec :: Mat ns a -> Vector a
- mIndices :: Mat ns a -> NonEmpty Pos
- pattern Mat :: forall (ns :: [Nat]) a. Vector a -> NonEmpty Pos -> Mat ns a
- pattern MatU :: forall (ns :: [Nat]) a. (NS ns, HasCallStack) => Vector a -> NonEmpty Pos -> Mat ns a
- type Vec n = Mat '[n]
- type Mat2 n m = Mat '[n, m]
- type Mat3 n m p = Mat '[n, m, p]
- type Mat4 n m p q = Mat '[n, m, p, q]
- type Mat5 n m p q r = Mat '[n, m, p, q, r]
- type Mat6 n m p q r s = Mat '[n, m, p, q, r, s]
- type MatN n = Mat (NN n)
- class ConsMatC ns a b where
- class SnocMatC ns a b where
- data Eof1 = Eof1
- data EofN = EofN
- class MatTupleC ns a where
- toTupleC :: Mat ns a -> MatTupleT ns a
- fromTupleC :: MatTupleT ns a -> Mat ns a
- fmapTupleMatC :: (a -> b) -> MatTupleT ns a -> MatTupleT ns b
- traversalTupleMatC :: Traversal (MatTupleT ns a) (MatTupleT ns b) a b
- type family MatTupleT ns a where ...
- class ListTupleCInternal n where
- toTupleCInternal :: Vec n a -> ListTupleT n a
- fromTupleCInternal :: ListTupleT n a -> Vec n a
- traversalTupleCInternal :: Traversal (ListTupleT n a) (ListTupleT n b) a b
- class MatConvertersC ns where
- matToNestedVecC :: Mat ns a -> MatToNestedVecT ns a
- nestedVecToMatC :: MatToNestedVecT ns a -> Mat ns a
- matToNestedListC :: Mat ns a -> ListNST ns a
- nestedListToMatC :: ListNST ns a -> Either String (Mat ns a)
- matToNestedNonEmptyC :: Mat ns a -> NonEmptyNST ns a
- nestedNonEmptyToMatC :: NonEmptyNST ns a -> Either String (Mat ns a)
- nestedListToMatValidated :: forall ns a x. (x ~ ListNST ns a, ValidateNestedListC x (ValidateNestedListT x), MatConvertersC ns) => ListNST ns a -> Either String (Mat ns a)
- nestedNonEmptyToMatValidated :: forall ns a x. (x ~ NonEmptyNST ns a, ValidateNestedNonEmptyC x (ValidateNestedNonEmptyT x), MatConvertersC ns) => NonEmptyNST ns a -> Either String (Mat ns a)
- type family MatToNestedVecT ns a where ...
- mkMat :: forall ns a. Vector a -> NonEmpty Pos -> Either String (Mat ns a)
- mkMatC :: forall ns a. NS ns => Vector a -> NonEmpty Pos -> Either String (Mat ns a)
- mat :: forall ns a. (HasCallStack, NS ns) => [a] -> Mat ns a
- mat' :: forall ns a. (HasCallStack, NS ns) => [a] -> Mat ns a
- vec :: forall n a. (HasCallStack, PosC n) => [a] -> Vec n a
- vec' :: forall n a. (HasCallStack, PosC n) => [a] -> Vec n a
- mat2 :: forall n m a. (HasCallStack, PosC n, PosC m) => [a] -> Mat2 n m a
- mat2' :: forall n m a. (HasCallStack, PosC n, PosC m) => [a] -> Mat2 n m a
- gen' :: forall ns a. NS ns => ([Int] -> a) -> Mat ns a
- gen :: forall ns a. NS ns => (Int -> a) -> Mat ns a
- mm :: forall ns. NS ns => Mat ns Int
- buildMat :: forall ns a b. NS ns => ([FinMat ns] -> [FinMat ns] -> b -> FinMat ns -> (b, a)) -> b -> (b, Mat ns a)
- (.:) :: forall n a a'. a ~ a' => a -> Vec n a' -> Vec (1 + n) a'
- se1 :: forall a. a -> Vec 1 a
- (.::) :: forall n m ns a. Mat (m ': ns) a -> Mat (n ': (m ': ns)) a -> Mat ((1 + n) ': (m ': ns)) a
- se2 :: forall n ns a. Mat (n ': ns) a -> Mat (1 ': (n ': ns)) a
- (.|) :: forall a a'. a ~ a' => a -> a' -> Vec 2 a'
- (.||) :: forall m ns a. Mat (m ': ns) a -> Mat (m ': ns) a -> Mat (2 ': (m ': ns)) a
- ixMat :: forall (ns :: [Nat]) a. FinMat ns -> Lens' (Mat ns a) a
- ixMat' :: forall (is :: [Nat]) (ns :: [Nat]) a. FinMatC is ns => Lens' (Mat ns a) a
- setMat :: a -> FinMat ns -> Mat ns a -> Mat ns a
- updateMat :: (a -> a) -> FinMat ns -> Mat ns a -> Mat ns a
- indexMat :: FinMat ns -> Mat ns a -> a
- finMatRows :: forall ns. NS ns => NonEmpty (FinMat ns)
- reverseRows :: LeafC ns => Mat ns a -> Mat ns a
- sortByRows :: LeafC ns => (a -> a -> Ordering) -> Mat ns a -> Mat ns a
- multMat :: forall n m p a. Num a => Mat2 n m a -> Mat2 m p a -> Mat2 n p a
- class DotC ns ns' a b fa fb | ns ns' a -> fa, ns ns' b -> fb, ns ns' fa -> a, ns ns' fb -> b, fa fb a b -> ns ns' where
- zipWithMat :: (a -> b -> c) -> Mat ns a -> Mat ns b -> Mat ns c
- zipWithMat3 :: (a -> b -> c -> d) -> Mat ns a -> Mat ns b -> Mat ns c -> Mat ns d
- zipMat :: Mat ns a -> Mat ns b -> Mat ns (a, b)
- zipWithMatA :: Applicative f => (a -> b -> f c) -> Mat ns a -> Mat ns b -> f (Mat ns c)
- izipWith :: NS ns => (FinMat ns -> a -> b -> c) -> Mat ns a -> Mat ns b -> Mat ns c
- izipWithM :: (NS ns, Applicative f) => (FinMat ns -> a -> b -> f c) -> Mat ns a -> Mat ns b -> f (Mat ns c)
- cartesian :: (a -> b -> c) -> Mat (n ': ns) a -> Mat (n' ': ns') b -> Mat (n ': (ns ++ (n' ': ns'))) c
- pureMat :: forall ns a. NS ns => a -> Mat ns a
- replicateMat :: forall n n1 ns a. PosC n => Mat (n1 ': ns) a -> Mat (n ': (n1 ': ns)) a
- determinant :: Num a => Mat2 n n a -> a
- deleteColumnL :: forall a. Pos -> Int -> [a] -> [a]
- deleteRow :: forall (i :: Nat) (n :: Nat) (ns :: [Nat]) a. FinC i (1 + n) => Mat ((1 + n) ': ns) a -> Mat (n ': ns) a
- deleteRow' :: forall n ns a. Fin (1 + n) -> Mat ((1 + n) ': ns) a -> Mat (n ': ns) a
- insertRow :: forall i n m ns a. FinC i (1 + n) => Mat (m ': ns) a -> Mat (n ': (m ': ns)) a -> Mat ((1 + n) ': (m ': ns)) a
- insertRow' :: forall n m ns a. Fin (1 + n) -> Mat (m ': ns) a -> Mat (n ': (m ': ns)) a -> Mat ((1 + n) ': (m ': ns)) a
- swapRow :: forall (i :: Nat) (j :: Nat) (n :: Nat) ns a. (FinC i n, FinC j n) => Mat (n ': ns) a -> Mat (n ': ns) a
- swapRow' :: forall (n :: Nat) ns a. Fin n -> Fin n -> Mat (n ': ns) a -> Mat (n ': ns) a
- _row :: forall (i :: Nat) (ns :: [Nat]) a. SliceC '[i] ns => Lens' (Mat ns a) (SliceT '[i] ns a)
- _row' :: forall (n :: Nat) (ns :: [Nat]) a. SliceC' '[n] ns => Fin n -> Lens' (Mat ns a) (SliceT' '[n] ns a)
- rows :: forall n m ns a. Mat (n ': (m ': ns)) a -> Vec n (Mat (m ': ns) a)
- unrows :: forall n m ns a. Vec n (Mat (m ': ns) a) -> Mat (n ': (m ': ns)) a
- _rows :: forall n m ns a b. Iso (Mat (n ': (m ': ns)) a) (Mat (n ': (m ': ns)) b) (Vec n (Mat (m ': ns) a)) (Vec n (Mat (m ': ns) b))
- wrapRows1 :: LeafC ns => (NonEmpty a -> NonEmpty b) -> Mat ns a -> Either String (Mat ns b)
- indexRow :: Fin n -> Mat (n ': (m ': ns)) a -> Mat (m ': ns) a
- deleteCol :: forall (i :: Nat) (n :: Nat) (n1 :: Nat) ns a. FinC i (1 + n1) => Mat (n ': ((1 + n1) ': ns)) a -> Mat (n ': (n1 ': ns)) a
- deleteCol' :: forall (n :: Nat) (n1 :: Nat) ns a. Fin (1 + n1) -> Mat (n ': ((1 + n1) ': ns)) a -> Mat (n ': (n1 ': ns)) a
- insertCol :: forall (i :: Nat) (n :: Nat) (n1 :: Nat) ns a. FinC i (1 + n1) => Mat (n ': ns) a -> Mat (n ': (n1 ': ns)) a -> Mat (n ': ((1 + n1) ': ns)) a
- insertCol' :: forall (n :: Nat) (n1 :: Nat) ns a. Fin (1 + n1) -> Mat (n ': ns) a -> Mat (n ': (n1 ': ns)) a -> Mat (n ': ((1 + n1) ': ns)) a
- swapCol :: forall (i :: Nat) (j :: Nat) (n :: Nat) (n1 :: Nat) ns a. (FinC i n1, FinC j n1) => Mat (n ': (n1 ': ns)) a -> Mat (n ': (n1 ': ns)) a
- swapCol' :: forall (n :: Nat) (n1 :: Nat) ns a. Fin n1 -> Fin n1 -> Mat (n ': (n1 ': ns)) a -> Mat (n ': (n1 ': ns)) a
- _col :: forall (i :: Nat) n m ns a. FinC i m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _col' :: forall n m ns a. Fin m -> Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- swapMat :: forall (is :: [Nat]) (js :: [Nat]) ns a. (FinMatC is ns, FinMatC js ns) => Mat ns a -> Mat ns a
- swapMat' :: forall ns a. FinMat ns -> FinMat ns -> Mat ns a -> Mat ns a
- appendV :: Mat (n ': ns) a -> Mat (n' ': ns) a -> Mat ((n + n') ': ns) a
- appendH :: forall n m m' ns a. Mat (n ': (m ': ns)) a -> Mat (n ': (m' ': ns)) a -> Mat (n ': ((m + m') ': ns)) a
- permutationsMat :: forall n a. Vec n a -> Mat2 (FacT n) n a
- findMatElems :: NS ns => (a -> Bool) -> Mat ns a -> [(FinMat ns, a)]
- bulkMat :: Vec x (FinMat ns) -> Lens' (Mat ns a) (Vec x a)
- updatesMat :: forall ns t a b. Foldable t => (FinMat ns -> a -> b -> a) -> t (FinMat ns, b) -> Mat ns a -> Mat ns a
- getsMat :: forall ns a t. Functor t => t (FinMat ns) -> Mat ns a -> t a
- setsMat :: forall ns t a. Foldable t => t (FinMat ns, a) -> Mat ns a -> Mat ns a
- nonEmptyMatsToMat :: forall n m ns a t. (Foldable1 t, PosC n) => t (Mat (m ': ns) a) -> Either String (Mat (n ': (m ': ns)) a)
- _transposeMat :: Iso (Mat (n ': (m ': ns)) a) (Mat (n ': (m ': ns)) b) (Mat (m ': (n ': ns)) a) (Mat (m ': (n ': ns)) b)
- transposeMat :: forall n m ns a. Mat (n ': (m ': ns)) a -> Mat (m ': (n ': ns)) a
- toND :: forall i ns a. PosC i => Mat ns a -> MatToNDT i ns a
- type MatToNDT i ns a = Mat (MatToMatNTA (NatToPeanoT i) ns) (Mat (MatToMatNTB (NatToPeanoT i) ns) a)
- toVec :: Mat ns a -> MatToNDT 1 ns a
- toMat2 :: Mat ns a -> MatToNDT 2 ns a
- toMat3 :: Mat ns a -> MatToNDT 3 ns a
- concatMat :: forall (n :: Nat) (ns :: [Nat]) (m :: Nat) (ms :: [Nat]) a. Mat (n ': ns) (Mat (m ': ms) a) -> Mat (n ': (ns ++ (m ': ms))) a
- redim :: forall ms ns a. (NS ms, ProductT ns ~ ProductT ms) => Mat ns a -> Mat ms a
- reverseDim :: Mat ns a -> Mat (ReverseT ns) a
- rotateLeft :: Mat2 n m a -> Mat2 m n a
- rotateRight :: Mat2 n m a -> Mat2 m n a
- class SliceC is ns where
- type family SliceT is ns a where ...
- class SliceC' ns' ns where
- type family SliceT' ns' ns a where ...
- slice :: forall is ns a z. (z ~ SliceToFinMatT is ns, NS is, NS ns, NS z, SliceC' z ns) => Mat ns a -> SliceT' z ns a
- sliceUpdate :: forall is ns a z. (z ~ SliceToFinMatT is ns, NS is, NS ns, NS z, SliceC' z ns) => Mat ns a -> SliceT' z ns a -> Mat ns a
- sliceToFinMat :: forall is ns. (NS (SliceToFinMatT is ns), NS is, NS ns) => FinMat (SliceToFinMatT is ns)
- type family SliceToFinMatT is ns where ...
- ixSlice :: forall (is :: [Nat]) (ns :: [Nat]) a. SliceC is ns => Lens' (Mat ns a) (SliceT is ns a)
- ixSlice' :: forall (ns' :: [Nat]) (ns :: [Nat]) a. SliceC' ns' ns => FinMat ns' -> Lens' (Mat ns a) (SliceT' ns' ns a)
- subsetRows :: forall i j n ns a. DiffTC i j n => Mat (n ': ns) a -> Mat (DiffT i j n ': ns) a
- subsetCols :: forall i j m n ns a. DiffTC i j n => Mat (m ': (n ': ns)) a -> Mat (m ': (DiffT i j n ': ns)) a
- diagonal :: Mat (n ': (n ': ns)) a -> Mat (n ': ns) a
- rowsToMat :: forall x n m ns a. Vec x (Fin n) -> Mat (n ': (m ': ns)) a -> Mat (x ': (m ': ns)) a
- chunkNV :: forall t a z. Traversable t => t z -> Pos -> Vector a -> Either String (t (Vector a))
- chunkNVMat :: forall ns t x a z. Traversable t => t z -> NonEmpty Pos -> Mat x a -> Either String (t (Mat ns a))
- class LeafC ns where
- traverseLeafC :: Applicative m => (FinMat ns -> Vec (LastT ns) a -> m b) -> Mat ns a -> m (Mat (InitT ns) b)
- fromLeavesInternalC :: Mat (InitT ns) (Vec (LastT ns) a) -> Mat ns a
- traverseLeafSimple :: (LeafC ns, Applicative m) => (FinMat ns -> Vec (LastT ns) a -> m (Vec (LastT ns) b)) -> Mat ns a -> m (Mat ns b)
- mapLeafSimple :: LeafC ns => (FinMat ns -> Vec (LastT ns) a -> Vec (LastT ns) b) -> Mat ns a -> Mat ns b
- foldMapLeaf :: (Monoid z, LeafC ns) => (FinMat ns -> Vec (LastT ns) a -> z) -> Mat ns a -> z
- foldMapLeafR :: (Monoid z, LeafC ns) => (FinMat ns -> Vec (LastT ns) a -> z) -> Mat ns a -> z
- mapLeaf :: LeafC ns => (FinMat ns -> Vec (LastT ns) a -> b) -> Mat ns a -> Mat (InitT ns) b
- mapLeafS :: LeafC ns => (FinMat ns -> c -> Vec (LastT ns) a -> (c, b)) -> c -> Mat ns a -> (c, Mat (InitT ns) b)
- mapLeafSimpleS :: LeafC ns => (FinMat ns -> c -> Vec (LastT ns) a -> (c, Vec (LastT ns) b)) -> c -> Mat ns a -> (c, Mat ns b)
- foldLeaf :: LeafC ns => (FinMat ns -> c -> Vec (LastT ns) a -> c) -> c -> Mat ns a -> c
- toLeaves :: LeafC ns => Mat ns a -> Mat (InitT ns) (Vec (LastT ns) a)
- mapCols :: forall n m ns a b. (FinMat (m ': (n ': ns)) -> Vec (LastT (n ': ns)) a -> Vec (LastT (n ': ns)) b) -> Mat (n ': (m ': ns)) a -> Mat (n ': (m ': ns)) b
- mapCols' :: forall n m ns a b c. (FinMat (m ': (n ': ns)) -> c -> Vec (LastT (n ': ns)) a -> (c, Vec (LastT (n ': ns)) b)) -> c -> Mat (n ': (m ': ns)) a -> (c, Mat (n ': (m ': ns)) b)
- class ShowMatC ns where
- data ShowOpts = ShowOpts {
- smIndent0 :: !Int
- smIndentN :: !Int
- smDivvy :: !Bool
- smInline1D :: !Bool
- smInlineNewLineEof :: !Bool
- smOtherNewLineEof :: !Bool
- defShowOpts :: ShowOpts
- prtMat :: forall ns a. (ShowMatC ns, Show a) => ShowOpts -> Mat ns a -> IO ()
- showMat :: forall ns a. (ShowMatC ns, Show a) => ShowOpts -> Mat ns a -> String
- readMatP :: forall ns a. (MatConvertersC ns, NS ns, Read (ListNST ns a)) => ShowOpts -> ReadP (Mat ns a)
- readMat :: forall ns a. (MatConvertersC ns, NS ns, Read (ListNST ns a)) => ReadS (Mat ns a)
- readMat2 :: (MatConvertersC '[n, m], PosC n, PosC m, Read [[a]]) => ReadS (Mat2 n m a)
- readVec :: (MatConvertersC '[n], PosC n, Read [a]) => ReadS (Vec n a)
- class Row1 s a | s -> a where
- class Row2 s a | s -> a where
- class Row3 s a | s -> a where
- class Row4 s a | s -> a where
- class Row5 s a | s -> a where
- class Row6 s a | s -> a where
- class Row7 s a | s -> a where
- class Row8 s a | s -> a where
- class Row9 s a | s -> a where
- class Row10 s a | s -> a where
- _c1 :: FinC 1 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _c2 :: FinC 2 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _c3 :: FinC 3 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _c4 :: FinC 4 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _c5 :: FinC 5 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _c6 :: FinC 6 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _c7 :: FinC 7 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _c8 :: FinC 8 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _c9 :: FinC 9 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- _c10 :: FinC 10 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a)
- finMatMatrix :: forall ns. NS ns => Mat ns (FinMat ns)
- finMatMatrix' :: forall ns x. NS ns => Mat ns x -> Mat ns (FinMat ns)
- scanlVec :: forall n a b. (b -> a -> b) -> b -> Vec n a -> Vec (n + 1) b
- scanrVec :: forall n a b. (a -> b -> b) -> b -> Vec n a -> Vec (n + 1) b
- postscanlMat :: forall ns a b. (b -> a -> b) -> b -> Mat ns a -> Mat ns b
- postscanrMat :: forall ns a b. (a -> b -> b) -> b -> Mat ns a -> Mat ns b
- dim1 :: Vec n a -> Vec n a
- dim2 :: Mat2 n m a -> Mat2 n m a
- dim3 :: Mat '[n, m, p] a -> Mat '[n, m, p] a
- dim4 :: Mat '[n, m, p, q] a -> Mat '[n, m, p, q] a
- dim5 :: Mat '[n, m, p, q, r] a -> Mat '[n, m, p, q, r] a
- dim6 :: Mat '[n, m, p, q, r, s] a -> Mat '[n, m, p, q, r, s] a
- dim7 :: Mat '[n, m, p, q, r, s, t] a -> Mat '[n, m, p, q, r, s, t] a
- dim8 :: Mat '[n, m, p, q, r, s, t, u] a -> Mat '[n, m, p, q, r, s, t, u] a
- dim9 :: Mat '[n, m, p, q, r, s, t, u, v] a -> Mat '[n, m, p, q, r, s, t, u, v] a
- dim10 :: Mat '[n, m, p, q, r, s, t, u, v, w] a -> Mat '[n, m, p, q, r, s, t, u, v, w] a
Documentation
definition of a matrix
Instances
NS ns => Monad (Mat ns) Source # | |
Functor (Mat ns) Source # | |
NS ns => Applicative (Mat ns) Source # | |
Foldable (Mat ns) Source # | |
Defined in Cybus.Mat fold :: Monoid m => Mat ns m -> m # foldMap :: Monoid m => (a -> m) -> Mat ns a -> m # foldMap' :: Monoid m => (a -> m) -> Mat ns a -> m # foldr :: (a -> b -> b) -> b -> Mat ns a -> b # foldr' :: (a -> b -> b) -> b -> Mat ns a -> b # foldl :: (b -> a -> b) -> b -> Mat ns a -> b # foldl' :: (b -> a -> b) -> b -> Mat ns a -> b # foldr1 :: (a -> a -> a) -> Mat ns a -> a # foldl1 :: (a -> a -> a) -> Mat ns a -> a # elem :: Eq a => a -> Mat ns a -> Bool # maximum :: Ord a => Mat ns a -> a # minimum :: Ord a => Mat ns a -> a # | |
Traversable (Mat ns) Source # | |
NS ns => Distributive (Mat ns) Source # | |
NS ns => Representable (Mat ns) Source # | |
NS ns => MonadZip (Mat ns) Source # | |
NFData1 (Mat ns) Source # | |
Foldable1 (Mat ns) Source # | |
Traversable1 (Mat ns) Source # | |
Apply (Mat ns) Source # | |
NS ns => Bind (Mat ns) Source # | |
Generic1 (Mat ns :: Type -> Type) Source # | |
NS ns => FunctorWithIndex (FinMat ns) (Mat ns) Source # | |
NS ns => FoldableWithIndex (FinMat ns) (Mat ns) Source # | |
Defined in Cybus.Mat ifoldMap :: Monoid m => (FinMat ns -> a -> m) -> Mat ns a -> m # ifoldMap' :: Monoid m => (FinMat ns -> a -> m) -> Mat ns a -> m # ifoldr :: (FinMat ns -> a -> b -> b) -> b -> Mat ns a -> b # ifoldl :: (FinMat ns -> b -> a -> b) -> b -> Mat ns a -> b # ifoldr' :: (FinMat ns -> a -> b -> b) -> b -> Mat ns a -> b # ifoldl' :: (FinMat ns -> b -> a -> b) -> b -> Mat ns a -> b # | |
NS ns => TraversableWithIndex (FinMat ns) (Mat ns) Source # | |
DotC ('[] :: [Nat]) (r ': xs) a b a (Mat (r ': xs) b) Source # | |
NS ns => IsList (Mat ns a) Source # | |
(NS ns, Bounded a) => Bounded (Mat ns a) Source # | |
(Enum a, Bounded a, NS ns) => Enum (Mat ns a) Source # | |
Eq a => Eq (Mat ns a) Source # | |
(NS ns, Fractional a) => Fractional (Mat ns a) Source # | |
(NS ns, Num a) => Num (Mat ns a) Source # | |
Ord a => Ord (Mat ns a) Source # | |
(MatConvertersC ns, NS ns, Read (ListNST ns a)) => Read (Mat ns a) Source # | |
(Show a, ShowMatC ns, NS ns) => Show (Mat ns a) Source # | |
(c ~ Char, NS ns) => IsString (Mat ns c) Source # | |
Defined in Cybus.Mat fromString :: String -> Mat ns c # | |
Generic (Mat ns a) Source # | |
Semigroup a => Semigroup (Mat ns a) Source # | |
(Monoid a, NS ns) => Monoid (Mat ns a) Source # | |
NFData a => NFData (Mat ns a) Source # | |
(Bounded a, Enum a) => Num1 (Mat ns a) Source # | |
Defined in Cybus.Mat toInteger1 :: Mat ns a -> Integer # fromInteger1 :: Mat ns a -> Integer -> Either String (Mat ns a) # (.+) :: Either String (Mat ns a) -> Either String (Mat ns a) -> Either String (Mat ns a) # (.-) :: Either String (Mat ns a) -> Either String (Mat ns a) -> Either String (Mat ns a) # (.*) :: Either String (Mat ns a) -> Either String (Mat ns a) -> Either String (Mat ns a) # negate1 :: Either String (Mat ns a) -> Either String (Mat ns a) # abs1 :: Either String (Mat ns a) -> Either String (Mat ns a) # signum1 :: Either String (Mat ns a) -> Either String (Mat ns a) # succ1 :: Either String (Mat ns a) -> Either String (Mat ns a) # pred1 :: Either String (Mat ns a) -> Either String (Mat ns a) # | |
FinC 10 n => Row10 (Vec n a) a Source # | |
FinC 9 n => Row9 (Vec n a) a Source # | |
FinC 8 n => Row8 (Vec n a) a Source # | |
FinC 7 n => Row7 (Vec n a) a Source # | |
FinC 6 n => Row6 (Vec n a) a Source # | |
FinC 5 n => Row5 (Vec n a) a Source # | |
FinC 4 n => Row4 (Vec n a) a Source # | |
FinC 3 n => Row3 (Vec n a) a Source # | |
FinC 2 n => Row2 (Vec n a) a Source # | |
FinC 1 n => Row1 (Vec n a) a Source # | lens into the first element in a 1d matrix |
FinC 10 n => Row10 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | |
FinC 9 n => Row9 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | |
FinC 8 n => Row8 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | |
FinC 7 n => Row7 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | |
FinC 6 n => Row6 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | |
FinC 5 n => Row5 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | |
FinC 4 n => Row4 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | |
FinC 3 n => Row3 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | |
FinC 2 n => Row2 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | |
FinC 1 n => Row1 (Mat (n ': (m ': ns)) a) (Mat (m ': ns) a) Source # | lens into the first row in a 2d or greater matrix |
DotC (q ': ns) ('[] :: [Nat]) a b (Mat (q ': ns) a) b Source # | |
DotC (q ': ns) (r ': xs) a b (Mat (q ': ns) a) (Mat (r ': xs) b) Source # | |
type Rep (Mat ns) Source # | |
type Rep1 (Mat ns :: Type -> Type) Source # | |
Defined in Cybus.Mat type Rep1 (Mat ns :: Type -> Type) = D1 ('MetaData "Mat" "Cybus.Mat" "cybus-0.3.0.0-2tgktn1zjvk47vpww9PCqf" 'False) (C1 ('MetaCons "MatUnsafe" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec1 Vector) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NonEmpty Pos)))) | |
type Rep (Mat ns a) Source # | |
Defined in Cybus.Mat type Rep (Mat ns a) = D1 ('MetaData "Mat" "Cybus.Mat" "cybus-0.3.0.0-2tgktn1zjvk47vpww9PCqf" 'False) (C1 ('MetaCons "MatUnsafe" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Vector a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NonEmpty Pos)))) | |
type Item (Mat ns a) Source # | |
pattern Mat :: forall (ns :: [Nat]) a. Vector a -> NonEmpty Pos -> Mat ns a Source #
readonly pattern synonym for a matrix
pattern MatU :: forall (ns :: [Nat]) a. (NS ns, HasCallStack) => Vector a -> NonEmpty Pos -> Mat ns a Source #
bidirectional pattern synonym for validating a matrix before construction with NS
constraint for additional typelevel validation
type MatN n = Mat (NN n) Source #
convenient type synonym for specifying the dimensions of a matrix using each digit as a dimension
cons/snoc lenses
class ConsMatC ns a b where Source #
iso and lenses to uncons a matrix
consMat :: Iso (Mat ns a) (Mat ns b) (ConsMatCTA ns a, ConsMatCTB ns a) (ConsMatCTA ns b, ConsMatCTB ns b) Source #
headMat :: a ~ b => Lens' (Mat ns a) (ConsMatCTA ns a) Source #
tailMat :: a ~ b => Lens' (Mat ns a) (ConsMatCTB ns a) Source #
Instances
(ConsMatCTA (n ': (m ': ns)) a ~ Mat (m ': ns) a, ConsMatCTA (n ': (m ': ns)) b ~ Mat (m ': ns) b, ConsMatCTB (n ': (m ': ns)) a ~ Mat ((n - 1) ': (m ': ns)) a, ConsMatCTB (n ': (m ': ns)) b ~ Mat ((n - 1) ': (m ': ns)) b) => ConsMatC (n ': (m ': ns)) a b Source # | |
Defined in Cybus.Mat consMat :: Iso (Mat (n ': (m ': ns)) a) (Mat (n ': (m ': ns)) b) (ConsMatCTA (n ': (m ': ns)) a, ConsMatCTB (n ': (m ': ns)) a) (ConsMatCTA (n ': (m ': ns)) b, ConsMatCTB (n ': (m ': ns)) b) Source # headMat :: Lens' (Mat (n ': (m ': ns)) a) (ConsMatCTA (n ': (m ': ns)) a) Source # tailMat :: Lens' (Mat (n ': (m ': ns)) a) (ConsMatCTB (n ': (m ': ns)) a) Source # | |
(ConsMatCTA '[n] a ~ a, ConsMatCTA '[n] b ~ b, ConsMatCTB '[n] a ~ Vec (n - 1) a, ConsMatCTB '[n] b ~ Vec (n - 1) b) => ConsMatC '[n] a b Source # | |
(ConsMatCTA (1 ': (m ': ns)) a ~ Mat (m ': ns) a, ConsMatCTA (1 ': (m ': ns)) b ~ Mat (m ': ns) b, ConsMatCTB (1 ': (m ': ns)) a ~ EofN, ConsMatCTB (1 ': (m ': ns)) b ~ EofN) => ConsMatC (1 ': (n1 ': ns)) a b Source # | |
Defined in Cybus.Mat consMat :: Iso (Mat (1 ': (n1 ': ns)) a) (Mat (1 ': (n1 ': ns)) b) (ConsMatCTA (1 ': (n1 ': ns)) a, ConsMatCTB (1 ': (n1 ': ns)) a) (ConsMatCTA (1 ': (n1 ': ns)) b, ConsMatCTB (1 ': (n1 ': ns)) b) Source # headMat :: Lens' (Mat (1 ': (n1 ': ns)) a) (ConsMatCTA (1 ': (n1 ': ns)) a) Source # tailMat :: Lens' (Mat (1 ': (n1 ': ns)) a) (ConsMatCTB (1 ': (n1 ': ns)) a) Source # | |
(ConsMatCTA '[1] a ~ a, ConsMatCTA '[1] b ~ b, ConsMatCTB '[1] a ~ Eof1, ConsMatCTB '[1] b ~ Eof1) => ConsMatC '[1] a b Source # | |
class SnocMatC ns a b where Source #
iso and lenses to unsnoc a matrix
snocMat :: Iso (Mat ns a) (Mat ns b) (ConsMatCTB ns a, ConsMatCTA ns a) (ConsMatCTB ns b, ConsMatCTA ns b) Source #
initMat :: a ~ b => Lens' (Mat ns a) (ConsMatCTB ns a) Source #
lastMat :: a ~ b => Lens' (Mat ns a) (ConsMatCTA ns a) Source #
Instances
(ConsMatCTB (n ': (m ': ns)) a ~ Mat ((n - 1) ': (m ': ns)) a, ConsMatCTB (n ': (m ': ns)) a ~ Mat ((n - 1) ': (m ': ns)) b) => SnocMatC (n ': (m ': ns)) a b Source # | |
Defined in Cybus.Mat snocMat :: Iso (Mat (n ': (m ': ns)) a) (Mat (n ': (m ': ns)) b) (ConsMatCTB (n ': (m ': ns)) a, ConsMatCTA (n ': (m ': ns)) a) (ConsMatCTB (n ': (m ': ns)) b, ConsMatCTA (n ': (m ': ns)) b) Source # initMat :: Lens' (Mat (n ': (m ': ns)) a) (ConsMatCTB (n ': (m ': ns)) a) Source # lastMat :: Lens' (Mat (n ': (m ': ns)) a) (ConsMatCTA (n ': (m ': ns)) a) Source # | |
(ConsMatCTB '[n] a ~ Vec (n - 1) a, ConsMatCTB '[n] b ~ Vec (n - 1) b) => SnocMatC '[n] a b Source # | |
SnocMatC (1 ': (n1 ': ns)) a b Source # | |
Defined in Cybus.Mat snocMat :: Iso (Mat (1 ': (n1 ': ns)) a) (Mat (1 ': (n1 ': ns)) b) (ConsMatCTB (1 ': (n1 ': ns)) a, ConsMatCTA (1 ': (n1 ': ns)) a) (ConsMatCTB (1 ': (n1 ': ns)) b, ConsMatCTA (1 ': (n1 ': ns)) b) Source # initMat :: Lens' (Mat (1 ': (n1 ': ns)) a) (ConsMatCTB (1 ': (n1 ': ns)) a) Source # lastMat :: Lens' (Mat (1 ': (n1 ': ns)) a) (ConsMatCTA (1 ': (n1 ': ns)) a) Source # | |
SnocMatC '[1] a b Source # | |
marker representing the last value in a 1d matrix ie singleton
marker representing the last row in a nd matrix ie singleton
tuple conversions
class MatTupleC ns a where Source #
convert a between a matrix and a nested tuple
Instances
(TypeError ('Text "MatTupleC '[]: undefined for empty indices") :: Constraint) => MatTupleC ('[] :: [Nat]) a Source # | |
(ListTupleCInternal n, NS (n1 ': ns), MatTupleC (n1 ': ns) a) => MatTupleC (n ': (n1 ': ns)) a Source # | |
Defined in Cybus.Mat toTupleC :: Mat (n ': (n1 ': ns)) a -> MatTupleT (n ': (n1 ': ns)) a Source # fromTupleC :: MatTupleT (n ': (n1 ': ns)) a -> Mat (n ': (n1 ': ns)) a Source # fmapTupleMatC :: (a -> b) -> MatTupleT (n ': (n1 ': ns)) a -> MatTupleT (n ': (n1 ': ns)) b Source # traversalTupleMatC :: Traversal (MatTupleT (n ': (n1 ': ns)) a) (MatTupleT (n ': (n1 ': ns)) b) a b Source # | |
ListTupleCInternal n => MatTupleC '[n] a Source # | |
type family MatTupleT ns a where ... Source #
convert a matrix to a nested tuple
MatTupleT '[] _ = TypeError ('Text "MatTupleT '[]: undefined for empty indices") | |
MatTupleT '[n] a = ListTupleT n a | |
MatTupleT (n ': (n1 ': ns)) a = ListTupleT n (MatTupleT (n1 ': ns) a) |
class ListTupleCInternal n where Source #
conversions between n-tuple and Vec
toTupleCInternal :: Vec n a -> ListTupleT n a Source #
convert a Vec
to a tuple
fromTupleCInternal :: ListTupleT n a -> Vec n a Source #
convert a tuple of type "a" to Vec
traversalTupleCInternal :: Traversal (ListTupleT n a) (ListTupleT n b) a b Source #
traversal over a tuple
Instances
converters
class MatConvertersC ns where Source #
class with methods to convert to and from Mat using nested structures
matToNestedVecC :: Mat ns a -> MatToNestedVecT ns a Source #
nestedVecToMatC :: MatToNestedVecT ns a -> Mat ns a Source #
matToNestedListC :: Mat ns a -> ListNST ns a Source #
convert a Mat
to a nested list
nestedListToMatC :: ListNST ns a -> Either String (Mat ns a) Source #
convert a nested list to a Mat
matToNestedNonEmptyC :: Mat ns a -> NonEmptyNST ns a Source #
convert a Mat
to a nested nonempty list
nestedNonEmptyToMatC :: NonEmptyNST ns a -> Either String (Mat ns a) Source #
convert a nested nonempty list to a Mat
Instances
nestedListToMatValidated :: forall ns a x. (x ~ ListNST ns a, ValidateNestedListC x (ValidateNestedListT x), MatConvertersC ns) => ListNST ns a -> Either String (Mat ns a) Source #
validate and convert from a nested list to a matrix
nestedNonEmptyToMatValidated :: forall ns a x. (x ~ NonEmptyNST ns a, ValidateNestedNonEmptyC x (ValidateNestedNonEmptyT x), MatConvertersC ns) => NonEmptyNST ns a -> Either String (Mat ns a) Source #
validate and convert from a nested nonempty list to a matrix
type family MatToNestedVecT ns a where ... Source #
converts mat dimensions to a nested list
MatToNestedVecT '[] _ = TypeError ('Text "MatToNestedVecT '[]: undefined for empty indices") | |
MatToNestedVecT '[n] a = Vec n a | |
MatToNestedVecT (n ': (n1 ': ns)) a = Vec n (MatToNestedVecT (n1 ': ns) a) |
bulk construct matrix
mkMat :: forall ns a. Vector a -> NonEmpty Pos -> Either String (Mat ns a) Source #
validate before creating a matrix
vec :: forall n a. (HasCallStack, PosC n) => [a] -> Vec n a Source #
create a 1d matrix from a list of values
vec' :: forall n a. (HasCallStack, PosC n) => [a] -> Vec n a Source #
create a 1d matrix from a list of values with the exact number of elements
mat2 :: forall n m a. (HasCallStack, PosC n, PosC m) => [a] -> Mat2 n m a Source #
create a 2d matrix from a list of values
mat2' :: forall n m a. (HasCallStack, PosC n, PosC m) => [a] -> Mat2 n m a Source #
create a 2d matrix from a list of values with the exact number of elements
gen' :: forall ns a. NS ns => ([Int] -> a) -> Mat ns a Source #
generate a matrix passing the indices at that element to a user callback function
gen :: forall ns a. NS ns => (Int -> a) -> Mat ns a Source #
generate a matrix passing a relative position of the element to a user callback function
mm :: forall ns. NS ns => Mat ns Int Source #
generate a matrix using relative position starting at one
buildMat :: forall ns a b. NS ns => ([FinMat ns] -> [FinMat ns] -> b -> FinMat ns -> (b, a)) -> b -> (b, Mat ns a) Source #
generate a Mat
with the given past and future rep values and a user state
vector/matrix builders
(.:) :: forall n a a'. a ~ a' => a -> Vec n a' -> Vec (1 + n) a' infixr 4 Source #
cons a value with a 1d matrix
(.::) :: forall n m ns a. Mat (m ': ns) a -> Mat (n ': (m ': ns)) a -> Mat ((1 + n) ': (m ': ns)) a infixr 3 Source #
cons a matrix with a one-higher dimension matrix
se2 :: forall n ns a. Mat (n ': ns) a -> Mat (1 ': (n ': ns)) a Source #
last element in a 2d or greater matrix
(.|) :: forall a a'. a ~ a' => a -> a' -> Vec 2 a' infixr 4 Source #
combine two values together into 1d matrix
(.||) :: forall m ns a. Mat (m ': ns) a -> Mat (m ': ns) a -> Mat (2 ': (m ': ns)) a infixr 3 Source #
combine two matrices
indexing
ixMat :: forall (ns :: [Nat]) a. FinMat ns -> Lens' (Mat ns a) a Source #
lens that accesses a value inside a mat given a concrete mat index
ixMat' :: forall (is :: [Nat]) (ns :: [Nat]) a. FinMatC is ns => Lens' (Mat ns a) a Source #
lens that accesses a value inside a mat using a type level index
finMatRows :: forall ns. NS ns => NonEmpty (FinMat ns) Source #
get the start index for each row in a mat
reverse
sort
sortByRows :: LeafC ns => (a -> a -> Ordering) -> Mat ns a -> Mat ns a Source #
sort each row of a mat using underlying Vec
multMat :: forall n m p a. Num a => Mat2 n m a -> Mat2 m p a -> Mat2 n p a Source #
multiply two matrices together
class DotC ns ns' a b fa fb | ns ns' a -> fa, ns ns' b -> fb, ns ns' fa -> a, ns ns' fb -> b, fa fb a b -> ns ns' where Source #
generalised dot product
dotC :: (fa -> fb -> c) -> (NonEmpty c -> d) -> Mat (n ': (m ': ns)) a -> Mat (m ': (p ': ns')) b -> Mat2 n p d Source #
zip
zipWithMat :: (a -> b -> c) -> Mat ns a -> Mat ns b -> Mat ns c Source #
zip two matrices using a combining function
zipWithMat3 :: (a -> b -> c -> d) -> Mat ns a -> Mat ns b -> Mat ns c -> Mat ns d Source #
zip three matrices using a combining function
zipWithMatA :: Applicative f => (a -> b -> f c) -> Mat ns a -> Mat ns b -> f (Mat ns c) Source #
zipWithMat
with an Applicative or use zipWithT
but that needs a NS
constraint
izipWith :: NS ns => (FinMat ns -> a -> b -> c) -> Mat ns a -> Mat ns b -> Mat ns c Source #
zipWithMat
with an index or use izipWithR
izipWithM :: (NS ns, Applicative f) => (FinMat ns -> a -> b -> f c) -> Mat ns a -> Mat ns b -> f (Mat ns c) Source #
zipWithMatA
with an index or use izipWithR
if "f" is Distributive
general
cartesian :: (a -> b -> c) -> Mat (n ': ns) a -> Mat (n' ': ns') b -> Mat (n ': (ns ++ (n' ': ns'))) c Source #
cartesian product of two matrices with a combining function
replicateMat :: forall n n1 ns a. PosC n => Mat (n1 ': ns) a -> Mat (n ': (n1 ': ns)) a Source #
creates a matrix of first dimension "n" by replicating the input matrix "n" times
determinant :: Num a => Mat2 n n a -> a Source #
get the determinant of a matrix
deleteColumnL :: forall a. Pos -> Int -> [a] -> [a] Source #
delete column "i" from a list of width "n"
row operations
deleteRow :: forall (i :: Nat) (n :: Nat) (ns :: [Nat]) a. FinC i (1 + n) => Mat ((1 + n) ': ns) a -> Mat (n ': ns) a Source #
delete a row
deleteRow' :: forall n ns a. Fin (1 + n) -> Mat ((1 + n) ': ns) a -> Mat (n ': ns) a Source #
delete a row using a concrete index
insertRow :: forall i n m ns a. FinC i (1 + n) => Mat (m ': ns) a -> Mat (n ': (m ': ns)) a -> Mat ((1 + n) ': (m ': ns)) a Source #
delete a row from a matrix
insertRow' :: forall n m ns a. Fin (1 + n) -> Mat (m ': ns) a -> Mat (n ': (m ': ns)) a -> Mat ((1 + n) ': (m ': ns)) a Source #
same as insertRow
but using a typelevel witness for the index
swapRow :: forall (i :: Nat) (j :: Nat) (n :: Nat) ns a. (FinC i n, FinC j n) => Mat (n ': ns) a -> Mat (n ': ns) a Source #
swaps mat rows (1d or more)
swapRow' :: forall (n :: Nat) ns a. Fin n -> Fin n -> Mat (n ': ns) a -> Mat (n ': ns) a Source #
swaps mat rows (1d or more)
_row :: forall (i :: Nat) (ns :: [Nat]) a. SliceC '[i] ns => Lens' (Mat ns a) (SliceT '[i] ns a) Source #
a lens indexing the outermost slice
_row' :: forall (n :: Nat) (ns :: [Nat]) a. SliceC' '[n] ns => Fin n -> Lens' (Mat ns a) (SliceT' '[n] ns a) Source #
a lens indexing a row using a concrete index Fin
rows :: forall n m ns a. Mat (n ': (m ': ns)) a -> Vec n (Mat (m ': ns) a) Source #
break up into rows
unrows :: forall n m ns a. Vec n (Mat (m ': ns) a) -> Mat (n ': (m ': ns)) a Source #
unbust from rows see rows
_rows :: forall n m ns a b. Iso (Mat (n ': (m ': ns)) a) (Mat (n ': (m ': ns)) b) (Vec n (Mat (m ': ns) a)) (Vec n (Mat (m ': ns) b)) Source #
isomorphism for nesting/unnesting a matrix one level deep
wrapRows1 :: LeafC ns => (NonEmpty a -> NonEmpty b) -> Mat ns a -> Either String (Mat ns b) Source #
visit each leaf row with a function from a nonempty to a nonempty list
indexRow :: Fin n -> Mat (n ': (m ': ns)) a -> Mat (m ': ns) a Source #
get a row from a matrix using a concrete index see _row'
column operations
deleteCol :: forall (i :: Nat) (n :: Nat) (n1 :: Nat) ns a. FinC i (1 + n1) => Mat (n ': ((1 + n1) ': ns)) a -> Mat (n ': (n1 ': ns)) a Source #
delete a column from a matrix (2d or higher)
deleteCol' :: forall (n :: Nat) (n1 :: Nat) ns a. Fin (1 + n1) -> Mat (n ': ((1 + n1) ': ns)) a -> Mat (n ': (n1 ': ns)) a Source #
same as deleteCol
but using a typelevel witness for the index
insertCol :: forall (i :: Nat) (n :: Nat) (n1 :: Nat) ns a. FinC i (1 + n1) => Mat (n ': ns) a -> Mat (n ': (n1 ': ns)) a -> Mat (n ': ((1 + n1) ': ns)) a Source #
insert a column into a mat (2d and above)
insertCol' :: forall (n :: Nat) (n1 :: Nat) ns a. Fin (1 + n1) -> Mat (n ': ns) a -> Mat (n ': (n1 ': ns)) a -> Mat (n ': ((1 + n1) ': ns)) a Source #
swapCol :: forall (i :: Nat) (j :: Nat) (n :: Nat) (n1 :: Nat) ns a. (FinC i n1, FinC j n1) => Mat (n ': (n1 ': ns)) a -> Mat (n ': (n1 ': ns)) a Source #
swaps mat rows (2d or more)
swapCol' :: forall (n :: Nat) (n1 :: Nat) ns a. Fin n1 -> Fin n1 -> Mat (n ': (n1 ': ns)) a -> Mat (n ': (n1 ': ns)) a Source #
swaps mat rows (2d or more)
_col :: forall (i :: Nat) n m ns a. FinC i m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
a lens for acccessing a column
_col' :: forall n m ns a. Fin m -> Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
a lens for acccessing a column
swapMat :: forall (is :: [Nat]) (js :: [Nat]) ns a. (FinMatC is ns, FinMatC js ns) => Mat ns a -> Mat ns a Source #
swaps a single value "a" from any location to any other location using type level indexes
appendV :: Mat (n ': ns) a -> Mat (n' ': ns) a -> Mat ((n + n') ': ns) a Source #
append two matrices vertically
appendH :: forall n m m' ns a. Mat (n ': (m ': ns)) a -> Mat (n ': (m' ': ns)) a -> Mat (n ': ((m + m') ': ns)) a Source #
append two matrices horizontally
permutationsMat :: forall n a. Vec n a -> Mat2 (FacT n) n a Source #
return a mat as a permutation of a list (1d only) todo: extend to multidimensions
findMatElems :: NS ns => (a -> Bool) -> Mat ns a -> [(FinMat ns, a)] Source #
find all elements in a mat that match the predicate
bulk updates
bulkMat :: Vec x (FinMat ns) -> Lens' (Mat ns a) (Vec x a) Source #
lens for bulk updates/gets on a matrix
updatesMat :: forall ns t a b. Foldable t => (FinMat ns -> a -> b -> a) -> t (FinMat ns, b) -> Mat ns a -> Mat ns a Source #
bulk updates on a mat
getsMat :: forall ns a t. Functor t => t (FinMat ns) -> Mat ns a -> t a Source #
bulk gets from a mat: replaces the container of indices with the corresponding values
setsMat :: forall ns t a. Foldable t => t (FinMat ns, a) -> Mat ns a -> Mat ns a Source #
bulk updates on a mat
nonEmptyMatsToMat :: forall n m ns a t. (Foldable1 t, PosC n) => t (Mat (m ': ns) a) -> Either String (Mat (n ': (m ': ns)) a) Source #
create a matrix of one dimension higher from rows of a sub matrix
reshape
_transposeMat :: Iso (Mat (n ': (m ': ns)) a) (Mat (n ': (m ': ns)) b) (Mat (m ': (n ': ns)) a) (Mat (m ': (n ': ns)) b) Source #
an iso for transposing a matrix
transposeMat :: forall n m ns a. Mat (n ': (m ': ns)) a -> Mat (m ': (n ': ns)) a Source #
transpose a 2d or larger matrix
toND :: forall i ns a. PosC i => Mat ns a -> MatToNDT i ns a Source #
create a nd matrix using a Nat see 'toND
type MatToNDT i ns a = Mat (MatToMatNTA (NatToPeanoT i) ns) (Mat (MatToMatNTB (NatToPeanoT i) ns) a) Source #
type synonym for the result of nesting a matrix: see toND
concatMat :: forall (n :: Nat) (ns :: [Nat]) (m :: Nat) (ms :: [Nat]) a. Mat (n ': ns) (Mat (m ': ms) a) -> Mat (n ': (ns ++ (m ': ms))) a Source #
squash a single nested matrix together into one
redim :: forall ms ns a. (NS ms, ProductT ns ~ ProductT ms) => Mat ns a -> Mat ms a Source #
resize a mat
rotateLeft :: Mat2 n m a -> Mat2 m n a Source #
left rotate a matrix
rotateRight :: Mat2 n m a -> Mat2 m n a Source #
right rotate a matrix
subset and slicing
class SliceC is ns where Source #
allows viewing and updating a slice of a mat
sliceC :: Mat ns a -> SliceT is ns a Source #
sliceUpdateC :: Mat ns a -> SliceT is ns a -> Mat ns a Source #
Instances
(TypeError ('Text "SliceC '[] '[]: empty indices ns and ns'") :: Constraint) => SliceC ('[] :: [Nat]) ('[] :: [Nat]) Source # | |
(TypeError ('Text "SliceC '[] (n ': ns): empty indices ns'") :: Constraint) => SliceC ('[] :: [Nat]) (n ': ns) Source # | |
(TypeError ('Text "SliceC (n' ': ns') '[]: empty indices ns") :: Constraint) => SliceC (n' ': ns') ('[] :: [Nat]) Source # | |
(TypeError ('Text "too many indices 'is': length is > length ns") :: Constraint) => SliceC (i ': (i1 ': is)) '[n] Source # | |
(FinC i n, SliceC (i1 ': is) (n1 ': ns)) => SliceC (i ': (i1 ': is)) (n ': (n1 ': ns)) Source # | |
FinC i n => SliceC '[i] (n ': (m ': ns)) Source # | |
FinC i n => SliceC '[i] '[n] Source # | |
type family SliceT is ns a where ... Source #
describes the resulting type of taking a slice from the mat
SliceT '[] (_ ': _) _ = TypeError ('Text "SliceT '[] (_ ': _): not defined for empty indices ns'") | |
SliceT (_ ': _) '[] _ = TypeError ('Text "SliceT (_ ': _) '[]: not defined for empty indices ns") | |
SliceT '[] '[] _ = TypeError ('Text "SliceT '[] '[]: not defined for empty indices ns and ns'") | |
SliceT '[_] '[_] a = a | |
SliceT (_ ': (i ': is)) '[_] _ = TypeError (('Text "SliceT: 'is' must be a smaller in length than 'ns'" :<>: 'Text " extra 'is'=") :<>: 'ShowType (i ': is)) | |
SliceT '[_] (_ ': (n1 ': ns)) a = Mat (n1 ': ns) a | |
SliceT (_ ': (i1 ': is)) (_ ': (n1 ': ns)) a = SliceT (i1 ': is) (n1 ': ns) a |
class SliceC' ns' ns where Source #
allows viewing and updating a slice of a mat using concrete indices
inference is better with n ~ n' but since we have committed to a instance
we are missing nice errors when the indices dont match: eg
sliceC' '[1]
'[7] (FinMat 0 (_7P :| [])) (mm @(NN 7))
sliceC' :: FinMat ns' -> Mat ns a -> SliceT' ns' ns a Source #
sliceUpdateC' :: FinMat ns' -> Mat ns a -> SliceT' ns' ns a -> Mat ns a Source #
Instances
(TypeError ('Text "SliceC' '[] '[]: empty indices ns and ns'") :: Constraint) => SliceC' ('[] :: [Nat]) ('[] :: [Nat]) Source # | |
(TypeError ('Text "SliceC' '[] (n ': ns): empty indices ns'") :: Constraint) => SliceC' ('[] :: [Nat]) (n ': ns) Source # | |
(TypeError ('Text "SliceC' (n' ': ns') '[]: empty indices ns") :: Constraint) => SliceC' (n' ': ns') ('[] :: [Nat]) Source # | |
(TypeError ('Text "SliceC': too many indices ns': length ns' > length ns") :: Constraint) => SliceC' (n' ': (n1' ': ns')) '[n] Source # | |
(n ~ n', SliceC' (n1' ': ns') (n1 ': ns)) => SliceC' (n ': (n1' ': ns')) (n' ': (n1 ': ns)) Source # | |
Defined in Cybus.Mat | |
n ~ n' => SliceC' '[n'] (n ': (m ': ns)) Source # | |
n ~ n' => SliceC' '[n'] '[n] Source # | |
type family SliceT' ns' ns a where ... Source #
describes the resulting type of taking a slice from the mat but the indices must match pointwise unlike SliceT so we can use the concrete FinMat to specify the indices
SliceT' '[] (_ ': _) _ = TypeError ('Text "SliceT' '[] (_ ': _): not defined for empty indices ns'") | |
SliceT' (_ ': _) '[] _ = TypeError ('Text "SliceT' (_ ': _) '[]: not defined for empty indices ns") | |
SliceT' '[] '[] _ = TypeError ('Text "SliceT' '[] '[]: not defined for empty indices ns and ns'") | |
SliceT' '[n] '[n] a = a | |
SliceT' (_ ': (n' ': ns')) '[_] _ = TypeError (('Text "SliceT': there are more ns' indices (lhs) than the actual matrix ns indices (rhs):" :<>: 'Text " extra ns'=") :<>: 'ShowType (n' ': ns')) | |
SliceT' '[n] (n ': (n1 ': ns)) a = Mat (n1 ': ns) a | |
SliceT' (n ': (n1' ': ns')) (n ': (n1 ': ns)) a = SliceT' (n1' ': ns') (n1 ': ns) a | |
SliceT' (n' ': _) (n ': _) _ = TypeError (((('Text "SliceT': indices need to match pointwise:" :<>: 'Text "ie n' /= n:") :<>: 'ShowType n') :<>: 'Text " /= ") :<>: 'ShowType n) |
slice :: forall is ns a z. (z ~ SliceToFinMatT is ns, NS is, NS ns, NS z, SliceC' z ns) => Mat ns a -> SliceT' z ns a Source #
get a slice by converting a typelevel slice to a concrete FinMat based slice
sliceUpdate :: forall is ns a z. (z ~ SliceToFinMatT is ns, NS is, NS ns, NS z, SliceC' z ns) => Mat ns a -> SliceT' z ns a -> Mat ns a Source #
update a slice by converting a typelevel slice to a concrete FinMat based slice
sliceToFinMat :: forall is ns. (NS (SliceToFinMatT is ns), NS is, NS ns) => FinMat (SliceToFinMatT is ns) Source #
converts a typelevel slice to a concrete FinMat
type family SliceToFinMatT is ns where ... Source #
describes the resulting type of taking a slice from the matrix
SliceToFinMatT (_ ': _) '[] = TypeError ('Text "SliceToFinMatT (_ ': _) '[]: 'is' is empty") | |
SliceToFinMatT '[] (_ ': _) = TypeError ('Text "SliceToFinMatT '[] (_ ': _): 'ns' is empty") | |
SliceToFinMatT '[] '[] = TypeError ('Text "SliceToFinMatT '[] '[]: 'is' and 'ns' are empty") | |
SliceToFinMatT '[_] '[n] = '[n] | |
SliceToFinMatT (_ ': (i ': is)) '[_] = TypeError (('Text "SliceToFinMatT: 'is' is larger in length than 'ns':" :<>: 'Text " extra 'is'=") :<>: 'ShowType (i ': is)) | |
SliceToFinMatT '[_] (n ': (_ ': _)) = '[n] | |
SliceToFinMatT (_ ': (i1 ': is)) (n ': (n1 ': ns)) = n ': SliceToFinMatT (i1 ': is) (n1 ': ns) |
ixSlice :: forall (is :: [Nat]) (ns :: [Nat]) a. SliceC is ns => Lens' (Mat ns a) (SliceT is ns a) Source #
a lens for accessing a slice of a mat
ixSlice' :: forall (ns' :: [Nat]) (ns :: [Nat]) a. SliceC' ns' ns => FinMat ns' -> Lens' (Mat ns a) (SliceT' ns' ns a) Source #
a lens for accessing a slice of a mat
subsetRows :: forall i j n ns a. DiffTC i j n => Mat (n ': ns) a -> Mat (DiffT i j n ': ns) a Source #
take a subset of a matrix using the start and end rows
subsetCols :: forall i j m n ns a. DiffTC i j n => Mat (m ': (n ': ns)) a -> Mat (m ': (DiffT i j n ': ns)) a Source #
take a subset of a matrix using the start and end columns
diagonal :: Mat (n ': (n ': ns)) a -> Mat (n ': ns) a Source #
gets the diagonal elements of a 2d or greater square matrix: the diagonal of a n * n * ns matrix results in a n * ns matrix
rowsToMat :: forall x n m ns a. Vec x (Fin n) -> Mat (n ': (m ': ns)) a -> Mat (x ': (m ': ns)) a Source #
construct a new matrix based on a 1d matrix of row witnesses
splitting
chunkNV :: forall t a z. Traversable t => t z -> Pos -> Vector a -> Either String (t (Vector a)) Source #
split up a vector into chunks of size "n" and fill a container "tz"
chunkNVMat :: forall ns t x a z. Traversable t => t z -> NonEmpty Pos -> Mat x a -> Either String (t (Mat ns a)) Source #
split up a matrix into matrix chunks of dimension "ps" and fill a container "tz"
leaf methods
methods for accessing all the leaf rows of a matrix: restricted to 2d hence this class
traverseLeafC :: Applicative m => (FinMat ns -> Vec (LastT ns) a -> m b) -> Mat ns a -> m (Mat (InitT ns) b) Source #
fromLeavesInternalC :: Mat (InitT ns) (Vec (LastT ns) a) -> Mat ns a Source #
traverseLeafSimple :: (LeafC ns, Applicative m) => (FinMat ns -> Vec (LastT ns) a -> m (Vec (LastT ns) b)) -> Mat ns a -> m (Mat ns b) Source #
traverse over a nested leaf matrix only allowing changes to "a"
mapLeafSimple :: LeafC ns => (FinMat ns -> Vec (LastT ns) a -> Vec (LastT ns) b) -> Mat ns a -> Mat ns b Source #
map over a nested leaf matrix only allowing changes to "a"
foldMapLeaf :: (Monoid z, LeafC ns) => (FinMat ns -> Vec (LastT ns) a -> z) -> Mat ns a -> z Source #
foldmap over a nested leaf matrix
foldMapLeafR :: (Monoid z, LeafC ns) => (FinMat ns -> Vec (LastT ns) a -> z) -> Mat ns a -> z Source #
foldmap over a nested leaf matrix
mapLeaf :: LeafC ns => (FinMat ns -> Vec (LastT ns) a -> b) -> Mat ns a -> Mat (InitT ns) b Source #
map over a nested leaf matrix
mapLeafS :: LeafC ns => (FinMat ns -> c -> Vec (LastT ns) a -> (c, b)) -> c -> Mat ns a -> (c, Mat (InitT ns) b) Source #
map over a nested leaf matrix with state
mapLeafSimpleS :: LeafC ns => (FinMat ns -> c -> Vec (LastT ns) a -> (c, Vec (LastT ns) b)) -> c -> Mat ns a -> (c, Mat ns b) Source #
map over a nested leaf matrix only allowing changes to "a" and access to user state
foldLeaf :: LeafC ns => (FinMat ns -> c -> Vec (LastT ns) a -> c) -> c -> Mat ns a -> c Source #
fold over a nested leaf matrix
toLeaves :: LeafC ns => Mat ns a -> Mat (InitT ns) (Vec (LastT ns) a) Source #
convert to nested matrix with 1d leaves
mapCols :: forall n m ns a b. (FinMat (m ': (n ': ns)) -> Vec (LastT (n ': ns)) a -> Vec (LastT (n ': ns)) b) -> Mat (n ': (m ': ns)) a -> Mat (n ': (m ': ns)) b Source #
map each column
mapCols' :: forall n m ns a b c. (FinMat (m ': (n ': ns)) -> c -> Vec (LastT (n ': ns)) a -> (c, Vec (LastT (n ': ns)) b)) -> c -> Mat (n ': (m ': ns)) a -> (c, Mat (n ': (m ': ns)) b) Source #
map each column with user state
readshowprint methods
class ShowMatC ns where Source #
class with methods to convert to and from Mat using nested structures
showMatC :: Show a => ShowOpts -> Mat ns a -> [String] Source #
show a matrix
showMatC' :: Show a => Int -> Int -> ShowOpts -> Mat ns a -> [String] Source #
show options for Mat
ShowOpts | |
|
defShowOpts :: ShowOpts Source #
default show options for Mat
prtMat :: forall ns a. (ShowMatC ns, Show a) => ShowOpts -> Mat ns a -> IO () Source #
print a matrix
showMat :: forall ns a. (ShowMatC ns, Show a) => ShowOpts -> Mat ns a -> String Source #
show a matrix
readMatP :: forall ns a. (MatConvertersC ns, NS ns, Read (ListNST ns a)) => ShowOpts -> ReadP (Mat ns a) Source #
reader for showFin
readMat :: forall ns a. (MatConvertersC ns, NS ns, Read (ListNST ns a)) => ReadS (Mat ns a) Source #
read in a matrix as a nested list using default ShowOpts
row lenses
class Row1 s a | s -> a where Source #
lens into row 1
column lenses
_c1 :: FinC 1 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 1 of a matrix
_c2 :: FinC 2 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 2 of a matrix
_c3 :: FinC 3 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 3 of a matrix
_c4 :: FinC 4 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 4 of a matrix
_c5 :: FinC 5 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 5 of a matrix
_c6 :: FinC 6 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 6 of a matrix
_c7 :: FinC 7 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 7 of a matrix
_c8 :: FinC 8 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 8 of a matrix
_c9 :: FinC 9 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 9 of a matrix
_c10 :: FinC 10 m => Lens' (Mat (n ': (m ': ns)) a) (Mat (n ': ns) a) Source #
lens into column 10 of a matrix
miscellaneous
finMatMatrix :: forall ns. NS ns => Mat ns (FinMat ns) Source #
create a matrix of matrix indices for a given size "ns"
finMatMatrix' :: forall ns x. NS ns => Mat ns x -> Mat ns (FinMat ns) Source #
fill an existing matrix with indices
scans
scanlVec :: forall n a b. (b -> a -> b) -> b -> Vec n a -> Vec (n + 1) b Source #
scanl'
for a vector
postscanlMat :: forall ns a b. (b -> a -> b) -> b -> Mat ns a -> Mat ns b Source #
see postscanl'
concrete version of postscanl
postscanrMat :: forall ns a b. (a -> b -> b) -> b -> Mat ns a -> Mat ns b Source #
see postscanr'
concrete version of 'Primus.Fold.postscanr
coercion methods to set the dimensions of a matrix
dim8 :: Mat '[n, m, p, q, r, s, t, u] a -> Mat '[n, m, p, q, r, s, t, u] a Source #
matrix of dimension 8