From 2b5ea5fdbf68b8c125a9a256aa15a6de849cdbca Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Sat, 1 Jan 2011 20:25:47 +0000 Subject: simplified liftMatrix2Auto --- lib/Numeric/ContainerBoot.hs | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'lib/Numeric/ContainerBoot.hs') diff --git a/lib/Numeric/ContainerBoot.hs b/lib/Numeric/ContainerBoot.hs index 276eaa8..d9f0d78 100644 --- a/lib/Numeric/ContainerBoot.hs +++ b/lib/Numeric/ContainerBoot.hs @@ -639,33 +639,12 @@ assocM (r,c) z xs = ST.runSTMatrix $ do ---------------------------------------------------------------------- -conformMTo (r,c) m - | size m == (r,c) = m - | size m == (1,1) = konst (m@@>(0,0)) (r,c) - | size m == (r,1) = repCols c m - | size m == (1,c) = repRows r m - | otherwise = error $ "matrix " ++ shSize m ++ " cannot be expanded to (" ++ show r ++ "><"++ show c ++")" - -conformVTo n v - | dim v == n = v - | dim v == 1 = konst (v@>0) n - | otherwise = error $ "vector of dim=" ++ show (dim v) ++ " cannot be expanded to dim=" ++ show n - -repRows n x = fromRows (replicate n (flatten x)) -repCols n x = fromColumns (replicate n (flatten x)) - -size m = (rows m, cols m) - -shSize m = "(" ++ show (rows m) ++"><"++ show (cols m)++")" - -condM a b l e t = reshape c $ cond a' b' l' e' t' +condM a b l e t = reshape (cols a'') $ cond a' b' l' e' t' where - r = maximum (map rows [a,b,l,e,t]) - c = maximum (map cols [a,b,l,e,t]) - [a', b', l', e', t'] = map (flatten . conformMTo (r,c)) [a,b,l,e,t] + args@(a'':_) = conformMs [a,b,l,e,t] + [a', b', l', e', t'] = map flatten args condV f a b l e t = f a' b' l' e' t' where - n = maximum (map dim [a,b,l,e,t]) - [a', b', l', e', t'] = map (conformVTo n) [a,b,l,e,t] + [a', b', l', e', t'] = conformVs [a,b,l,e,t] -- cgit v1.2.3