diff options
Diffstat (limited to 'packages/base/src/Internal/Element.hs')
-rw-r--r-- | packages/base/src/Internal/Element.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/base/src/Internal/Element.hs b/packages/base/src/Internal/Element.hs index 51d5686..6d86f3d 100644 --- a/packages/base/src/Internal/Element.hs +++ b/packages/base/src/Internal/Element.hs | |||
@@ -173,7 +173,7 @@ m ?? (e, TakeLast n) = m ?? (e, Drop (cols m - n)) | |||
173 | m ?? (DropLast n, e) = m ?? (Take (rows m - n), e) | 173 | m ?? (DropLast n, e) = m ?? (Take (rows m - n), e) |
174 | m ?? (e, DropLast n) = m ?? (e, Take (cols m - n)) | 174 | m ?? (e, DropLast n) = m ?? (e, Take (cols m - n)) |
175 | 175 | ||
176 | m ?? (er,ec) = unsafePerformIO $ extractR m moder rs modec cs | 176 | m ?? (er,ec) = unsafePerformIO $ extractR (orderOf m) m moder rs modec cs |
177 | where | 177 | where |
178 | (moder,rs) = mkExt (rows m) er | 178 | (moder,rs) = mkExt (rows m) er |
179 | (modec,cs) = mkExt (cols m) ec | 179 | (modec,cs) = mkExt (cols m) ec |
@@ -491,9 +491,13 @@ liftMatrix2Auto f m1 m2 | |||
491 | -- FIXME do not flatten if equal order | 491 | -- FIXME do not flatten if equal order |
492 | lM f m1 m2 = matrixFromVector | 492 | lM f m1 m2 = matrixFromVector |
493 | RowMajor | 493 | RowMajor |
494 | (max (rows m1) (rows m2)) | 494 | (max' (rows m1) (rows m2)) |
495 | (max (cols m1) (cols m2)) | 495 | (max' (cols m1) (cols m2)) |
496 | (f (flatten m1) (flatten m2)) | 496 | (f (flatten m1) (flatten m2)) |
497 | where | ||
498 | max' 1 b = b | ||
499 | max' a 1 = a | ||
500 | max' a b = max a b | ||
497 | 501 | ||
498 | compat' :: Matrix a -> Matrix b -> Bool | 502 | compat' :: Matrix a -> Matrix b -> Bool |
499 | compat' m1 m2 = s1 == (1,1) || s2 == (1,1) || s1 == s2 | 503 | compat' m1 m2 = s1 == (1,1) || s2 == (1,1) || s1 == s2 |
@@ -595,6 +599,6 @@ mapMatrixWithIndex g m = reshape c . mapVectorWithIndex (mk c g) . flatten $ m | |||
595 | where | 599 | where |
596 | c = cols m | 600 | c = cols m |
597 | 601 | ||
598 | mapMatrix :: (Storable a, Storable b) => (a -> b) -> Matrix a -> Matrix b | 602 | mapMatrix :: (Element a, Element b) => (a -> b) -> Matrix a -> Matrix b |
599 | mapMatrix f = liftMatrix (mapVector f) | 603 | mapMatrix f = liftMatrix (mapVector f) |
600 | 604 | ||