summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Matrix.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2008-01-22 13:06:13 +0000
committerAlberto Ruiz <aruiz@um.es>2008-01-22 13:06:13 +0000
commitbaeb3890896e424e57582b108f7419f4ae479c42 (patch)
tree09d805dc1460e0530f9e55c31707c65cecb54aa9 /lib/Data/Packed/Internal/Matrix.hs
parente92696514c8861e7bed7abb434ca24527861c05c (diff)
CInt in all imports
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs38
1 files changed, 13 insertions, 25 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index c20726b..86c5915 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -83,13 +83,13 @@ mat = withMatrix
83withMatrix MC {rows = r, cols = c, cdat = d } f = 83withMatrix MC {rows = r, cols = c, cdat = d } f =
84 withForeignPtr (fptr d) $ \p -> do 84 withForeignPtr (fptr d) $ \p -> do
85 let m g = do 85 let m g = do
86 g r c p 86 g (fi r) (fi c) p
87 f m 87 f m
88 88
89withMatrix MF {rows = r, cols = c, fdat = d } f = 89withMatrix MF {rows = r, cols = c, fdat = d } f =
90 withForeignPtr (fptr d) $ \p -> do 90 withForeignPtr (fptr d) $ \p -> do
91 let m g = do 91 let m g = do
92 g r c p 92 g (fi r) (fi c) p
93 f m 93 f m
94 94
95{- | Creates a vector by concatenation of rows 95{- | Creates a vector by concatenation of rows
@@ -247,22 +247,20 @@ transdataAux fun c1 d c2 =
247 v <- createVector (dim d) 247 v <- createVector (dim d)
248 withForeignPtr (fptr d) $ \pd -> 248 withForeignPtr (fptr d) $ \pd ->
249 withForeignPtr (fptr v) $ \pv -> 249 withForeignPtr (fptr v) $ \pv ->
250 fun r1 c1 pd r2 c2 pv // check "transdataAux" 250 fun (fi r1) (fi c1) pd (fi r2) (fi c2) pv // check "transdataAux"
251 -- putStrLn $ "---> transdataAux" ++ show (toList d) ++ show (toList v) 251 -- putStrLn $ "---> transdataAux" ++ show (toList d) ++ show (toList v)
252 return v 252 return v
253 where r1 = dim d `div` c1 253 where r1 = dim d `div` c1
254 r2 = dim d `div` c2 254 r2 = dim d `div` c2
255 noneed = r1 == 1 || c1 == 1 255 noneed = r1 == 1 || c1 == 1
256 256
257foreign import ccall unsafe "auxi.h transR" 257foreign import ccall unsafe "auxi.h transR" ctransR :: TMM
258 ctransR :: TMM -- Double ::> Double ::> IO Int 258foreign import ccall unsafe "auxi.h transC" ctransC :: TCMCM
259foreign import ccall unsafe "auxi.h transC"
260 ctransC :: TCMCM -- Complex Double ::> Complex Double ::> IO Int
261 259
262------------------------------------------------------------------ 260------------------------------------------------------------------
263 261
264gmatC MF { rows = r, cols = c } p f = f 1 c r p 262gmatC MF { rows = r, cols = c } p f = f 1 (fi c) (fi r) p
265gmatC MC { rows = r, cols = c } p f = f 0 r c p 263gmatC MC { rows = r, cols = c } p f = f 0 (fi r) (fi c) p
266 264
267dtt MC { cdat = d } = d 265dtt MC { cdat = d } = d
268dtt MF { fdat = d } = d 266dtt MF { fdat = d } = d
@@ -277,18 +275,10 @@ multiplyAux fun a b = unsafePerformIO $ do
277 return r 275 return r
278 276
279multiplyR = multiplyAux cmultiplyR 277multiplyR = multiplyAux cmultiplyR
280foreign import ccall unsafe "auxi.h multiplyR" 278foreign import ccall unsafe "auxi.h multiplyR" cmultiplyR :: TauxMul Double
281 cmultiplyR :: Int -> Int -> Int -> Ptr Double
282 -> Int -> Int -> Int -> Ptr Double
283 -> Int -> Int -> Ptr Double
284 -> IO CInt
285 279
286multiplyC = multiplyAux cmultiplyC 280multiplyC = multiplyAux cmultiplyC
287foreign import ccall unsafe "auxi.h multiplyC" 281foreign import ccall unsafe "auxi.h multiplyC" cmultiplyC :: TauxMul (Complex Double)
288 cmultiplyC :: Int -> Int -> Int -> Ptr (Complex Double)
289 -> Int -> Int -> Int -> Ptr (Complex Double)
290 -> Int -> Int -> Ptr (Complex Double)
291 -> IO CInt
292 282
293-- | matrix product 283-- | matrix product
294multiply :: (Element a) => Matrix a -> Matrix a -> Matrix a 284multiply :: (Element a) => Matrix a -> Matrix a -> Matrix a
@@ -301,9 +291,9 @@ subMatrixR :: (Int,Int) -> (Int,Int) -> Matrix Double -> Matrix Double
301subMatrixR (r0,c0) (rt,ct) x' = unsafePerformIO $ do 291subMatrixR (r0,c0) (rt,ct) x' = unsafePerformIO $ do
302 r <- createMatrix RowMajor rt ct 292 r <- createMatrix RowMajor rt ct
303 let x = cmat x' 293 let x = cmat x'
304 app2 (c_submatrixR r0 (r0+rt-1) c0 (c0+ct-1)) mat x mat r "subMatrixR" 294 app2 (c_submatrixR (fi r0) (fi $ r0+rt-1) (fi c0) (fi $ c0+ct-1)) mat x mat r "subMatrixR"
305 return r 295 return r
306foreign import ccall "auxi.h submatrixR" c_submatrixR :: Int -> Int -> Int -> Int -> TMM 296foreign import ccall "auxi.h submatrixR" c_submatrixR :: CInt -> CInt -> CInt -> CInt -> TMM
307 297
308-- | extraction of a submatrix from a complex matrix 298-- | extraction of a submatrix from a complex matrix
309subMatrixC :: (Int,Int) -> (Int,Int) -> Matrix (Complex Double) -> Matrix (Complex Double) 299subMatrixC :: (Int,Int) -> (Int,Int) -> Matrix (Complex Double) -> Matrix (Complex Double)
@@ -353,13 +343,11 @@ constantAux fun x n = unsafePerformIO $ do
353 343
354constantR :: Double -> Int -> Vector Double 344constantR :: Double -> Int -> Vector Double
355constantR = constantAux cconstantR 345constantR = constantAux cconstantR
356foreign import ccall "auxi.h constantR" 346foreign import ccall "auxi.h constantR" cconstantR :: Ptr Double -> TV
357 cconstantR :: Ptr Double -> TV -- Double :> IO Int
358 347
359constantC :: Complex Double -> Int -> Vector (Complex Double) 348constantC :: Complex Double -> Int -> Vector (Complex Double)
360constantC = constantAux cconstantC 349constantC = constantAux cconstantC
361foreign import ccall "auxi.h constantC" 350foreign import ccall "auxi.h constantC" cconstantC :: Ptr (Complex Double) -> TCV
362 cconstantC :: Ptr (Complex Double) -> TCV -- Complex Double :> IO Int
363 351
364{- | creates a vector with a given number of equal components: 352{- | creates a vector with a given number of equal components:
365 353