summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Matrix.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-06-22 10:21:15 +0000
committerAlberto Ruiz <aruiz@um.es>2007-06-22 10:21:15 +0000
commit989bdf7e88c13500bd1986dcde36f6cc4f467efb (patch)
treeb30ff0dd52e2b6c2adb1dfe8759d03234f65c684 /lib/Data/Packed/Internal/Matrix.hs
parentaa14e6615533e7bd5e2b15acdc3ec76afbe1aac4 (diff)
reverting to the old signatures for aux C functions
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index fccf8bb..2925fc0 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -50,8 +50,9 @@ trans m = m { rows = cols m
50 } 50 }
51 51
52type Mt t s = Int -> Int -> Ptr t -> s 52type Mt t s = Int -> Int -> Ptr t -> s
53infixr 6 ::> 53-- not yet admitted by my haddock version
54type t ::> s = Mt t s 54-- infixr 6 ::>
55-- type t ::> s = Mt t s
55 56
56mat d m f = f (rows m) (cols m) (ptr (d m)) 57mat d m f = f (rows m) (cols m) (ptr (d m))
57 58
@@ -117,9 +118,9 @@ transdataAux fun c1 d c2 =
117 noneed = r1 == 1 || c1 == 1 118 noneed = r1 == 1 || c1 == 1
118 119
119foreign import ccall safe "aux.h transR" 120foreign import ccall safe "aux.h transR"
120 ctransR :: Double ::> Double ::> IO Int 121 ctransR :: TMM -- Double ::> Double ::> IO Int
121foreign import ccall safe "aux.h transC" 122foreign import ccall safe "aux.h transC"
122 ctransC :: Complex Double ::> Complex Double ::> IO Int 123 ctransC :: TCMCM -- Complex Double ::> Complex Double ::> IO Int
123 124
124transdata :: Field a => Int -> Vector a -> Int -> Vector a 125transdata :: Field a => Int -> Vector a -> Int -> Vector a
125transdata c1 d c2 | isReal baseOf d = scast $ transdataR c1 (scast d) c2 126transdata c1 d c2 | isReal baseOf d = scast $ transdataR c1 (scast d) c2
@@ -170,10 +171,16 @@ multiplyAux order fun a b = unsafePerformIO $ do
170 return r 171 return r
171 172
172foreign import ccall safe "aux.h multiplyR" 173foreign import ccall safe "aux.h multiplyR"
173 cmultiplyR :: Int -> Double ::> (Int -> Double ::> (Double ::> IO Int)) 174 cmultiplyR :: Int -> Int -> Int -> Ptr Double
175 -> Int -> Int -> Int -> Ptr Double
176 -> Int -> Int -> Ptr Double
177 -> IO Int
174 178
175foreign import ccall safe "aux.h multiplyC" 179foreign import ccall safe "aux.h multiplyC"
176 cmultiplyC :: Int -> Complex Double ::> (Int -> Complex Double ::> (Complex Double ::> IO Int)) 180 cmultiplyC :: Int -> Int -> Int -> Ptr (Complex Double)
181 -> Int -> Int -> Int -> Ptr (Complex Double)
182 -> Int -> Int -> Ptr (Complex Double)
183 -> IO Int
177 184
178multiply :: (Num a, Field a) => MatrixOrder -> Matrix a -> Matrix a -> Matrix a 185multiply :: (Num a, Field a) => MatrixOrder -> Matrix a -> Matrix a -> Matrix a
179multiply RowMajor a b = multiplyD RowMajor a b 186multiply RowMajor a b = multiplyD RowMajor a b
@@ -206,7 +213,7 @@ subMatrixR (r0,c0) (rt,ct) x = unsafePerformIO $ do
206 c_submatrixR r0 (r0+rt-1) c0 (c0+ct-1) // mat cdat x // mat cdat r // check "subMatrixR" [dat r] 213 c_submatrixR r0 (r0+rt-1) c0 (c0+ct-1) // mat cdat x // mat cdat r // check "subMatrixR" [dat r]
207 return r 214 return r
208foreign import ccall "aux.h submatrixR" 215foreign import ccall "aux.h submatrixR"
209 c_submatrixR :: Int -> Int -> Int -> Int -> Double ::> Double ::> IO Int 216 c_submatrixR :: Int -> Int -> Int -> Int -> TMM
210 217
211-- | extraction of a submatrix of a complex matrix 218-- | extraction of a submatrix of a complex matrix
212subMatrixC :: (Int,Int) -- ^ (r0,c0) starting position 219subMatrixC :: (Int,Int) -- ^ (r0,c0) starting position
@@ -239,12 +246,12 @@ diagAux fun msg (v@V {dim = n}) = unsafePerformIO $ do
239-- | diagonal matrix from a real vector 246-- | diagonal matrix from a real vector
240diagR :: Vector Double -> Matrix Double 247diagR :: Vector Double -> Matrix Double
241diagR = diagAux c_diagR "diagR" 248diagR = diagAux c_diagR "diagR"
242foreign import ccall "aux.h diagR" c_diagR :: Double :> Double ::> IO Int 249foreign import ccall "aux.h diagR" c_diagR :: TVM
243 250
244-- | diagonal matrix from a real vector 251-- | diagonal matrix from a real vector
245diagC :: Vector (Complex Double) -> Matrix (Complex Double) 252diagC :: Vector (Complex Double) -> Matrix (Complex Double)
246diagC = diagAux c_diagC "diagC" 253diagC = diagAux c_diagC "diagC"
247foreign import ccall "aux.h diagC" c_diagC :: (Complex Double) :> (Complex Double) ::> IO Int 254foreign import ccall "aux.h diagC" c_diagC :: TCVCM
248 255
249-- | diagonal matrix from a vector 256-- | diagonal matrix from a vector
250diag :: (Num a, Field a) => Vector a -> Matrix a 257diag :: (Num a, Field a) => Vector a -> Matrix a