@@ -104,8 +104,8 @@ module LAoP.Matrix.Type
104104 multM,
105105
106106 -- * Selective equivalent instance function
107− selectM,
108−
107+ selectM,
108+
109109 -- * Monad equivalent instance function
110110 returnM,
111111 bindM,
@@ -113,7 +113,9 @@ module LAoP.Matrix.Type
113113 -- * Misc
114114 -- ** Get dimensions
115115 columns,
116+ columns',
116117 rows,
118+ rows',
117119
118120 -- ** Matrix Transposition
119121 tr,
@@ -265,7 +267,7 @@ infixl 2 ===
265267-- Functor hierarchy
266268
267269-- | Functor instance equivalent function
268−fmapM ::
270+fmapM ::
269271 ( Liftable e a b,
270272 CountableDimsN a b,
271273 FLN b a
@@ -279,7 +281,7 @@ unitM :: (Num e) => Matrix e () ()
279281unitM = one 1
280282
281283-- | Applicative instance equivalent 'unit' function,
282−multM ::
284+multM ::
283285 ( CountableDimsN a b,
284286 CountableN (a, b),
285287 Num e,
@@ -290,8 +292,8 @@ multM ::
290292multM = kr
291293
292294-- | Monad instance equivalent 'return' function,
293−returnM ::
294− forall e a .
295+returnM ::
296+ forall e a .
295297 ( Num e,
296298 Enum e,
297299 Enum a,
@@ -387,7 +389,7 @@ toList (M m) = I.toList m
387389
388390-- | The zero matrix. A matrix wholly filled with zeros.
389391zeros ::
390− (Num e, FLN cols rows, CountableDimsN cols rows)
392+ (Num e, FLN cols rows, CountableDimsN cols rows)
391393 => Matrix e cols rows
392394zeros = M I.zeros
393395
@@ -397,7 +399,7 @@ zeros = M I.zeros
397399--
398400-- Also known as T (Top) matrix.
399401ones ::
400− (Num e, FLN cols rows, CountableDimsN cols rows)
402+ (Num e, FLN cols rows, CountableDimsN cols rows)
401403 => Matrix e cols rows
402404ones = M I.ones
403405
@@ -406,7 +408,7 @@ ones = M I.ones
406408-- | The constant matrix constructor. A matrix wholly filled with a given
407409-- value.
408410constant ::
409− (Num e, FLN cols rows, CountableDimsN cols rows)
411+ (Num e, FLN cols rows, CountableDimsN cols rows)
410412 => e -> Matrix e cols rows
411413constant = M . I.constant
412414
@@ -420,7 +422,7 @@ bang ::
420422bang = M I.bang
421423
422424-- | Point constant relation
423−point ::
425+point ::
424426 ( Bounded a,
425427 Enum a,
426428 Eq a,
@@ -449,7 +451,7 @@ iden = M I.iden
449451comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
450452comp (M a) (M b) = M (I.comp a b)
451453{-# NOINLINE comp #-}
452−{-# RULES
454+{-# RULES
453455 "comp/iden1" forall m. comp m iden = m ;
454456 "comp/iden2" forall m. comp iden m = m
455457#-}
@@ -514,24 +516,34 @@ i2 = tr p2
514516
515517-- | Obtain the number of rows.
516518--
517−-- NOTE: The 'KnownNat' constaint is needed in order to obtain the
518−-- dimensions in constant time.
519−--
520−-- TODO: A 'rows' function that does not need the 'KnownNat' constraint in
521−-- exchange for performance.
519+-- NOTE: The 'KnownNat' constraint is needed in order to obtain the
520+-- dimensions in constant time. For a version that doesn't require the
521+-- constraint see 'rows''.
522522rows :: (CountableN rows) => Matrix e cols rows -> Int
523523rows (M m) = I.rows m
524524
525+-- | Obtain the number of rows in an inefficient manner, but without any
526+-- constraints.
527+--
528+-- For a more efficient version see 'rows'.
529+rows' :: Matrix e cols rows -> Int
530+rows' (M m) = I.rows' m
531+
525532-- | Obtain the number of columns.
526−--
527−-- NOTE: The 'KnownNat' constaint is needed in order to obtain the
528−-- dimensions in constant time.
529533--
530−-- TODO: A 'columns' function that does not need the 'KnownNat' constraint in
531−-- exchange for performance.
534+-- NOTE: The 'KnownNat' constraint is needed in order to obtain the
535+-- dimensions in constant time. For a version that doesn't require the
536+-- constraint see 'columns''.
532537columns :: (CountableN cols) => Matrix e cols rows -> Int
533538columns (M m) = I.columns m
534539
540+-- | Obtain the number of columns in an inefficient manner, but without any
541+-- constraints.
542+--
543+-- For a more efficient version see 'columns'.
544+columns' :: Matrix e cols rows -> Int
545+columns' (M m) = I.columns' m
546+
535547-- Coproduct Bifunctor
536548
537549infixl 5 -|-
@@ -553,7 +565,7 @@ infixl 5 -|-
553565-- Khatri Rao Product and projections
554566
555567-- | Khatri Rao product first component projection matrix.
556−fstM ::
568+fstM ::
557569 forall e m k .
558570 ( Num e,
559571 CountableDimsN m k,
@@ -564,7 +576,7 @@ fstM ::
564576fstM = M (I.fstM @e @(I.Normalize m) @(I.Normalize k))
565577
566578-- | Khatri Rao product second component projection matrix.
567−sndM ::
579+sndM ::
568580 forall e m k.
569581 ( Num e,
570582 CountableDimsN k m,
@@ -577,9 +589,9 @@ sndM = M (I.sndM @e @(I.Normalize m) @(I.Normalize k))
577589-- | Khatri Rao Matrix product also known as matrix pairing.
578590--
579591-- NOTE: That this is not a true categorical product, see for instance:
580−--
592+--
581593-- @
582−-- | fstM . kr a b == a
594+-- | fstM . kr a b == a
583595-- kr a b ==> |
584596-- | sndM . kr a b == b
585597-- @
@@ -625,7 +637,7 @@ infixl 4 ><
625637-- Matrix abide Join Fork
626638
627639-- | Matrix "abiding" followin the 'Join'-'Fork' abide law.
628−--
640+--
629641-- Law:
630642--
631643-- @
@@ -637,7 +649,7 @@ abideJF (M m) = M (I.abideJF m)
637649-- Matrix abide Fork Join
638650
639651-- | Matrix "abiding" followin the 'Fork'-'Join' abide law.
640−--
652+--
641653-- Law:
642654--
643655-- @
@@ -656,7 +668,7 @@ tr (M m) = M (I.tr m)
656668
657669-- | Selective functors 'select' operator equivalent inspired by the
658670-- ArrowMonad solution presented in the paper.
659−selectM ::
671+selectM ::
660672 ( Num e,
661673 FLN b b,
662674 CountableN b