@@ -33,6 +33,12 @@ module Matrix.Nat
3333 -- * Type safe matrix representation
3434 Matrix (..),
3535
36+ -- * Primitives
37+ empty,
38+ one,
39+ junc,
40+ split,
41+
3642 -- * Auxiliary type families
3743 I.FromNat,
3844 I.Count,
@@ -59,18 +65,24 @@ module Matrix.Nat
5965 -- ** Matrix Transposition
6066 tr,
6167
68+ -- ** Selective operator
69+ select,
70+
71+ -- ** McCarthy's Conditional
72+ cond,
73+
6274 -- ** Matrix "abiding"
6375 abideJS,
6476 abideSJ,
6577
6678 -- * Biproduct approach
6779 -- ** Split
68− split,
80+ (===),
6981 -- *** Projections
7082 p1,
7183 p2,
7284 -- ** Junc
73− junc,
85+ (|||),
7486 -- *** Injections
7587 i1,
7688 i2,
@@ -129,6 +141,14 @@ junc ::
129141 Matrix e cols3 rows
130142junc (M a) (M b) = M (I.Junc a b)
131143
144+infixl 3 |||
145+(|||) ::
146+ (I.FromNat cols3 ~ Either (I.FromNat cols1) (I.FromNat cols2)) =>
147+ Matrix e cols1 rows ->
148+ Matrix e cols2 rows ->
149+ Matrix e cols3 rows
150+(|||) = junc
151+
132152split ::
133153 (I.FromNat rows3 ~ Either (I.FromNat rows1) (I.FromNat rows2)) =>
134154 Matrix e cols rows1 ->
@@ -136,6 +156,14 @@ split ::
136156 Matrix e cols rows3
137157split (M a) (M b) = M (I.Split a b)
138158
159+infixl 2 ===
160+(===) ::
161+ (I.FromNat rows3 ~ Either (I.FromNat rows1) (I.FromNat rows2)) =>
162+ Matrix e cols rows1 ->
163+ Matrix e cols rows2 ->
164+ Matrix e cols rows3
165+(===) = split
166+
139167-- Construction
140168
141169fromLists :: (I.FromLists e (I.FromNat cols) (I.FromNat rows)) => [[e]] -> Matrix e cols rows
@@ -383,6 +411,22 @@ abideSJ (M m) = M (I.abideSJ m)
383411tr :: Matrix e cols rows -> Matrix e rows cols
384412tr (M m) = M (I.tr m)
385413
414+-- Selective 'select' operator
415+
416+select
417+ :: (Num e, Bounded a1, Bounded b, Enum a1, Enum b, Ord e,
418+ KnownNat (I.Count a2), KnownNat (I.Count (I.FromNat rows1)),
419+ I.FromLists e (I.FromNat rows1) a2,
420+ I.FromLists e (I.FromNat rows1) (I.FromNat rows1), Eq b,
421+ I.FromNat cols1 ~ I.FromNat cols2,
422+ I.FromNat rows2 ~ Either a2 (I.FromNat rows1)) =>
423+ Matrix e cols1 rows2 -> (a1 -> b) -> Matrix e cols2 rows1
424+select (M m) y = M (I.select m y)
425+
426+-- McCarthy's Conditional
427+
428+cond p (M a) (M b) = M (I.cond p a b)
429+
386430-- Pretty print
387431
388432pretty :: Show e => Matrix e cols rows -> String