summaryrefslogtreecommitdiff
path: root/lib/Data/Packed
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-10-15 10:31:45 +0000
committerAlberto Ruiz <aruiz@um.es>2007-10-15 10:31:45 +0000
commit9adf5ded237339dbe41db6c486993c4547396a22 (patch)
treeec36572020d515ffdec785e0f661ef57754a5220 /lib/Data/Packed
parent9d2073dd2cf7873006b0e831754928f7c0be52b7 (diff)
some windows support
Diffstat (limited to 'lib/Data/Packed')
-rw-r--r--lib/Data/Packed/Internal/Common.hs1
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs20
-rw-r--r--lib/Data/Packed/Internal/Vector.hs2
-rw-r--r--lib/Data/Packed/Internal/auxi.c (renamed from lib/Data/Packed/Internal/aux.c)2
-rw-r--r--lib/Data/Packed/Internal/auxi.h (renamed from lib/Data/Packed/Internal/aux.h)0
5 files changed, 13 insertions, 12 deletions
diff --git a/lib/Data/Packed/Internal/Common.hs b/lib/Data/Packed/Internal/Common.hs
index 75a5b1e..2b3ec28 100644
--- a/lib/Data/Packed/Internal/Common.hs
+++ b/lib/Data/Packed/Internal/Common.hs
@@ -70,6 +70,7 @@ errorCode 2003 = "bad file"
70errorCode 2004 = "singular" 70errorCode 2004 = "singular"
71errorCode 2005 = "didn't converge" 71errorCode 2005 = "didn't converge"
72errorCode 2006 = "the input matrix is not positive definite" 72errorCode 2006 = "the input matrix is not positive definite"
73errorCode 2007 = "not yet supported in this OS"
73errorCode n = "code "++show n 74errorCode n = "code "++show n
74 75
75{- | conversion of Haskell functions into function pointers that can be used in the C side 76{- | conversion of Haskell functions into function pointers that can be used in the C side
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index e76500b..bf7f0ec 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -240,9 +240,9 @@ transdataAux fun c1 d c2 =
240 r2 = dim d `div` c2 240 r2 = dim d `div` c2
241 noneed = r1 == 1 || c1 == 1 241 noneed = r1 == 1 || c1 == 1
242 242
243foreign import ccall safe "aux.h transR" 243foreign import ccall safe "auxi.h transR"
244 ctransR :: TMM -- Double ::> Double ::> IO Int 244 ctransR :: TMM -- Double ::> Double ::> IO Int
245foreign import ccall safe "aux.h transC" 245foreign import ccall safe "auxi.h transC"
246 ctransC :: TCMCM -- Complex Double ::> Complex Double ::> IO Int 246 ctransC :: TCMCM -- Complex Double ::> Complex Double ::> IO Int
247 247
248------------------------------------------------------------------ 248------------------------------------------------------------------
@@ -258,14 +258,14 @@ multiplyAux fun a b = unsafePerformIO $ do
258 return r 258 return r
259 259
260multiplyR = multiplyAux cmultiplyR 260multiplyR = multiplyAux cmultiplyR
261foreign import ccall safe "aux.h multiplyR" 261foreign import ccall safe "auxi.h multiplyR"
262 cmultiplyR :: Int -> Int -> Int -> Ptr Double 262 cmultiplyR :: Int -> Int -> Int -> Ptr Double
263 -> Int -> Int -> Int -> Ptr Double 263 -> Int -> Int -> Int -> Ptr Double
264 -> Int -> Int -> Ptr Double 264 -> Int -> Int -> Ptr Double
265 -> IO Int 265 -> IO Int
266 266
267multiplyC = multiplyAux cmultiplyC 267multiplyC = multiplyAux cmultiplyC
268foreign import ccall safe "aux.h multiplyC" 268foreign import ccall safe "auxi.h multiplyC"
269 cmultiplyC :: Int -> Int -> Int -> Ptr (Complex Double) 269 cmultiplyC :: Int -> Int -> Int -> Ptr (Complex Double)
270 -> Int -> Int -> Int -> Ptr (Complex Double) 270 -> Int -> Int -> Int -> Ptr (Complex Double)
271 -> Int -> Int -> Ptr (Complex Double) 271 -> Int -> Int -> Ptr (Complex Double)
@@ -288,7 +288,7 @@ subMatrixR (r0,c0) (rt,ct) x = unsafePerformIO $ do
288 r <- createMatrix RowMajor rt ct 288 r <- createMatrix RowMajor rt ct
289 c_submatrixR r0 (r0+rt-1) c0 (c0+ct-1) // mat cdat x // mat dat r // check "subMatrixR" [dat r] 289 c_submatrixR r0 (r0+rt-1) c0 (c0+ct-1) // mat cdat x // mat dat r // check "subMatrixR" [dat r]
290 return r 290 return r
291foreign import ccall "aux.h submatrixR" c_submatrixR :: Int -> Int -> Int -> Int -> TMM 291foreign import ccall "auxi.h submatrixR" c_submatrixR :: Int -> Int -> Int -> Int -> TMM
292 292
293-- | extraction of a submatrix from a complex matrix 293-- | extraction of a submatrix from a complex matrix
294subMatrixC :: (Int,Int) -> (Int,Int) -> Matrix (Complex Double) -> Matrix (Complex Double) 294subMatrixC :: (Int,Int) -> (Int,Int) -> Matrix (Complex Double) -> Matrix (Complex Double)
@@ -316,12 +316,12 @@ diagAux fun msg (v@V {dim = n}) = unsafePerformIO $ do
316-- | diagonal matrix from a real vector 316-- | diagonal matrix from a real vector
317diagR :: Vector Double -> Matrix Double 317diagR :: Vector Double -> Matrix Double
318diagR = diagAux c_diagR "diagR" 318diagR = diagAux c_diagR "diagR"
319foreign import ccall "aux.h diagR" c_diagR :: TVM 319foreign import ccall "auxi.h diagR" c_diagR :: TVM
320 320
321-- | diagonal matrix from a real vector 321-- | diagonal matrix from a real vector
322diagC :: Vector (Complex Double) -> Matrix (Complex Double) 322diagC :: Vector (Complex Double) -> Matrix (Complex Double)
323diagC = diagAux c_diagC "diagC" 323diagC = diagAux c_diagC "diagC"
324foreign import ccall "aux.h diagC" c_diagC :: TCVCM 324foreign import ccall "auxi.h diagC" c_diagC :: TCVCM
325 325
326-- | creates a square matrix with the given diagonal 326-- | creates a square matrix with the given diagonal
327diag :: Field a => Vector a -> Matrix a 327diag :: Field a => Vector a -> Matrix a
@@ -338,12 +338,12 @@ constantAux fun x n = unsafePerformIO $ do
338 338
339constantR :: Double -> Int -> Vector Double 339constantR :: Double -> Int -> Vector Double
340constantR = constantAux cconstantR 340constantR = constantAux cconstantR
341foreign import ccall safe "aux.h constantR" 341foreign import ccall safe "auxi.h constantR"
342 cconstantR :: Ptr Double -> TV -- Double :> IO Int 342 cconstantR :: Ptr Double -> TV -- Double :> IO Int
343 343
344constantC :: Complex Double -> Int -> Vector (Complex Double) 344constantC :: Complex Double -> Int -> Vector (Complex Double)
345constantC = constantAux cconstantC 345constantC = constantAux cconstantC
346foreign import ccall safe "aux.h constantC" 346foreign import ccall safe "auxi.h constantC"
347 cconstantC :: Ptr (Complex Double) -> TCV -- Complex Double :> IO Int 347 cconstantC :: Ptr (Complex Double) -> TCV -- Complex Double :> IO Int
348 348
349{- | creates a vector with a given number of equal components: 349{- | creates a vector with a given number of equal components:
@@ -381,7 +381,7 @@ fromFile filename (r,c) = do
381 c_gslReadMatrix charname // mat dat res // check "gslReadMatrix" [] 381 c_gslReadMatrix charname // mat dat res // check "gslReadMatrix" []
382 --free charname -- TO DO: free the auxiliary CString 382 --free charname -- TO DO: free the auxiliary CString
383 return res 383 return res
384foreign import ccall "aux.h matrix_fscanf" c_gslReadMatrix:: Ptr CChar -> TM 384foreign import ccall "auxi.h matrix_fscanf" c_gslReadMatrix:: Ptr CChar -> TM
385 385
386------------------------------------------------------------------------- 386-------------------------------------------------------------------------
387 387
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs
index ebe6371..9557206 100644
--- a/lib/Data/Packed/Internal/Vector.hs
+++ b/lib/Data/Packed/Internal/Vector.hs
@@ -46,7 +46,7 @@ check msg ls f = do
46 return () 46 return ()
47 47
48-- | description of GSL error codes 48-- | description of GSL error codes
49foreign import ccall "aux.h gsl_strerror" gsl_strerror :: Int -> IO (Ptr CChar) 49foreign import ccall "auxi.h gsl_strerror" gsl_strerror :: Int -> IO (Ptr CChar)
50 50
51-- | signature of foreign functions admitting C-style vectors 51-- | signature of foreign functions admitting C-style vectors
52type Vc t s = Int -> Ptr t -> s 52type Vc t s = Int -> Ptr t -> s
diff --git a/lib/Data/Packed/Internal/aux.c b/lib/Data/Packed/Internal/auxi.c
index 3db3535..b53d9b7 100644
--- a/lib/Data/Packed/Internal/aux.c
+++ b/lib/Data/Packed/Internal/auxi.c
@@ -1,4 +1,4 @@
1#include "aux.h" 1#include "auxi.h"
2#include <gsl/gsl_blas.h> 2#include <gsl/gsl_blas.h>
3#include <gsl/gsl_linalg.h> 3#include <gsl/gsl_linalg.h>
4#include <gsl/gsl_matrix.h> 4#include <gsl/gsl_matrix.h>
diff --git a/lib/Data/Packed/Internal/aux.h b/lib/Data/Packed/Internal/auxi.h
index 73334e3..73334e3 100644
--- a/lib/Data/Packed/Internal/aux.h
+++ b/lib/Data/Packed/Internal/auxi.h