diff options
author | Clark Gaebel <cgaebel@csclub.uwaterloo.ca> | 2012-03-10 22:47:13 -0500 |
---|---|---|
committer | Clark Gaebel <cgaebel@csclub.uwaterloo.ca> | 2012-03-10 22:47:13 -0500 |
commit | 7832cb74240ba06a23a981c20db3c5da8324828a (patch) | |
tree | b8afe01c34c75486eb3561377d574911422f63ee /lib | |
parent | f8b7b3734fa6bb8d63914719e09d17940add27d4 (diff) |
Added back some safety.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Numeric/GSL/Integration.hs | 12 | ||||
-rw-r--r-- | lib/Numeric/GSL/Internal.hs | 10 | ||||
-rw-r--r-- | lib/Numeric/GSL/Minimization.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/GSL/ODE.hs | 2 | ||||
-rw-r--r-- | lib/Numeric/GSL/Root.hs | 4 |
5 files changed, 16 insertions, 16 deletions
diff --git a/lib/Numeric/GSL/Integration.hs b/lib/Numeric/GSL/Integration.hs index b1e7930..defbf80 100644 --- a/lib/Numeric/GSL/Integration.hs +++ b/lib/Numeric/GSL/Integration.hs | |||
@@ -32,7 +32,7 @@ import System.IO.Unsafe(unsafePerformIO) | |||
32 | 32 | ||
33 | {- | conversion of Haskell functions into function pointers that can be used in the C side | 33 | {- | conversion of Haskell functions into function pointers that can be used in the C side |
34 | -} | 34 | -} |
35 | foreign import ccall unsafe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) | 35 | foreign import ccall safe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) |
36 | 36 | ||
37 | -------------------------------------------------------------------- | 37 | -------------------------------------------------------------------- |
38 | {- | Numerical integration using /gsl_integration_qags/ (adaptive integration with singularities). For example: | 38 | {- | Numerical integration using /gsl_integration_qags/ (adaptive integration with singularities). For example: |
@@ -63,7 +63,7 @@ integrateQAGS prec n f a b = unsafePerformIO $ do | |||
63 | freeHaskellFunPtr fp | 63 | freeHaskellFunPtr fp |
64 | return result | 64 | return result |
65 | 65 | ||
66 | foreign import ccall unsafe "gsl-aux.h integrate_qags" | 66 | foreign import ccall safe "gsl-aux.h integrate_qags" |
67 | c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt | 67 | c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt |
68 | -> Ptr Double -> Ptr Double -> IO CInt | 68 | -> Ptr Double -> Ptr Double -> IO CInt |
69 | 69 | ||
@@ -94,7 +94,7 @@ integrateQNG prec f a b = unsafePerformIO $ do | |||
94 | freeHaskellFunPtr fp | 94 | freeHaskellFunPtr fp |
95 | return result | 95 | return result |
96 | 96 | ||
97 | foreign import ccall unsafe "gsl-aux.h integrate_qng" | 97 | foreign import ccall safe "gsl-aux.h integrate_qng" |
98 | c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double | 98 | c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double |
99 | -> Ptr Double -> Ptr Double -> IO CInt | 99 | -> Ptr Double -> Ptr Double -> IO CInt |
100 | 100 | ||
@@ -126,7 +126,7 @@ integrateQAGI prec n f = unsafePerformIO $ do | |||
126 | freeHaskellFunPtr fp | 126 | freeHaskellFunPtr fp |
127 | return result | 127 | return result |
128 | 128 | ||
129 | foreign import ccall unsafe "gsl-aux.h integrate_qagi" | 129 | foreign import ccall safe "gsl-aux.h integrate_qagi" |
130 | c_integrate_qagi :: FunPtr (Double-> Ptr() -> Double) -> Double -> CInt | 130 | c_integrate_qagi :: FunPtr (Double-> Ptr() -> Double) -> Double -> CInt |
131 | -> Ptr Double -> Ptr Double -> IO CInt | 131 | -> Ptr Double -> Ptr Double -> IO CInt |
132 | 132 | ||
@@ -159,7 +159,7 @@ integrateQAGIU prec n f a = unsafePerformIO $ do | |||
159 | freeHaskellFunPtr fp | 159 | freeHaskellFunPtr fp |
160 | return result | 160 | return result |
161 | 161 | ||
162 | foreign import ccall unsafe "gsl-aux.h integrate_qagiu" | 162 | foreign import ccall safe "gsl-aux.h integrate_qagiu" |
163 | c_integrate_qagiu :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt | 163 | c_integrate_qagiu :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt |
164 | -> Ptr Double -> Ptr Double -> IO CInt | 164 | -> Ptr Double -> Ptr Double -> IO CInt |
165 | 165 | ||
@@ -192,7 +192,7 @@ integrateQAGIL prec n f b = unsafePerformIO $ do | |||
192 | freeHaskellFunPtr fp | 192 | freeHaskellFunPtr fp |
193 | return result | 193 | return result |
194 | 194 | ||
195 | foreign import ccall unsafe "gsl-aux.h integrate_qagil" | 195 | foreign import ccall safe "gsl-aux.h integrate_qagil" |
196 | c_integrate_qagil :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt | 196 | c_integrate_qagil :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt |
197 | -> Ptr Double -> Ptr Double -> IO CInt | 197 | -> Ptr Double -> Ptr Double -> IO CInt |
198 | 198 | ||
diff --git a/lib/Numeric/GSL/Internal.hs b/lib/Numeric/GSL/Internal.hs index 4267b38..84417ce 100644 --- a/lib/Numeric/GSL/Internal.hs +++ b/lib/Numeric/GSL/Internal.hs | |||
@@ -26,14 +26,14 @@ iv f n p = f (createV (fromIntegral n) copy "iv") where | |||
26 | return 0 | 26 | return 0 |
27 | 27 | ||
28 | -- | conversion of Haskell functions into function pointers that can be used in the C side | 28 | -- | conversion of Haskell functions into function pointers that can be used in the C side |
29 | foreign import ccall unsafe "wrapper" | 29 | foreign import ccall safe "wrapper" |
30 | mkVecfun :: (CInt -> Ptr Double -> Double) | 30 | mkVecfun :: (CInt -> Ptr Double -> Double) |
31 | -> IO( FunPtr (CInt -> Ptr Double -> Double)) | 31 | -> IO( FunPtr (CInt -> Ptr Double -> Double)) |
32 | 32 | ||
33 | foreign import ccall unsafe "wrapper" | 33 | foreign import ccall safe "wrapper" |
34 | mkVecVecfun :: TVV -> IO (FunPtr TVV) | 34 | mkVecVecfun :: TVV -> IO (FunPtr TVV) |
35 | 35 | ||
36 | foreign import ccall unsafe "wrapper" | 36 | foreign import ccall safe "wrapper" |
37 | mkDoubleVecVecfun :: (Double -> TVV) -> IO (FunPtr (Double -> TVV)) | 37 | mkDoubleVecVecfun :: (Double -> TVV) -> IO (FunPtr (Double -> TVV)) |
38 | 38 | ||
39 | aux_vTov :: (Vector Double -> Vector Double) -> TVV | 39 | aux_vTov :: (Vector Double -> Vector Double) -> TVV |
@@ -46,10 +46,10 @@ aux_vTov f n p nr r = g where | |||
46 | g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral nr) | 46 | g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral nr) |
47 | return 0 | 47 | return 0 |
48 | 48 | ||
49 | foreign import ccall unsafe "wrapper" | 49 | foreign import ccall safe "wrapper" |
50 | mkVecMatfun :: TVM -> IO (FunPtr TVM) | 50 | mkVecMatfun :: TVM -> IO (FunPtr TVM) |
51 | 51 | ||
52 | foreign import ccall unsafe "wrapper" | 52 | foreign import ccall safe "wrapper" |
53 | mkDoubleVecMatfun :: (Double -> TVM) -> IO (FunPtr (Double -> TVM)) | 53 | mkDoubleVecMatfun :: (Double -> TVM) -> IO (FunPtr (Double -> TVM)) |
54 | 54 | ||
55 | aux_vTom :: (Vector Double -> Matrix Double) -> TVM | 55 | aux_vTom :: (Vector Double -> Matrix Double) -> TVM |
diff --git a/lib/Numeric/GSL/Minimization.hs b/lib/Numeric/GSL/Minimization.hs index 21ac8a1..af85135 100644 --- a/lib/Numeric/GSL/Minimization.hs +++ b/lib/Numeric/GSL/Minimization.hs | |||
@@ -122,7 +122,7 @@ minimizeV method eps maxit szv f xiv = unsafePerformIO $ do | |||
122 | return (sol, path) | 122 | return (sol, path) |
123 | 123 | ||
124 | 124 | ||
125 | foreign import ccall unsafe "gsl-aux.h minimize" | 125 | foreign import ccall safe "gsl-aux.h minimize" |
126 | c_minimize:: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TVVM | 126 | c_minimize:: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TVVM |
127 | 127 | ||
128 | ---------------------------------------------------------------------------------- | 128 | ---------------------------------------------------------------------------------- |
@@ -179,7 +179,7 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do | |||
179 | freeHaskellFunPtr dfp | 179 | freeHaskellFunPtr dfp |
180 | return (sol,path) | 180 | return (sol,path) |
181 | 181 | ||
182 | foreign import ccall unsafe "gsl-aux.h minimizeD" | 182 | foreign import ccall safe "gsl-aux.h minimizeD" |
183 | c_minimizeD :: CInt | 183 | c_minimizeD :: CInt |
184 | -> FunPtr (CInt -> Ptr Double -> Double) | 184 | -> FunPtr (CInt -> Ptr Double -> Double) |
185 | -> FunPtr TVV | 185 | -> FunPtr TVV |
diff --git a/lib/Numeric/GSL/ODE.hs b/lib/Numeric/GSL/ODE.hs index 797ba3f..4d2beed 100644 --- a/lib/Numeric/GSL/ODE.hs +++ b/lib/Numeric/GSL/ODE.hs | |||
@@ -91,7 +91,7 @@ odeSolveV method h epsAbs epsRel f mbjac xiv ts = unsafePerformIO $ do | |||
91 | freeHaskellFunPtr fp | 91 | freeHaskellFunPtr fp |
92 | return sol | 92 | return sol |
93 | 93 | ||
94 | foreign import ccall unsafe "ode" | 94 | foreign import ccall safe "ode" |
95 | ode_c :: CInt -> Double -> Double -> Double -> FunPtr (Double -> TVV) -> FunPtr (Double -> TVM) -> TVVM | 95 | ode_c :: CInt -> Double -> Double -> Double -> FunPtr (Double -> TVV) -> FunPtr (Double -> TVM) -> TVVM |
96 | 96 | ||
97 | ------------------------------------------------------- | 97 | ------------------------------------------------------- |
diff --git a/lib/Numeric/GSL/Root.hs b/lib/Numeric/GSL/Root.hs index 4128846..cd2982a 100644 --- a/lib/Numeric/GSL/Root.hs +++ b/lib/Numeric/GSL/Root.hs | |||
@@ -91,7 +91,7 @@ rootGen m f xi epsabs maxit = unsafePerformIO $ do | |||
91 | return (take n $ drop 1 sol, path) | 91 | return (take n $ drop 1 sol, path) |
92 | 92 | ||
93 | 93 | ||
94 | foreign import ccall unsafe "root" | 94 | foreign import ccall safe "root" |
95 | c_root:: CInt -> FunPtr TVV -> Double -> CInt -> TVM | 95 | c_root:: CInt -> FunPtr TVV -> Double -> CInt -> TVM |
96 | 96 | ||
97 | ------------------------------------------------------------------------- | 97 | ------------------------------------------------------------------------- |
@@ -130,7 +130,7 @@ rootJGen m f jac xi epsabs maxit = unsafePerformIO $ do | |||
130 | return (take n $ drop 1 sol, path) | 130 | return (take n $ drop 1 sol, path) |
131 | 131 | ||
132 | 132 | ||
133 | foreign import ccall unsafe "rootj" | 133 | foreign import ccall safe "rootj" |
134 | c_rootj:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> CInt -> TVM | 134 | c_rootj:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> CInt -> TVM |
135 | 135 | ||
136 | ------------------------------------------------------- | 136 | ------------------------------------------------------- |