summaryrefslogtreecommitdiff
path: root/lib/Numeric/GSL/Special/Internal.hsc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/GSL/Special/Internal.hsc')
-rw-r--r--lib/Numeric/GSL/Special/Internal.hsc102
1 files changed, 0 insertions, 102 deletions
diff --git a/lib/Numeric/GSL/Special/Internal.hsc b/lib/Numeric/GSL/Special/Internal.hsc
deleted file mode 100644
index 96c1f40..0000000
--- a/lib/Numeric/GSL/Special/Internal.hsc
+++ /dev/null
@@ -1,102 +0,0 @@
1 {-# LANGUAGE ForeignFunctionInterface #-}
2-----------------------------------------------------------------------------
3{- |
4Module : Numeric.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
18#include <gsl/gsl_sf_result.h>
19#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
20
21module Numeric.GSL.Special.Internal (
22 createSFR,
23 createSFR_E10,
24 Precision(..),
25 Gsl_mode_t,
26 Size_t,
27 precCode
28)
29where
30
31import Foreign
32import Data.Packed.Internal(check,(//))
33import Foreign.C.Types(CSize,CInt)
34
35
36data Precision = PrecDouble | PrecSingle | PrecApprox
37
38precCode :: Precision -> Int
39precCode PrecDouble = 0
40precCode PrecSingle = 1
41precCode PrecApprox = 2
42
43type Gsl_mode_t = Int
44
45type Size_t = CSize
46
47---------------------------------------------------
48
49data Gsl_sf_result = SF Double Double
50 deriving (Show)
51
52instance Storable Gsl_sf_result where
53 sizeOf _ = #size gsl_sf_result
54 alignment _ = #alignment gsl_sf_result
55 peek ptr = do
56 val <- (#peek gsl_sf_result, val) ptr
57 err <- (#peek gsl_sf_result, err) ptr
58 return (SF val err)
59 poke ptr (SF val err) = do
60 (#poke gsl_sf_result, val) ptr val
61 (#poke gsl_sf_result, err) ptr err
62
63
64data Gsl_sf_result_e10 = SFE Double Double CInt
65 deriving (Show)
66
67instance Storable Gsl_sf_result_e10 where
68 sizeOf _ = #size gsl_sf_result_e10
69 alignment _ = #alignment gsl_sf_result_e10
70 peek ptr = do
71 val <- (#peek gsl_sf_result_e10, val) ptr
72 err <- (#peek gsl_sf_result_e10, err) ptr
73 e10 <- (#peek gsl_sf_result_e10, e10) ptr
74 return (SFE val err e10)
75 poke ptr (SFE val err e10) = do
76 (#poke gsl_sf_result_e10, val) ptr val
77 (#poke gsl_sf_result_e10, err) ptr err
78 (#poke gsl_sf_result_e10, e10) ptr e10
79
80
81----------------------------------------------------------------
82-- | access to a sf_result
83createSFR :: String -> (Ptr a -> IO CInt) -> (Double, Double)
84createSFR s f = unsafePerformIO $ do
85 p <- malloc :: IO (Ptr Gsl_sf_result)
86 f (castPtr p) // check s
87 SF val err <- peek p
88 free p
89 return (val,err)
90
91
92---------------------------------------------------------------------
93-- the sf_result_e10 contains two doubles and the exponent
94
95-- | access to sf_result_e10
96createSFR_E10 :: String -> (Ptr a -> IO CInt) -> (Double, Int, Double)
97createSFR_E10 s f = unsafePerformIO $ do
98 p <- malloc :: IO (Ptr Gsl_sf_result_e10)
99 f (castPtr p) // check s
100 SFE val err expo <- peek p
101 free p
102 return (val, fromIntegral expo,err)