diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-06-06 13:10:09 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-06-06 13:10:09 +0200 |
commit | de69c1cd115cf2702f4ef6c6932d25ae52375e83 (patch) | |
tree | 03b0b87816a380bf5628ad791b2f034529eaf4e4 /packages/base/src/Internal/Element.hs | |
parent | 3e4cdbadb0277010b0e089615e3053f6705332cb (diff) |
remove Tools
Diffstat (limited to 'packages/base/src/Internal/Element.hs')
-rw-r--r-- | packages/base/src/Internal/Element.hs | 14 |
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 | ||
22 | module Internal.Element where | 22 | module Internal.Element where |
23 | 23 | ||
24 | import Internal.Tools | ||
25 | import Internal.Vector | 24 | import Internal.Vector |
26 | import Internal.Matrix | 25 | import Internal.Matrix |
27 | import Internal.Vectorized | 26 | import Internal.Vectorized |
28 | import qualified Internal.ST as ST | 27 | import qualified Internal.ST as ST |
29 | import Data.Array | 28 | import Data.Array |
30 | import Text.Printf | 29 | import Text.Printf |
31 | import Data.Vector.Storable(fromList) | ||
32 | import Data.List(transpose,intersperse) | 30 | import Data.List(transpose,intersperse) |
31 | import Data.List.Split(chunksOf) | ||
33 | import Foreign.Storable(Storable) | 32 | import Foreign.Storable(Storable) |
34 | import Control.Monad(liftM) | 33 | import 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 | ||
168 | common :: (Eq a) => (b->a) -> [b] -> Maybe a | ||
169 | common 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 |
170 | joinVert :: Element t => [Matrix t] -> Matrix t | 178 | joinVert :: 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 |