diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-01-22 10:08:07 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-01-22 10:08:07 +0000 |
commit | 1bdc3af98f098f45e97e9c1a3225c5dcb64e3119 (patch) | |
tree | e6d2ad7bb2dae1be433a2facaa555305b7cc90b4 /lib/Numeric/GSL/Integration.hs | |
parent | 17749900a9146ddf6cd8ebf59dc35e56d6bff413 (diff) |
CInt in GSL args
Diffstat (limited to 'lib/Numeric/GSL/Integration.hs')
-rw-r--r-- | lib/Numeric/GSL/Integration.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Numeric/GSL/Integration.hs b/lib/Numeric/GSL/Integration.hs index b5f5930..7103ea4 100644 --- a/lib/Numeric/GSL/Integration.hs +++ b/lib/Numeric/GSL/Integration.hs | |||
@@ -22,9 +22,13 @@ module Numeric.GSL.Integration ( | |||
22 | 22 | ||
23 | import Foreign | 23 | import Foreign |
24 | import Foreign.C.Types(CInt) | 24 | import Foreign.C.Types(CInt) |
25 | import Data.Packed.Internal(mkfun,check,(//)) | 25 | import Data.Packed.Internal(check,(//)) |
26 | 26 | ||
27 | 27 | ||
28 | {- | conversion of Haskell functions into function pointers that can be used in the C side | ||
29 | -} | ||
30 | foreign import ccall "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) | ||
31 | |||
28 | -------------------------------------------------------------------- | 32 | -------------------------------------------------------------------- |
29 | {- | Numerical integration using /gsl_integration_qags/ (adaptive integration with singularities). For example: | 33 | {- | Numerical integration using /gsl_integration_qags/ (adaptive integration with singularities). For example: |
30 | 34 | ||
@@ -45,7 +49,7 @@ integrateQAGS prec n f a b = unsafePerformIO $ do | |||
45 | r <- malloc | 49 | r <- malloc |
46 | e <- malloc | 50 | e <- malloc |
47 | fp <- mkfun (\x _ -> f x) | 51 | fp <- mkfun (\x _ -> f x) |
48 | c_integrate_qags fp a b prec n r e // check "integrate_qags" | 52 | c_integrate_qags fp a b prec (fromIntegral n) r e // check "integrate_qags" |
49 | vr <- peek r | 53 | vr <- peek r |
50 | ve <- peek e | 54 | ve <- peek e |
51 | let result = (vr,ve) | 55 | let result = (vr,ve) |
@@ -55,7 +59,7 @@ integrateQAGS prec n f a b = unsafePerformIO $ do | |||
55 | return result | 59 | return result |
56 | 60 | ||
57 | foreign import ccall "gsl-aux.h integrate_qags" | 61 | foreign import ccall "gsl-aux.h integrate_qags" |
58 | c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> Int | 62 | c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt |
59 | -> Ptr Double -> Ptr Double -> IO CInt | 63 | -> Ptr Double -> Ptr Double -> IO CInt |
60 | 64 | ||
61 | ----------------------------------------------------------------- | 65 | ----------------------------------------------------------------- |
@@ -88,4 +92,3 @@ integrateQNG prec f a b = unsafePerformIO $ do | |||
88 | foreign import ccall "gsl-aux.h integrate_qng" | 92 | foreign import ccall "gsl-aux.h integrate_qng" |
89 | c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double | 93 | c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double |
90 | -> Ptr Double -> Ptr Double -> IO CInt | 94 | -> Ptr Double -> Ptr Double -> IO CInt |
91 | |||