diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-01-22 13:06:13 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-01-22 13:06:13 +0000 |
commit | baeb3890896e424e57582b108f7419f4ae479c42 (patch) | |
tree | 09d805dc1460e0530f9e55c31707c65cecb54aa9 /lib/Data/Packed/Internal/Matrix.hs | |
parent | e92696514c8861e7bed7abb434ca24527861c05c (diff) |
CInt in all imports
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 38 |
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 | |||
83 | withMatrix MC {rows = r, cols = c, cdat = d } f = | 83 | withMatrix 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 | ||
89 | withMatrix MF {rows = r, cols = c, fdat = d } f = | 89 | withMatrix 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 | ||
257 | foreign import ccall unsafe "auxi.h transR" | 257 | foreign import ccall unsafe "auxi.h transR" ctransR :: TMM |
258 | ctransR :: TMM -- Double ::> Double ::> IO Int | 258 | foreign import ccall unsafe "auxi.h transC" ctransC :: TCMCM |
259 | foreign import ccall unsafe "auxi.h transC" | ||
260 | ctransC :: TCMCM -- Complex Double ::> Complex Double ::> IO Int | ||
261 | 259 | ||
262 | ------------------------------------------------------------------ | 260 | ------------------------------------------------------------------ |
263 | 261 | ||
264 | gmatC MF { rows = r, cols = c } p f = f 1 c r p | 262 | gmatC MF { rows = r, cols = c } p f = f 1 (fi c) (fi r) p |
265 | gmatC MC { rows = r, cols = c } p f = f 0 r c p | 263 | gmatC MC { rows = r, cols = c } p f = f 0 (fi r) (fi c) p |
266 | 264 | ||
267 | dtt MC { cdat = d } = d | 265 | dtt MC { cdat = d } = d |
268 | dtt MF { fdat = d } = d | 266 | dtt MF { fdat = d } = d |
@@ -277,18 +275,10 @@ multiplyAux fun a b = unsafePerformIO $ do | |||
277 | return r | 275 | return r |
278 | 276 | ||
279 | multiplyR = multiplyAux cmultiplyR | 277 | multiplyR = multiplyAux cmultiplyR |
280 | foreign import ccall unsafe "auxi.h multiplyR" | 278 | foreign 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 | ||
286 | multiplyC = multiplyAux cmultiplyC | 280 | multiplyC = multiplyAux cmultiplyC |
287 | foreign import ccall unsafe "auxi.h multiplyC" | 281 | foreign 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 |
294 | multiply :: (Element a) => Matrix a -> Matrix a -> Matrix a | 284 | multiply :: (Element a) => Matrix a -> Matrix a -> Matrix a |
@@ -301,9 +291,9 @@ subMatrixR :: (Int,Int) -> (Int,Int) -> Matrix Double -> Matrix Double | |||
301 | subMatrixR (r0,c0) (rt,ct) x' = unsafePerformIO $ do | 291 | subMatrixR (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 |
306 | foreign import ccall "auxi.h submatrixR" c_submatrixR :: Int -> Int -> Int -> Int -> TMM | 296 | foreign 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 |
309 | subMatrixC :: (Int,Int) -> (Int,Int) -> Matrix (Complex Double) -> Matrix (Complex Double) | 299 | subMatrixC :: (Int,Int) -> (Int,Int) -> Matrix (Complex Double) -> Matrix (Complex Double) |
@@ -353,13 +343,11 @@ constantAux fun x n = unsafePerformIO $ do | |||
353 | 343 | ||
354 | constantR :: Double -> Int -> Vector Double | 344 | constantR :: Double -> Int -> Vector Double |
355 | constantR = constantAux cconstantR | 345 | constantR = constantAux cconstantR |
356 | foreign import ccall "auxi.h constantR" | 346 | foreign import ccall "auxi.h constantR" cconstantR :: Ptr Double -> TV |
357 | cconstantR :: Ptr Double -> TV -- Double :> IO Int | ||
358 | 347 | ||
359 | constantC :: Complex Double -> Int -> Vector (Complex Double) | 348 | constantC :: Complex Double -> Int -> Vector (Complex Double) |
360 | constantC = constantAux cconstantC | 349 | constantC = constantAux cconstantC |
361 | foreign import ccall "auxi.h constantC" | 350 | foreign 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 | ||