summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Internal')
-rw-r--r--lib/Data/Packed/Internal/Common.hs3
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs19
-rw-r--r--lib/Data/Packed/Internal/Vector.hs7
3 files changed, 12 insertions, 17 deletions
diff --git a/lib/Data/Packed/Internal/Common.hs b/lib/Data/Packed/Internal/Common.hs
index dc1c2b4..7305d8c 100644
--- a/lib/Data/Packed/Internal/Common.hs
+++ b/lib/Data/Packed/Internal/Common.hs
@@ -20,9 +20,6 @@ import Foreign
20import Complex 20import Complex
21import Control.Monad(when) 21import Control.Monad(when)
22import Debug.Trace 22import Debug.Trace
23import Data.List(transpose,intersperse)
24import Data.Typeable
25import Data.Maybe(fromJust)
26import Foreign.C.String(peekCString) 23import Foreign.C.String(peekCString)
27import Foreign.C.Types 24import Foreign.C.Types
28 25
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index 0519603..4cc94b7 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -22,7 +22,6 @@ import Data.Packed.Internal.Vector
22import Foreign hiding (xor) 22import Foreign hiding (xor)
23import Complex 23import Complex
24import Control.Monad(when) 24import Control.Monad(when)
25import Data.Maybe(fromJust)
26import Foreign.C.String 25import Foreign.C.String
27import Foreign.C.Types 26import Foreign.C.Types
28import Data.List(transpose) 27import Data.List(transpose)
@@ -83,14 +82,14 @@ mat = withMatrix
83 82
84withMatrix MC {rows = r, cols = c, cdat = d } f = 83withMatrix MC {rows = r, cols = c, cdat = d } f =
85 withForeignPtr (fptr d) $ \p -> do 84 withForeignPtr (fptr d) $ \p -> do
86 let m f = do 85 let m g = do
87 f r c p 86 g r c p
88 f m 87 f m
89 88
90withMatrix MF {rows = r, cols = c, fdat = d } f = 89withMatrix MF {rows = r, cols = c, fdat = d } f =
91 withForeignPtr (fptr d) $ \p -> do 90 withForeignPtr (fptr d) $ \p -> do
92 let m f = do 91 let m g = do
93 f r c p 92 g r c p
94 f m 93 f m
95 94
96{- | Creates a vector by concatenation of rows 95{- | Creates a vector by concatenation of rows
@@ -262,8 +261,8 @@ foreign import ccall safe "auxi.h transC"
262 261
263------------------------------------------------------------------ 262------------------------------------------------------------------
264 263
265gmatC MF {rows = r, cols = c, fdat = d} p f = f 1 c r p 264gmatC MF { rows = r, cols = c } p f = f 1 c r p
266gmatC MC {rows = r, cols = c, cdat = d} p f = f 0 r c p 265gmatC MC { rows = r, cols = c } p f = f 0 r c p
267 266
268dtt MC { cdat = d } = d 267dtt MC { cdat = d } = d
269dtt MF { fdat = d } = d 268dtt MF { fdat = d } = d
@@ -273,8 +272,8 @@ multiplyAux fun a b = unsafePerformIO $ do
273 show (rows a,cols a) ++ " x " ++ show (rows b, cols b) 272 show (rows a,cols a) ++ " x " ++ show (rows b, cols b)
274 r <- createMatrix RowMajor (rows a) (cols b) 273 r <- createMatrix RowMajor (rows a) (cols b)
275 withForeignPtr (fptr (dtt a)) $ \pa -> withForeignPtr (fptr (dtt b)) $ \pb -> 274 withForeignPtr (fptr (dtt a)) $ \pa -> withForeignPtr (fptr (dtt b)) $ \pb ->
276 withMatrix r $ \r -> 275 withMatrix r $ \r' ->
277 fun // gmatC a pa // gmatC b pb // r // check "multiplyAux" 276 fun // gmatC a pa // gmatC b pb // r' // check "multiplyAux"
278 return r 277 return r
279 278
280multiplyR = multiplyAux cmultiplyR 279multiplyR = multiplyAux cmultiplyR
@@ -421,7 +420,7 @@ diagG v = matrixFromVector RowMajor c $ fromList $ [ l!!(i-1) * delta k i | k <-
421 | otherwise = 0 420 | otherwise = 0
422-} 421-}
423 422
424transdataG c1 d c2 = fromList . concat . transpose . partit c1 . toList $ d 423transdataG c1 d _ = fromList . concat . transpose . partit c1 . toList $ d
425 424
426dotL a b = sum (zipWith (*) a b) 425dotL a b = sum (zipWith (*) a b)
427 426
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs
index 7eee5fe..ac6588b 100644
--- a/lib/Data/Packed/Internal/Vector.hs
+++ b/lib/Data/Packed/Internal/Vector.hs
@@ -20,7 +20,6 @@ import Data.Packed.Internal.Common
20import Foreign 20import Foreign
21import Complex 21import Complex
22import Control.Monad(when) 22import Control.Monad(when)
23import Data.List(transpose)
24 23
25-- | A one-dimensional array of objects stored in a contiguous memory block. 24-- | A one-dimensional array of objects stored in a contiguous memory block.
26data Vector t = V { dim :: Int -- ^ number of elements 25data Vector t = V { dim :: Int -- ^ number of elements
@@ -39,8 +38,8 @@ type Vc t s = Int -> Ptr t -> s
39vec = withVector 38vec = withVector
40 39
41withVector (V n fp) f = withForeignPtr fp $ \p -> do 40withVector (V n fp) f = withForeignPtr fp $ \p -> do
42 let v f = do 41 let v g = do
43 f n p 42 g n p
44 f v 43 f v
45 44
46-- | allocates memory for a new vector 45-- | allocates memory for a new vector
@@ -132,7 +131,7 @@ join as = unsafePerformIO $ do
132 joiner as tot ptr 131 joiner as tot ptr
133 return r 132 return r
134 where joiner [] _ _ = return () 133 where joiner [] _ _ = return ()
135 joiner (r@V {dim = n, fptr = b} : cs) _ p = do 134 joiner (V {dim = n, fptr = b} : cs) _ p = do
136 withForeignPtr b $ \pb -> copyArray p pb n 135 withForeignPtr b $ \pb -> copyArray p pb n
137 joiner cs 0 (advancePtr p n) 136 joiner cs 0 (advancePtr p n)
138 137