summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/Matrix.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/Matrix.hs
parent3e4cdbadb0277010b0e089615e3053f6705332cb (diff)
remove Tools
Diffstat (limited to 'packages/base/src/Internal/Matrix.hs')
-rw-r--r--packages/base/src/Internal/Matrix.hs22
1 files changed, 17 insertions, 5 deletions
diff --git a/packages/base/src/Internal/Matrix.hs b/packages/base/src/Internal/Matrix.hs
index 44365d0..d715cbf 100644
--- a/packages/base/src/Internal/Matrix.hs
+++ b/packages/base/src/Internal/Matrix.hs
@@ -16,12 +16,9 @@
16 16
17module Internal.Matrix where 17module Internal.Matrix where
18 18
19
20import Internal.Tools ( splitEvery, fi, compatdim, (//) )
21import Internal.Vector 19import Internal.Vector
22import Internal.Devel 20import Internal.Devel
23import Internal.Vectorized 21import Internal.Vectorized
24import Data.Vector.Storable ( unsafeWith, fromList )
25import Foreign.Marshal.Alloc ( free ) 22import Foreign.Marshal.Alloc ( free )
26import Foreign.Ptr ( Ptr ) 23import Foreign.Ptr ( Ptr )
27import Foreign.Storable ( Storable ) 24import Foreign.Storable ( Storable )
@@ -30,7 +27,7 @@ import Foreign.C.Types ( CInt(..) )
30import Foreign.C.String ( CString, newCString ) 27import Foreign.C.String ( CString, newCString )
31import System.IO.Unsafe ( unsafePerformIO ) 28import System.IO.Unsafe ( unsafePerformIO )
32import Control.DeepSeq ( NFData(..) ) 29import Control.DeepSeq ( NFData(..) )
33 30import Data.List.Split(chunksOf)
34 31
35----------------------------------------------------------------- 32-----------------------------------------------------------------
36 33
@@ -150,7 +147,22 @@ type t ::> s = Mt t s
150 147
151-- | the inverse of 'Data.Packed.Matrix.fromLists' 148-- | the inverse of 'Data.Packed.Matrix.fromLists'
152toLists :: (Element t) => Matrix t -> [[t]] 149toLists :: (Element t) => Matrix t -> [[t]]
153toLists m = splitEvery (cols m) . toList . flatten $ m 150toLists m = chunksOf (cols m) . toList . flatten $ m
151
152
153
154-- | common value with \"adaptable\" 1
155compatdim :: [Int] -> Maybe Int
156compatdim [] = Nothing
157compatdim [a] = Just a
158compatdim (a:b:xs)
159 | a==b = compatdim (b:xs)
160 | a==1 = compatdim (b:xs)
161 | b==1 = compatdim (a:xs)
162 | otherwise = Nothing
163
164
165
154 166
155-- | Create a matrix from a list of vectors. 167-- | Create a matrix from a list of vectors.
156-- All vectors must have the same dimension, 168-- All vectors must have the same dimension,