summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/Element.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-06-24 17:07:29 +0200
committerAlberto Ruiz <aruiz@um.es>2015-06-24 17:07:29 +0200
commit624046d6b55d37104f950e8888ab68c53a2e6bf0 (patch)
tree664fa33c2c995078439f277c0d6147ca0ad8ffe4 /packages/base/src/Internal/Element.hs
parentfbff5949bba157b0da08a4b59124c7976289fb65 (diff)
initial support of sliceMatrix, remove transdata
Diffstat (limited to 'packages/base/src/Internal/Element.hs')
-rw-r--r--packages/base/src/Internal/Element.hs12
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))
173m ?? (DropLast n, e) = m ?? (Take (rows m - n), e) 173m ?? (DropLast n, e) = m ?? (Take (rows m - n), e)
174m ?? (e, DropLast n) = m ?? (e, Take (cols m - n)) 174m ?? (e, DropLast n) = m ?? (e, Take (cols m - n))
175 175
176m ?? (er,ec) = unsafePerformIO $ extractR m moder rs modec cs 176m ?? (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
492lM f m1 m2 = matrixFromVector 492lM 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
498compat' :: Matrix a -> Matrix b -> Bool 502compat' :: Matrix a -> Matrix b -> Bool
499compat' m1 m2 = s1 == (1,1) || s2 == (1,1) || s1 == s2 503compat' 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
598mapMatrix :: (Storable a, Storable b) => (a -> b) -> Matrix a -> Matrix b 602mapMatrix :: (Element a, Element b) => (a -> b) -> Matrix a -> Matrix b
599mapMatrix f = liftMatrix (mapVector f) 603mapMatrix f = liftMatrix (mapVector f)
600 604