summaryrefslogtreecommitdiff
path: root/lib/GSL/Special/Internal.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-07-28 10:44:43 +0000
committerAlberto Ruiz <aruiz@um.es>2007-07-28 10:44:43 +0000
commit774924233c87a20c31a3232cbd01d9bf5170a951 (patch)
tree944efe08c6b0921b5b7e496f9e96e5ca4389e5fb /lib/GSL/Special/Internal.hs
parent34b094b7589bf400114d802549fcba3ce1481683 (diff)
a few automatic wrappers
Diffstat (limited to 'lib/GSL/Special/Internal.hs')
-rw-r--r--lib/GSL/Special/Internal.hs65
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/GSL/Special/Internal.hs b/lib/GSL/Special/Internal.hs
new file mode 100644
index 0000000..c7455d9
--- /dev/null
+++ b/lib/GSL/Special/Internal.hs
@@ -0,0 +1,65 @@
1{-# OPTIONS #-}
2-----------------------------------------------------------------------------
3{- |
4Module : GSL.Special.Internal
5Copyright : (c) Alberto Ruiz 2007
6License : GPL-style
7
8Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional
10Portability : uses ffi
11
12Support for Special functions.
13
14<http://www.gnu.org/software/gsl/manual/html_node/Special-Functions.html#Special-Functions>
15-}
16-----------------------------------------------------------------------------
17
18module GSL.Special.Internal (
19 createSFR,
20 createSFR_E10,
21 Precision(..),
22 Gsl_mode_t,
23 precCode
24)
25where
26
27import Foreign
28import Data.Packed.Internal.Common(check,(//))
29
30
31data Precision = PrecDouble | PrecSingle | PrecApprox
32
33precCode :: Precision -> Int
34precCode PrecDouble = 0
35precCode PrecSingle = 1
36precCode PrecApprox = 2
37
38type Gsl_mode_t = Int
39
40----------------------------------------------------------------
41-- | access to a sf_result
42createSFR :: Storable a => t -> (Ptr a -> IO Int) -> (a, a)
43createSFR s f = unsafePerformIO $ do
44 p <- mallocArray 2
45 f p // check "createSFR" []
46 [val,err] <- peekArray 2 p
47 free p
48 return (val,err)
49
50
51---------------------------------------------------------------------
52-- the sf_result_e10 contains two doubles and the exponent
53
54-- | acces to sf_result_e10
55createSFR_E10 :: (Storable t2, Storable t3, Storable t1) => t -> (Ptr a -> IO Int) -> (t1, t2, t3)
56createSFR_E10 s f = unsafePerformIO $ do
57 let sd = sizeOf (0::Double)
58 let si = sizeOf (0::Int)
59 p <- mallocBytes (2*sd + si)
60 f p // check "createSFR_E10" []
61 val <- peekByteOff p 0
62 err <- peekByteOff p sd
63 expo <- peekByteOff p (2*sd)
64 free p
65 return (val,expo,err)