summaryrefslogtreecommitdiff
path: root/lib/Numeric/GSL/Integration.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/GSL/Integration.hs')
-rw-r--r--lib/Numeric/GSL/Integration.hs11
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
23import Foreign 23import Foreign
24import Foreign.C.Types(CInt) 24import Foreign.C.Types(CInt)
25import Data.Packed.Internal(mkfun,check,(//)) 25import 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-}
30foreign 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
57foreign import ccall "gsl-aux.h integrate_qags" 61foreign 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
88foreign import ccall "gsl-aux.h integrate_qng" 92foreign 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