@@ -81,6 +81,10 @@ module LAoP.Matrix.Internal
8181 -- ** Matrix Transposition
8282 tr,
8383
84+ -- ** Scalar multiplication/division of matrices
85+ (.|),
86+ (./),
87+
8488 -- ** Selective operator
8589 select,
8690 branch,
@@ -344,7 +348,7 @@ instance {-# OVERLAPPABLE #-} (FromLists e (Either a b) c, FromLists e (Either a
344348 fromLists l@(h : t) =
345349 let lh = length h
346350 rowsC = fromInteger (natVal (Proxy :: Proxy (Count c)))
347− condition = all (== lh) (map length t)
351+ condition = all ((== lh) . length) t
348352 in if lh > 0 && condition
349353 then Fork (fromLists (take rowsC l)) (fromLists (drop rowsC l))
350354 else error "Not all rows have the same length"
@@ -497,6 +501,26 @@ comp c (Join a b) = Join (comp c a) (comp c b) -- Join fusion law
497501 "comp/iden2" forall m. comp iden m = m
498502#-}
499503
504+-- Scalar multiplication of matrices
505+
506+infixl 7 .|
507+-- | Scalar multiplication of matrices.
508+(.|) :: Num e => e -> Matrix e cols rows -> Matrix e cols rows
509+(.|) _ Empty = Empty
510+(.|) e (One a) = One (e * a)
511+(.|) e (Join a b) = Join (e .| a) (e .| b)
512+(.|) e (Fork a b) = Fork (e .| a) (e .| b)
513+
514+-- Scalar division of matrices
515+
516+infixl 7 ./
517+-- | Scalar multiplication of matrices.
518+(./) :: Fractional e => Matrix e cols rows -> e -> Matrix e cols rows
519+(./) Empty _ = Empty
520+(./) (One a) e = One (a / e)
521+(./) (Join a b) e = Join (a ./ e) (b ./ e)
522+(./) (Fork a b) e = Fork (a ./ e) (b ./ e)
523+
500524-- Projections
501525
502526-- | Biproduct first component projection