summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/Element.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-06-06 13:10:09 +0200
committerAlberto Ruiz <aruiz@um.es>2015-06-06 13:10:09 +0200
commitde69c1cd115cf2702f4ef6c6932d25ae52375e83 (patch)
tree03b0b87816a380bf5628ad791b2f034529eaf4e4 /packages/base/src/Internal/Element.hs
parent3e4cdbadb0277010b0e089615e3053f6705332cb (diff)
remove Tools
Diffstat (limited to 'packages/base/src/Internal/Element.hs')
-rw-r--r--packages/base/src/Internal/Element.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/packages/base/src/Internal/Element.hs b/packages/base/src/Internal/Element.hs
index 61a75d8..55bff67 100644
--- a/packages/base/src/Internal/Element.hs
+++ b/packages/base/src/Internal/Element.hs
@@ -21,15 +21,14 @@
21 21
22module Internal.Element where 22module Internal.Element where
23 23
24import Internal.Tools
25import Internal.Vector 24import Internal.Vector
26import Internal.Matrix 25import Internal.Matrix
27import Internal.Vectorized 26import Internal.Vectorized
28import qualified Internal.ST as ST 27import qualified Internal.ST as ST
29import Data.Array 28import Data.Array
30import Text.Printf 29import Text.Printf
31import Data.Vector.Storable(fromList)
32import Data.List(transpose,intersperse) 30import Data.List(transpose,intersperse)
31import Data.List.Split(chunksOf)
33import Foreign.Storable(Storable) 32import Foreign.Storable(Storable)
34import Control.Monad(liftM) 33import Control.Monad(liftM)
35 34
@@ -165,6 +164,15 @@ m ?? (er,ec) = extractR m moder rs modec cs
165 164
166-------------------------------------------------------------------------------- 165--------------------------------------------------------------------------------
167 166
167-- | obtains the common value of a property of a list
168common :: (Eq a) => (b->a) -> [b] -> Maybe a
169common f = commonval . map f
170 where
171 commonval :: (Eq a) => [a] -> Maybe a
172 commonval [] = Nothing
173 commonval [a] = Just a
174 commonval (a:b:xs) = if a==b then commonval (b:xs) else Nothing
175
168 176
169-- | creates a matrix from a vertical list of matrices 177-- | creates a matrix from a vertical list of matrices
170joinVert :: Element t => [Matrix t] -> Matrix t 178joinVert :: Element t => [Matrix t] -> Matrix t
@@ -210,7 +218,7 @@ adaptBlocks ms = ms' where
210 rs = map (compatdim . map rows) ms 218 rs = map (compatdim . map rows) ms
211 cs = map (compatdim . map cols) (transpose ms) 219 cs = map (compatdim . map cols) (transpose ms)
212 szs = sequence [rs,cs] 220 szs = sequence [rs,cs]
213 ms' = splitEvery bc $ zipWith g szs (concat ms) 221 ms' = chunksOf bc $ zipWith g szs (concat ms)
214 222
215 g [Just nr,Just nc] m 223 g [Just nr,Just nc] m
216 | nr == r && nc == c = m 224 | nr == r && nc == c = m