@@ -104,8 +104,8 @@ module LAoP.Matrix.Type
106 -- * Selective equivalent instance function
106 -- * Selective equivalent instance function
107− selectM,
107+ selectM,
109 -- * Monad equivalent instance function
109 -- * Monad equivalent instance function
@@ -113,7 +113,9 @@ module LAoP.Matrix.Type
113 -- * Misc
113 -- * Misc
114 -- ** Get dimensions
114 -- ** Get dimensions
118 -- ** Matrix Transposition
120 -- ** Matrix Transposition
@@ -265,7 +267,7 @@ infixl 2 ===
265-- Functor hierarchy
267-- Functor hierarchy
267-- | Functor instance equivalent function
269-- | Functor instance equivalent function
268−fmapM ::
270+fmapM ::
269 ( Liftable e a b,
271 ( Liftable e a b,
270 CountableDimsN a b,
272 CountableDimsN a b,
@@ -279,7 +281,7 @@ unitM :: (Num e) => Matrix e () ()
279unitM = one 1
281unitM = one 1
281-- | Applicative instance equivalent 'unit' function,
283-- | Applicative instance equivalent 'unit' function,
282−multM ::
284+multM ::
283 ( CountableDimsN a b,
285 ( CountableDimsN a b,
284 CountableN (a, b),
286 CountableN (a, b),
@@ -290,8 +292,8 @@ multM ::
290multM = kr
292multM = kr
292-- | Monad instance equivalent 'return' function,
294-- | Monad instance equivalent 'return' function,
293−returnM ::
295+returnM ::
294− forall e a .
296+ forall e a .
@@ -387,7 +389,7 @@ toList (M m) = I.toList m
388-- | The zero matrix. A matrix wholly filled with zeros.
390-- | The zero matrix. A matrix wholly filled with zeros.
390− (Num e, FLN cols rows, CountableDimsN cols rows)
392+ (Num e, FLN cols rows, CountableDimsN cols rows)
391 => Matrix e cols rows
393 => Matrix e cols rows
392zeros = M I.zeros
394zeros = M I.zeros
@@ -397,7 +399,7 @@ zeros = M I.zeros
398-- Also known as T (Top) matrix.
400-- Also known as T (Top) matrix.
400− (Num e, FLN cols rows, CountableDimsN cols rows)
402+ (Num e, FLN cols rows, CountableDimsN cols rows)
401 => Matrix e cols rows
403 => Matrix e cols rows
402ones = M I.ones
404ones = M I.ones
@@ -406,7 +408,7 @@ ones = M I.ones
406-- | The constant matrix constructor. A matrix wholly filled with a given
408-- | The constant matrix constructor. A matrix wholly filled with a given
408constant ::
410constant ::
409− (Num e, FLN cols rows, CountableDimsN cols rows)
411+ (Num e, FLN cols rows, CountableDimsN cols rows)
410 => e -> Matrix e cols rows
412 => e -> Matrix e cols rows
411constant = M . I.constant
413constant = M . I.constant
@@ -420,7 +422,7 @@ bang ::
420bang = M I.bang
422bang = M I.bang
422-- | Point constant relation
424-- | Point constant relation
423−point ::
425+point ::
424 ( Bounded a,
426 ( Bounded a,
@@ -449,7 +451,7 @@ iden = M I.iden
449comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
451comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
450comp (M a) (M b) = M (I.comp a b)
452comp (M a) (M b) = M (I.comp a b)
451{-# NOINLINE comp #-}
453{-# NOINLINE comp #-}
452−{-# RULES
454+{-# RULES
453 "comp/iden1" forall m. comp m iden = m ;
455 "comp/iden1" forall m. comp m iden = m ;
454 "comp/iden2" forall m. comp iden m = m
456 "comp/iden2" forall m. comp iden m = m
@@ -514,24 +516,34 @@ i2 = tr p2
515-- | Obtain the number of rows.
517-- | Obtain the number of rows.
517−-- NOTE: The 'KnownNat' constaint is needed in order to obtain the
519+-- NOTE: The 'KnownNat' constraint is needed in order to obtain the
518−-- dimensions in constant time.
520+-- dimensions in constant time. For a version that doesn't require the
519−--
521+-- constraint see 'rows''.
520−-- TODO: A 'rows' function that does not need the 'KnownNat' constraint in
521−-- exchange for performance.
522rows :: (CountableN rows) => Matrix e cols rows -> Int
522rows :: (CountableN rows) => Matrix e cols rows -> Int
523rows (M m) = I.rows m
523rows (M m) = I.rows m
525+-- | Obtain the number of rows in an inefficient manner, but without any
528+-- For a more efficient version see 'rows'.
529+rows' :: Matrix e cols rows -> Int
530+rows' (M m) = I.rows' m
525-- | Obtain the number of columns.
532-- | Obtain the number of columns.
527−-- NOTE: The 'KnownNat' constaint is needed in order to obtain the
528−-- dimensions in constant time.
530−-- TODO: A 'columns' function that does not need the 'KnownNat' constraint in
534+-- NOTE: The 'KnownNat' constraint is needed in order to obtain the
531−-- exchange for performance.
535+-- dimensions in constant time. For a version that doesn't require the
536+-- constraint see 'columns''.
532columns :: (CountableN cols) => Matrix e cols rows -> Int
537columns :: (CountableN cols) => Matrix e cols rows -> Int
533columns (M m) = I.columns m
538columns (M m) = I.columns m
540+-- | Obtain the number of columns in an inefficient manner, but without any
543+-- For a more efficient version see 'columns'.
544+columns' :: Matrix e cols rows -> Int
545+columns' (M m) = I.columns' m
535-- Coproduct Bifunctor
547-- Coproduct Bifunctor
537infixl 5 -|-
549infixl 5 -|-
@@ -553,7 +565,7 @@ infixl 5 -|-
553-- Khatri Rao Product and projections
565-- Khatri Rao Product and projections
555-- | Khatri Rao product first component projection matrix.
567-- | Khatri Rao product first component projection matrix.
557 forall e m k .
569 forall e m k .
559 CountableDimsN m k,
571 CountableDimsN m k,
@@ -564,7 +576,7 @@ fstM ::
564fstM = M (I.fstM @e @(I.Normalize m) @(I.Normalize k))
576fstM = M (I.fstM @e @(I.Normalize m) @(I.Normalize k))
566-- | Khatri Rao product second component projection matrix.
578-- | Khatri Rao product second component projection matrix.
568 forall e m k.
580 forall e m k.
570 CountableDimsN k m,
582 CountableDimsN k m,
@@ -577,9 +589,9 @@ sndM = M (I.sndM @e @(I.Normalize m) @(I.Normalize k))
577-- | Khatri Rao Matrix product also known as matrix pairing.
589-- | Khatri Rao Matrix product also known as matrix pairing.
579-- NOTE: That this is not a true categorical product, see for instance:
591-- NOTE: That this is not a true categorical product, see for instance:
582−-- | fstM . kr a b == a
594+-- | fstM . kr a b == a
583-- kr a b ==> |
595-- kr a b ==> |
584-- | sndM . kr a b == b
596-- | sndM . kr a b == b
@@ -625,7 +637,7 @@ infixl 4 ><
625-- Matrix abide Join Fork
637-- Matrix abide Join Fork
627-- | Matrix "abiding" followin the 'Join'-'Fork' abide law.
639-- | Matrix "abiding" followin the 'Join'-'Fork' abide law.
@@ -637,7 +649,7 @@ abideJF (M m) = M (I.abideJF m)
637-- Matrix abide Fork Join
649-- Matrix abide Fork Join
639-- | Matrix "abiding" followin the 'Fork'-'Join' abide law.
651-- | Matrix "abiding" followin the 'Fork'-'Join' abide law.
@@ -656,7 +668,7 @@ tr (M m) = M (I.tr m)
657-- | Selective functors 'select' operator equivalent inspired by the
669-- | Selective functors 'select' operator equivalent inspired by the
658-- ArrowMonad solution presented in the paper.
670-- ArrowMonad solution presented in the paper.
659−selectM ::
671+selectM ::
662 CountableN b
674 CountableN b