summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/GSL/Special.hs48
-rw-r--r--lib/GSL/Special/Airy.hs166
-rw-r--r--lib/GSL/Special/Erf.hs93
-rw-r--r--lib/GSL/Special/Gamma.hs277
-rw-r--r--lib/GSL/Special/Internal.hs65
-rw-r--r--lib/GSL/Special/airy.h24
-rw-r--r--lib/GSL/Special/auto.hs201
-rw-r--r--lib/GSL/Special/erf.h12
-rw-r--r--lib/GSL/Special/gamma.h43
-rw-r--r--lib/HSSL.hs17
10 files changed, 890 insertions, 56 deletions
diff --git a/lib/GSL/Special.hs b/lib/GSL/Special.hs
index fec96eb..01aec2b 100644
--- a/lib/GSL/Special.hs
+++ b/lib/GSL/Special.hs
@@ -9,25 +9,27 @@ Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional 9Stability : provisional
10Portability : uses ffi 10Portability : uses ffi
11 11
12Special functions. 12Wrappers for a few special functions.
13 13
14<http://www.gnu.org/software/gsl/manual/html_node/Special-Functions.html#Special-Functions> 14<http://www.gnu.org/software/gsl/manual/html_node/Special-Functions.html#Special-Functions>
15-} 15-}
16----------------------------------------------------------------------------- 16-----------------------------------------------------------------------------
17 17
18module GSL.Special ( 18module GSL.Special (
19 erf, 19 module GSL.Special.Airy,
20 erf_Z, 20 module GSL.Special.Erf,
21 module GSL.Special.Gamma,
21 bessel_J0_e, 22 bessel_J0_e,
22 exp_e10_e, 23 exp_e10_e
23 gamma
24) 24)
25where 25where
26 26
27import Foreign 27import Foreign
28import Data.Packed.Internal.Common(check,(//)) 28import GSL.Special.Internal
29import GSL.Special.Gamma
30import GSL.Special.Erf
31import GSL.Special.Airy
29 32
30----------------------------------------------------------------
31-------------------- simple functions -------------------------- 33-------------------- simple functions --------------------------
32 34
33{- | The error function (/gsl_sf_erf/), defined as 2\/ \\sqrt \\pi * \int\_0\^t \\exp -t\^2 dt. 35{- | The error function (/gsl_sf_erf/), defined as 2\/ \\sqrt \\pi * \int\_0\^t \\exp -t\^2 dt.
@@ -46,24 +48,6 @@ foreign import ccall "gsl-aux.h gsl_sf_erf" erf :: Double -> Double
46-} 48-}
47foreign import ccall "gsl-aux.h gsl_sf_erf_Z" erf_Z :: Double -> Double 49foreign import ccall "gsl-aux.h gsl_sf_erf_Z" erf_Z :: Double -> Double
48 50
49{- | The gamma function (/gsl_sf_gamma/), described in <http://www.gnu.org/software/gsl/manual/html_node/Gamma-Functions.html>
50
51>> gamma 5
52>24.0
53
54-}
55foreign import ccall "gsl-aux.h gsl_sf_gamma" gamma :: Double -> Double
56
57----------------------------------------------------------------
58-- the sf_result struct is equivalent to an array of two doubles
59
60createSFR s f = unsafePerformIO $ do
61 p <- mallocArray 2
62 f p // check "createSFR" []
63 [val,err] <- peekArray 2 p
64 free p
65 return (val,err)
66
67-------------------- functions returning sf_result ------------- 51-------------------- functions returning sf_result -------------
68 52
69{- | The regular cylindrical Bessel function of zeroth order, J_0(x). This is 53{- | The regular cylindrical Bessel function of zeroth order, J_0(x). This is
@@ -78,20 +62,6 @@ bessel_J0_e :: Double -> (Double,Double)
78bessel_J0_e x = createSFR "bessel_J0_e" (gsl_sf_bessel_J0_e x) 62bessel_J0_e x = createSFR "bessel_J0_e" (gsl_sf_bessel_J0_e x)
79foreign import ccall "gsl-aux.h gsl_sf_bessel_J0_e" gsl_sf_bessel_J0_e :: Double -> Ptr Double -> IO Int 63foreign import ccall "gsl-aux.h gsl_sf_bessel_J0_e" gsl_sf_bessel_J0_e :: Double -> Ptr Double -> IO Int
80 64
81---------------------------------------------------------------------
82-- the sf_result_e10 contains two doubles and the exponent
83
84createSFR_E10 s f = unsafePerformIO $ do
85 let sd = sizeOf (0::Double)
86 let si = sizeOf (0::Int)
87 p <- mallocBytes (2*sd + si)
88 f p // check "createSFR_E10" []
89 val <- peekByteOff p 0
90 err <- peekByteOff p sd
91 expo <- peekByteOff p (2*sd)
92 free p
93 return (val,expo,err)
94
95-------------------- functions returning sf_result_e10 ------------- 65-------------------- functions returning sf_result_e10 -------------
96 66
97{- | (From the GSL manual) \"This function computes the exponential \exp(x) using the @gsl_sf_result_e10@ type to return a result with extended range. This function may be useful if the value of \exp(x) would overflow the numeric range of double\". 67{- | (From the GSL manual) \"This function computes the exponential \exp(x) using the @gsl_sf_result_e10@ type to return a result with extended range. This function may be useful if the value of \exp(x) would overflow the numeric range of double\".
diff --git a/lib/GSL/Special/Airy.hs b/lib/GSL/Special/Airy.hs
new file mode 100644
index 0000000..872f7c5
--- /dev/null
+++ b/lib/GSL/Special/Airy.hs
@@ -0,0 +1,166 @@
1------------------------------------------------------------
2{- |
3Module : GSL.Special.Airy
4Copyright : (c) Alberto Ruiz 2006
5License : GPL-style
6Maintainer : Alberto Ruiz (aruiz at um dot es)
7Stability : provisional
8Portability : uses ffi
9
10Wrappers for selected functions described at:
11
12<http://www.gnu.org/software/gsl/manual/html_node/Airy-Functions-and-Derivatives.html>
13
14-}
15------------------------------------------------------------
16
17module GSL.Special.Airy(
18 Precision (..)
19, airy_Ai_e
20, airy_Ai
21, airy_Bi_e
22, airy_Bi
23, airy_Ai_scaled_e
24, airy_Ai_scaled
25, airy_Bi_scaled_e
26, airy_Bi_scaled
27, airy_Ai_deriv_e
28, airy_Ai_deriv
29, airy_Bi_deriv_e
30, airy_Bi_deriv
31, airy_Ai_deriv_scaled_e
32, airy_Ai_deriv_scaled
33, airy_Bi_deriv_scaled_e
34, airy_Bi_deriv_scaled
35, airy_zero_Ai_e
36, airy_zero_Ai
37, airy_zero_Bi_e
38, airy_zero_Bi
39, airy_zero_Ai_deriv_e
40, airy_zero_Ai_deriv
41, airy_zero_Bi_deriv_e
42, airy_zero_Bi_deriv
43) where
44
45import Foreign(Ptr)
46import GSL.Special.Internal
47
48-- | wrapper for int gsl_sf_airy_Ai_e(double x,gsl_mode_t mode,gsl_sf_result* result);
49airy_Ai_e :: Double -> Precision -> (Double,Double)
50airy_Ai_e x mode = createSFR "airy_Ai_e" $ gsl_sf_airy_Ai_e x (precCode mode)
51foreign import ccall "airy.h gsl_sf_airy_Ai_e" gsl_sf_airy_Ai_e :: Double -> Gsl_mode_t -> Ptr Double -> IO(Int)
52
53-- | wrapper for double gsl_sf_airy_Ai(double x,gsl_mode_t mode);
54airy_Ai :: Double -> Precision -> Double
55airy_Ai x mode = gsl_sf_airy_Ai x (precCode mode)
56foreign import ccall "airy.h gsl_sf_airy_Ai" gsl_sf_airy_Ai :: Double -> Gsl_mode_t -> Double
57
58-- | wrapper for int gsl_sf_airy_Bi_e(double x,gsl_mode_t mode,gsl_sf_result* result);
59airy_Bi_e :: Double -> Precision -> (Double,Double)
60airy_Bi_e x mode = createSFR "airy_Bi_e" $ gsl_sf_airy_Bi_e x (precCode mode)
61foreign import ccall "airy.h gsl_sf_airy_Bi_e" gsl_sf_airy_Bi_e :: Double -> Gsl_mode_t -> Ptr Double -> IO(Int)
62
63-- | wrapper for double gsl_sf_airy_Bi(double x,gsl_mode_t mode);
64airy_Bi :: Double -> Precision -> Double
65airy_Bi x mode = gsl_sf_airy_Bi x (precCode mode)
66foreign import ccall "airy.h gsl_sf_airy_Bi" gsl_sf_airy_Bi :: Double -> Gsl_mode_t -> Double
67
68-- | wrapper for int gsl_sf_airy_Ai_scaled_e(double x,gsl_mode_t mode,gsl_sf_result* result);
69airy_Ai_scaled_e :: Double -> Precision -> (Double,Double)
70airy_Ai_scaled_e x mode = createSFR "airy_Ai_scaled_e" $ gsl_sf_airy_Ai_scaled_e x (precCode mode)
71foreign import ccall "airy.h gsl_sf_airy_Ai_scaled_e" gsl_sf_airy_Ai_scaled_e :: Double -> Gsl_mode_t -> Ptr Double -> IO(Int)
72
73-- | wrapper for double gsl_sf_airy_Ai_scaled(double x,gsl_mode_t mode);
74airy_Ai_scaled :: Double -> Precision -> Double
75airy_Ai_scaled x mode = gsl_sf_airy_Ai_scaled x (precCode mode)
76foreign import ccall "airy.h gsl_sf_airy_Ai_scaled" gsl_sf_airy_Ai_scaled :: Double -> Gsl_mode_t -> Double
77
78-- | wrapper for int gsl_sf_airy_Bi_scaled_e(double x,gsl_mode_t mode,gsl_sf_result* result);
79airy_Bi_scaled_e :: Double -> Precision -> (Double,Double)
80airy_Bi_scaled_e x mode = createSFR "airy_Bi_scaled_e" $ gsl_sf_airy_Bi_scaled_e x (precCode mode)
81foreign import ccall "airy.h gsl_sf_airy_Bi_scaled_e" gsl_sf_airy_Bi_scaled_e :: Double -> Gsl_mode_t -> Ptr Double -> IO(Int)
82
83-- | wrapper for double gsl_sf_airy_Bi_scaled(double x,gsl_mode_t mode);
84airy_Bi_scaled :: Double -> Precision -> Double
85airy_Bi_scaled x mode = gsl_sf_airy_Bi_scaled x (precCode mode)
86foreign import ccall "airy.h gsl_sf_airy_Bi_scaled" gsl_sf_airy_Bi_scaled :: Double -> Gsl_mode_t -> Double
87
88-- | wrapper for int gsl_sf_airy_Ai_deriv_e(double x,gsl_mode_t mode,gsl_sf_result* result);
89airy_Ai_deriv_e :: Double -> Precision -> (Double,Double)
90airy_Ai_deriv_e x mode = createSFR "airy_Ai_deriv_e" $ gsl_sf_airy_Ai_deriv_e x (precCode mode)
91foreign import ccall "airy.h gsl_sf_airy_Ai_deriv_e" gsl_sf_airy_Ai_deriv_e :: Double -> Gsl_mode_t -> Ptr Double -> IO(Int)
92
93-- | wrapper for double gsl_sf_airy_Ai_deriv(double x,gsl_mode_t mode);
94airy_Ai_deriv :: Double -> Precision -> Double
95airy_Ai_deriv x mode = gsl_sf_airy_Ai_deriv x (precCode mode)
96foreign import ccall "airy.h gsl_sf_airy_Ai_deriv" gsl_sf_airy_Ai_deriv :: Double -> Gsl_mode_t -> Double
97
98-- | wrapper for int gsl_sf_airy_Bi_deriv_e(double x,gsl_mode_t mode,gsl_sf_result* result);
99airy_Bi_deriv_e :: Double -> Precision -> (Double,Double)
100airy_Bi_deriv_e x mode = createSFR "airy_Bi_deriv_e" $ gsl_sf_airy_Bi_deriv_e x (precCode mode)
101foreign import ccall "airy.h gsl_sf_airy_Bi_deriv_e" gsl_sf_airy_Bi_deriv_e :: Double -> Gsl_mode_t -> Ptr Double -> IO(Int)
102
103-- | wrapper for double gsl_sf_airy_Bi_deriv(double x,gsl_mode_t mode);
104airy_Bi_deriv :: Double -> Precision -> Double
105airy_Bi_deriv x mode = gsl_sf_airy_Bi_deriv x (precCode mode)
106foreign import ccall "airy.h gsl_sf_airy_Bi_deriv" gsl_sf_airy_Bi_deriv :: Double -> Gsl_mode_t -> Double
107
108-- | wrapper for int gsl_sf_airy_Ai_deriv_scaled_e(double x,gsl_mode_t mode,gsl_sf_result* result);
109airy_Ai_deriv_scaled_e :: Double -> Precision -> (Double,Double)
110airy_Ai_deriv_scaled_e x mode = createSFR "airy_Ai_deriv_scaled_e" $ gsl_sf_airy_Ai_deriv_scaled_e x (precCode mode)
111foreign import ccall "airy.h gsl_sf_airy_Ai_deriv_scaled_e" gsl_sf_airy_Ai_deriv_scaled_e :: Double -> Gsl_mode_t -> Ptr Double -> IO(Int)
112
113-- | wrapper for double gsl_sf_airy_Ai_deriv_scaled(double x,gsl_mode_t mode);
114airy_Ai_deriv_scaled :: Double -> Precision -> Double
115airy_Ai_deriv_scaled x mode = gsl_sf_airy_Ai_deriv_scaled x (precCode mode)
116foreign import ccall "airy.h gsl_sf_airy_Ai_deriv_scaled" gsl_sf_airy_Ai_deriv_scaled :: Double -> Gsl_mode_t -> Double
117
118-- | wrapper for int gsl_sf_airy_Bi_deriv_scaled_e(double x,gsl_mode_t mode,gsl_sf_result* result);
119airy_Bi_deriv_scaled_e :: Double -> Precision -> (Double,Double)
120airy_Bi_deriv_scaled_e x mode = createSFR "airy_Bi_deriv_scaled_e" $ gsl_sf_airy_Bi_deriv_scaled_e x (precCode mode)
121foreign import ccall "airy.h gsl_sf_airy_Bi_deriv_scaled_e" gsl_sf_airy_Bi_deriv_scaled_e :: Double -> Gsl_mode_t -> Ptr Double -> IO(Int)
122
123-- | wrapper for double gsl_sf_airy_Bi_deriv_scaled(double x,gsl_mode_t mode);
124airy_Bi_deriv_scaled :: Double -> Precision -> Double
125airy_Bi_deriv_scaled x mode = gsl_sf_airy_Bi_deriv_scaled x (precCode mode)
126foreign import ccall "airy.h gsl_sf_airy_Bi_deriv_scaled" gsl_sf_airy_Bi_deriv_scaled :: Double -> Gsl_mode_t -> Double
127
128-- | wrapper for int gsl_sf_airy_zero_Ai_e(int s,gsl_sf_result* result);
129airy_zero_Ai_e :: Int -> (Double,Double)
130airy_zero_Ai_e s = createSFR "airy_zero_Ai_e" $ gsl_sf_airy_zero_Ai_e s
131foreign import ccall "airy.h gsl_sf_airy_zero_Ai_e" gsl_sf_airy_zero_Ai_e :: Int -> Ptr Double -> IO(Int)
132
133-- | wrapper for double gsl_sf_airy_zero_Ai(int s);
134airy_zero_Ai :: Int -> Double
135airy_zero_Ai = gsl_sf_airy_zero_Ai
136foreign import ccall "airy.h gsl_sf_airy_zero_Ai" gsl_sf_airy_zero_Ai :: Int -> Double
137
138-- | wrapper for int gsl_sf_airy_zero_Bi_e(int s,gsl_sf_result* result);
139airy_zero_Bi_e :: Int -> (Double,Double)
140airy_zero_Bi_e s = createSFR "airy_zero_Bi_e" $ gsl_sf_airy_zero_Bi_e s
141foreign import ccall "airy.h gsl_sf_airy_zero_Bi_e" gsl_sf_airy_zero_Bi_e :: Int -> Ptr Double -> IO(Int)
142
143-- | wrapper for double gsl_sf_airy_zero_Bi(int s);
144airy_zero_Bi :: Int -> Double
145airy_zero_Bi = gsl_sf_airy_zero_Bi
146foreign import ccall "airy.h gsl_sf_airy_zero_Bi" gsl_sf_airy_zero_Bi :: Int -> Double
147
148-- | wrapper for int gsl_sf_airy_zero_Ai_deriv_e(int s,gsl_sf_result* result);
149airy_zero_Ai_deriv_e :: Int -> (Double,Double)
150airy_zero_Ai_deriv_e s = createSFR "airy_zero_Ai_deriv_e" $ gsl_sf_airy_zero_Ai_deriv_e s
151foreign import ccall "airy.h gsl_sf_airy_zero_Ai_deriv_e" gsl_sf_airy_zero_Ai_deriv_e :: Int -> Ptr Double -> IO(Int)
152
153-- | wrapper for double gsl_sf_airy_zero_Ai_deriv(int s);
154airy_zero_Ai_deriv :: Int -> Double
155airy_zero_Ai_deriv = gsl_sf_airy_zero_Ai_deriv
156foreign import ccall "airy.h gsl_sf_airy_zero_Ai_deriv" gsl_sf_airy_zero_Ai_deriv :: Int -> Double
157
158-- | wrapper for int gsl_sf_airy_zero_Bi_deriv_e(int s,gsl_sf_result* result);
159airy_zero_Bi_deriv_e :: Int -> (Double,Double)
160airy_zero_Bi_deriv_e s = createSFR "airy_zero_Bi_deriv_e" $ gsl_sf_airy_zero_Bi_deriv_e s
161foreign import ccall "airy.h gsl_sf_airy_zero_Bi_deriv_e" gsl_sf_airy_zero_Bi_deriv_e :: Int -> Ptr Double -> IO(Int)
162
163-- | wrapper for double gsl_sf_airy_zero_Bi_deriv(int s);
164airy_zero_Bi_deriv :: Int -> Double
165airy_zero_Bi_deriv = gsl_sf_airy_zero_Bi_deriv
166foreign import ccall "airy.h gsl_sf_airy_zero_Bi_deriv" gsl_sf_airy_zero_Bi_deriv :: Int -> Double
diff --git a/lib/GSL/Special/Erf.hs b/lib/GSL/Special/Erf.hs
new file mode 100644
index 0000000..30b7817
--- /dev/null
+++ b/lib/GSL/Special/Erf.hs
@@ -0,0 +1,93 @@
1------------------------------------------------------------
2{- |
3Module : GSL.Special.Erf
4Copyright : (c) Alberto Ruiz 2006
5License : GPL-style
6Maintainer : Alberto Ruiz (aruiz at um dot es)
7Stability : provisional
8Portability : uses ffi
9
10Wrappers for selected functions described at:
11
12<http://www.gnu.org/software/gsl/manual/html_node/Error-Functions.html>
13
14-}
15------------------------------------------------------------
16
17module GSL.Special.Erf(
18 erfc_e
19, erfc
20, log_erfc_e
21, log_erfc
22, erf_e
23, erf
24, erf_Z_e
25, erf_Q_e
26, erf_Z
27, erf_Q
28, hazard_e
29, hazard
30) where
31
32import Foreign(Ptr)
33import GSL.Special.Internal
34
35-- | wrapper for int gsl_sf_erfc_e(double x,gsl_sf_result* result);
36erfc_e :: Double -> (Double,Double)
37erfc_e x = createSFR "erfc_e" $ gsl_sf_erfc_e x
38foreign import ccall "erf.h gsl_sf_erfc_e" gsl_sf_erfc_e :: Double -> Ptr Double -> IO(Int)
39
40-- | wrapper for double gsl_sf_erfc(double x);
41erfc :: Double -> Double
42erfc = gsl_sf_erfc
43foreign import ccall "erf.h gsl_sf_erfc" gsl_sf_erfc :: Double -> Double
44
45-- | wrapper for int gsl_sf_log_erfc_e(double x,gsl_sf_result* result);
46log_erfc_e :: Double -> (Double,Double)
47log_erfc_e x = createSFR "log_erfc_e" $ gsl_sf_log_erfc_e x
48foreign import ccall "erf.h gsl_sf_log_erfc_e" gsl_sf_log_erfc_e :: Double -> Ptr Double -> IO(Int)
49
50-- | wrapper for double gsl_sf_log_erfc(double x);
51log_erfc :: Double -> Double
52log_erfc = gsl_sf_log_erfc
53foreign import ccall "erf.h gsl_sf_log_erfc" gsl_sf_log_erfc :: Double -> Double
54
55-- | wrapper for int gsl_sf_erf_e(double x,gsl_sf_result* result);
56erf_e :: Double -> (Double,Double)
57erf_e x = createSFR "erf_e" $ gsl_sf_erf_e x
58foreign import ccall "erf.h gsl_sf_erf_e" gsl_sf_erf_e :: Double -> Ptr Double -> IO(Int)
59
60-- | wrapper for double gsl_sf_erf(double x);
61erf :: Double -> Double
62erf = gsl_sf_erf
63foreign import ccall "erf.h gsl_sf_erf" gsl_sf_erf :: Double -> Double
64
65-- | wrapper for int gsl_sf_erf_Z_e(double x,gsl_sf_result* result);
66erf_Z_e :: Double -> (Double,Double)
67erf_Z_e x = createSFR "erf_Z_e" $ gsl_sf_erf_Z_e x
68foreign import ccall "erf.h gsl_sf_erf_Z_e" gsl_sf_erf_Z_e :: Double -> Ptr Double -> IO(Int)
69
70-- | wrapper for int gsl_sf_erf_Q_e(double x,gsl_sf_result* result);
71erf_Q_e :: Double -> (Double,Double)
72erf_Q_e x = createSFR "erf_Q_e" $ gsl_sf_erf_Q_e x
73foreign import ccall "erf.h gsl_sf_erf_Q_e" gsl_sf_erf_Q_e :: Double -> Ptr Double -> IO(Int)
74
75-- | wrapper for double gsl_sf_erf_Z(double x);
76erf_Z :: Double -> Double
77erf_Z = gsl_sf_erf_Z
78foreign import ccall "erf.h gsl_sf_erf_Z" gsl_sf_erf_Z :: Double -> Double
79
80-- | wrapper for double gsl_sf_erf_Q(double x);
81erf_Q :: Double -> Double
82erf_Q = gsl_sf_erf_Q
83foreign import ccall "erf.h gsl_sf_erf_Q" gsl_sf_erf_Q :: Double -> Double
84
85-- | wrapper for int gsl_sf_hazard_e(double x,gsl_sf_result* result);
86hazard_e :: Double -> (Double,Double)
87hazard_e x = createSFR "hazard_e" $ gsl_sf_hazard_e x
88foreign import ccall "erf.h gsl_sf_hazard_e" gsl_sf_hazard_e :: Double -> Ptr Double -> IO(Int)
89
90-- | wrapper for double gsl_sf_hazard(double x);
91hazard :: Double -> Double
92hazard = gsl_sf_hazard
93foreign import ccall "erf.h gsl_sf_hazard" gsl_sf_hazard :: Double -> Double
diff --git a/lib/GSL/Special/Gamma.hs b/lib/GSL/Special/Gamma.hs
new file mode 100644
index 0000000..4586cb5
--- /dev/null
+++ b/lib/GSL/Special/Gamma.hs
@@ -0,0 +1,277 @@
1------------------------------------------------------------
2{- |
3Module : GSL.Special.Gamma
4Copyright : (c) Alberto Ruiz 2006
5License : GPL-style
6Maintainer : Alberto Ruiz (aruiz at um dot es)
7Stability : provisional
8Portability : uses ffi
9
10Wrappers for selected functions described at:
11
12<http://www.gnu.org/software/gsl/manual/html_node/Gamma-and-Beta-Functions.html>
13
14
15-}
16------------------------------------------------------------
17
18module GSL.Special.Gamma(
19 lngamma_e
20, lngamma
21, gamma_e
22, gamma
23, gammastar_e
24, gammastar
25, gammainv_e
26, gammainv
27, taylorcoeff_e
28, taylorcoeff
29, fact_e
30, fact
31, doublefact_e
32, doublefact
33, lnfact_e
34, lnfact
35, lndoublefact_e
36, lndoublefact
37, lnchoose_e
38, lnchoose
39, choose_e
40, choose
41, lnpoch_e
42, lnpoch
43, poch_e
44, poch
45, pochrel_e
46, pochrel
47, gamma_inc_Q_e
48, gamma_inc_Q
49, gamma_inc_P_e
50, gamma_inc_P
51, gamma_inc_e
52, gamma_inc
53, lnbeta_e
54, lnbeta
55, beta_e
56, beta
57, beta_inc_e
58, beta_inc
59) where
60
61import Foreign(Ptr)
62import GSL.Special.Internal
63
64-- | wrapper for int gsl_sf_lngamma_e(double x,gsl_sf_result* result);
65lngamma_e :: Double -> (Double,Double)
66lngamma_e x = createSFR "lngamma_e" $ gsl_sf_lngamma_e x
67foreign import ccall "gamma.h gsl_sf_lngamma_e" gsl_sf_lngamma_e :: Double -> Ptr Double -> IO(Int)
68
69-- | wrapper for double gsl_sf_lngamma(double x);
70lngamma :: Double -> Double
71lngamma = gsl_sf_lngamma
72foreign import ccall "gamma.h gsl_sf_lngamma" gsl_sf_lngamma :: Double -> Double
73
74-- | wrapper for int gsl_sf_lngamma_sgn_e(double x,gsl_sf_result* result_lg,double* sgn);
75lngamma_sgn_e :: Double -> Ptr Double -> Ptr Double -> Int
76lngamma_sgn_e = gsl_sf_lngamma_sgn_e
77foreign import ccall "gamma.h gsl_sf_lngamma_sgn_e" gsl_sf_lngamma_sgn_e :: Double -> Ptr Double -> Ptr Double -> Int
78
79-- | wrapper for int gsl_sf_gamma_e(double x,gsl_sf_result* result);
80gamma_e :: Double -> (Double,Double)
81gamma_e x = createSFR "gamma_e" $ gsl_sf_gamma_e x
82foreign import ccall "gamma.h gsl_sf_gamma_e" gsl_sf_gamma_e :: Double -> Ptr Double -> IO(Int)
83
84-- | wrapper for double gsl_sf_gamma(double x);
85gamma :: Double -> Double
86gamma = gsl_sf_gamma
87foreign import ccall "gamma.h gsl_sf_gamma" gsl_sf_gamma :: Double -> Double
88
89-- | wrapper for int gsl_sf_gammastar_e(double x,gsl_sf_result* result);
90gammastar_e :: Double -> (Double,Double)
91gammastar_e x = createSFR "gammastar_e" $ gsl_sf_gammastar_e x
92foreign import ccall "gamma.h gsl_sf_gammastar_e" gsl_sf_gammastar_e :: Double -> Ptr Double -> IO(Int)
93
94-- | wrapper for double gsl_sf_gammastar(double x);
95gammastar :: Double -> Double
96gammastar = gsl_sf_gammastar
97foreign import ccall "gamma.h gsl_sf_gammastar" gsl_sf_gammastar :: Double -> Double
98
99-- | wrapper for int gsl_sf_gammainv_e(double x,gsl_sf_result* result);
100gammainv_e :: Double -> (Double,Double)
101gammainv_e x = createSFR "gammainv_e" $ gsl_sf_gammainv_e x
102foreign import ccall "gamma.h gsl_sf_gammainv_e" gsl_sf_gammainv_e :: Double -> Ptr Double -> IO(Int)
103
104-- | wrapper for double gsl_sf_gammainv(double x);
105gammainv :: Double -> Double
106gammainv = gsl_sf_gammainv
107foreign import ccall "gamma.h gsl_sf_gammainv" gsl_sf_gammainv :: Double -> Double
108
109-- | wrapper for int gsl_sf_lngamma_complex_e(double zr,double zi,gsl_sf_result* lnr,gsl_sf_result* arg);
110lngamma_complex_e :: Double -> Double -> Ptr Double -> (Double,Double)
111lngamma_complex_e zr zi lnr = createSFR "lngamma_complex_e" $ gsl_sf_lngamma_complex_e zr zi lnr
112foreign import ccall "gamma.h gsl_sf_lngamma_complex_e" gsl_sf_lngamma_complex_e :: Double -> Double -> Ptr Double -> Ptr Double -> IO(Int)
113
114-- | wrapper for int gsl_sf_taylorcoeff_e(int n,double x,gsl_sf_result* result);
115taylorcoeff_e :: Int -> Double -> (Double,Double)
116taylorcoeff_e n x = createSFR "taylorcoeff_e" $ gsl_sf_taylorcoeff_e n x
117foreign import ccall "gamma.h gsl_sf_taylorcoeff_e" gsl_sf_taylorcoeff_e :: Int -> Double -> Ptr Double -> IO(Int)
118
119-- | wrapper for double gsl_sf_taylorcoeff(int n,double x);
120taylorcoeff :: Int -> Double -> Double
121taylorcoeff = gsl_sf_taylorcoeff
122foreign import ccall "gamma.h gsl_sf_taylorcoeff" gsl_sf_taylorcoeff :: Int -> Double -> Double
123
124-- | wrapper for int gsl_sf_fact_e(int n,gsl_sf_result* result);
125fact_e :: Int -> (Double,Double)
126fact_e n = createSFR "fact_e" $ gsl_sf_fact_e n
127foreign import ccall "gamma.h gsl_sf_fact_e" gsl_sf_fact_e :: Int -> Ptr Double -> IO(Int)
128
129-- | wrapper for double gsl_sf_fact(int n);
130fact :: Int -> Double
131fact = gsl_sf_fact
132foreign import ccall "gamma.h gsl_sf_fact" gsl_sf_fact :: Int -> Double
133
134-- | wrapper for int gsl_sf_doublefact_e(int n,gsl_sf_result* result);
135doublefact_e :: Int -> (Double,Double)
136doublefact_e n = createSFR "doublefact_e" $ gsl_sf_doublefact_e n
137foreign import ccall "gamma.h gsl_sf_doublefact_e" gsl_sf_doublefact_e :: Int -> Ptr Double -> IO(Int)
138
139-- | wrapper for double gsl_sf_doublefact(int n);
140doublefact :: Int -> Double
141doublefact = gsl_sf_doublefact
142foreign import ccall "gamma.h gsl_sf_doublefact" gsl_sf_doublefact :: Int -> Double
143
144-- | wrapper for int gsl_sf_lnfact_e(int n,gsl_sf_result* result);
145lnfact_e :: Int -> (Double,Double)
146lnfact_e n = createSFR "lnfact_e" $ gsl_sf_lnfact_e n
147foreign import ccall "gamma.h gsl_sf_lnfact_e" gsl_sf_lnfact_e :: Int -> Ptr Double -> IO(Int)
148
149-- | wrapper for double gsl_sf_lnfact(int n);
150lnfact :: Int -> Double
151lnfact = gsl_sf_lnfact
152foreign import ccall "gamma.h gsl_sf_lnfact" gsl_sf_lnfact :: Int -> Double
153
154-- | wrapper for int gsl_sf_lndoublefact_e(int n,gsl_sf_result* result);
155lndoublefact_e :: Int -> (Double,Double)
156lndoublefact_e n = createSFR "lndoublefact_e" $ gsl_sf_lndoublefact_e n
157foreign import ccall "gamma.h gsl_sf_lndoublefact_e" gsl_sf_lndoublefact_e :: Int -> Ptr Double -> IO(Int)
158
159-- | wrapper for double gsl_sf_lndoublefact(int n);
160lndoublefact :: Int -> Double
161lndoublefact = gsl_sf_lndoublefact
162foreign import ccall "gamma.h gsl_sf_lndoublefact" gsl_sf_lndoublefact :: Int -> Double
163
164-- | wrapper for int gsl_sf_lnchoose_e(int n,int m,gsl_sf_result* result);
165lnchoose_e :: Int -> Int -> (Double,Double)
166lnchoose_e n m = createSFR "lnchoose_e" $ gsl_sf_lnchoose_e n m
167foreign import ccall "gamma.h gsl_sf_lnchoose_e" gsl_sf_lnchoose_e :: Int -> Int -> Ptr Double -> IO(Int)
168
169-- | wrapper for double gsl_sf_lnchoose(int n,int m);
170lnchoose :: Int -> Int -> Double
171lnchoose = gsl_sf_lnchoose
172foreign import ccall "gamma.h gsl_sf_lnchoose" gsl_sf_lnchoose :: Int -> Int -> Double
173
174-- | wrapper for int gsl_sf_choose_e(int n,int m,gsl_sf_result* result);
175choose_e :: Int -> Int -> (Double,Double)
176choose_e n m = createSFR "choose_e" $ gsl_sf_choose_e n m
177foreign import ccall "gamma.h gsl_sf_choose_e" gsl_sf_choose_e :: Int -> Int -> Ptr Double -> IO(Int)
178
179-- | wrapper for double gsl_sf_choose(int n,int m);
180choose :: Int -> Int -> Double
181choose = gsl_sf_choose
182foreign import ccall "gamma.h gsl_sf_choose" gsl_sf_choose :: Int -> Int -> Double
183
184-- | wrapper for int gsl_sf_lnpoch_e(double a,double x,gsl_sf_result* result);
185lnpoch_e :: Double -> Double -> (Double,Double)
186lnpoch_e a x = createSFR "lnpoch_e" $ gsl_sf_lnpoch_e a x
187foreign import ccall "gamma.h gsl_sf_lnpoch_e" gsl_sf_lnpoch_e :: Double -> Double -> Ptr Double -> IO(Int)
188
189-- | wrapper for double gsl_sf_lnpoch(double a,double x);
190lnpoch :: Double -> Double -> Double
191lnpoch = gsl_sf_lnpoch
192foreign import ccall "gamma.h gsl_sf_lnpoch" gsl_sf_lnpoch :: Double -> Double -> Double
193
194-- | wrapper for int gsl_sf_lnpoch_sgn_e(double a,double x,gsl_sf_result* result,double* sgn);
195lnpoch_sgn_e :: Double -> Double -> Ptr Double -> Ptr Double -> Int
196lnpoch_sgn_e = gsl_sf_lnpoch_sgn_e
197foreign import ccall "gamma.h gsl_sf_lnpoch_sgn_e" gsl_sf_lnpoch_sgn_e :: Double -> Double -> Ptr Double -> Ptr Double -> Int
198
199-- | wrapper for int gsl_sf_poch_e(double a,double x,gsl_sf_result* result);
200poch_e :: Double -> Double -> (Double,Double)
201poch_e a x = createSFR "poch_e" $ gsl_sf_poch_e a x
202foreign import ccall "gamma.h gsl_sf_poch_e" gsl_sf_poch_e :: Double -> Double -> Ptr Double -> IO(Int)
203
204-- | wrapper for double gsl_sf_poch(double a,double x);
205poch :: Double -> Double -> Double
206poch = gsl_sf_poch
207foreign import ccall "gamma.h gsl_sf_poch" gsl_sf_poch :: Double -> Double -> Double
208
209-- | wrapper for int gsl_sf_pochrel_e(double a,double x,gsl_sf_result* result);
210pochrel_e :: Double -> Double -> (Double,Double)
211pochrel_e a x = createSFR "pochrel_e" $ gsl_sf_pochrel_e a x
212foreign import ccall "gamma.h gsl_sf_pochrel_e" gsl_sf_pochrel_e :: Double -> Double -> Ptr Double -> IO(Int)
213
214-- | wrapper for double gsl_sf_pochrel(double a,double x);
215pochrel :: Double -> Double -> Double
216pochrel = gsl_sf_pochrel
217foreign import ccall "gamma.h gsl_sf_pochrel" gsl_sf_pochrel :: Double -> Double -> Double
218
219-- | wrapper for int gsl_sf_gamma_inc_Q_e(double a,double x,gsl_sf_result* result);
220gamma_inc_Q_e :: Double -> Double -> (Double,Double)
221gamma_inc_Q_e a x = createSFR "gamma_inc_Q_e" $ gsl_sf_gamma_inc_Q_e a x
222foreign import ccall "gamma.h gsl_sf_gamma_inc_Q_e" gsl_sf_gamma_inc_Q_e :: Double -> Double -> Ptr Double -> IO(Int)
223
224-- | wrapper for double gsl_sf_gamma_inc_Q(double a,double x);
225gamma_inc_Q :: Double -> Double -> Double
226gamma_inc_Q = gsl_sf_gamma_inc_Q
227foreign import ccall "gamma.h gsl_sf_gamma_inc_Q" gsl_sf_gamma_inc_Q :: Double -> Double -> Double
228
229-- | wrapper for int gsl_sf_gamma_inc_P_e(double a,double x,gsl_sf_result* result);
230gamma_inc_P_e :: Double -> Double -> (Double,Double)
231gamma_inc_P_e a x = createSFR "gamma_inc_P_e" $ gsl_sf_gamma_inc_P_e a x
232foreign import ccall "gamma.h gsl_sf_gamma_inc_P_e" gsl_sf_gamma_inc_P_e :: Double -> Double -> Ptr Double -> IO(Int)
233
234-- | wrapper for double gsl_sf_gamma_inc_P(double a,double x);
235gamma_inc_P :: Double -> Double -> Double
236gamma_inc_P = gsl_sf_gamma_inc_P
237foreign import ccall "gamma.h gsl_sf_gamma_inc_P" gsl_sf_gamma_inc_P :: Double -> Double -> Double
238
239-- | wrapper for int gsl_sf_gamma_inc_e(double a,double x,gsl_sf_result* result);
240gamma_inc_e :: Double -> Double -> (Double,Double)
241gamma_inc_e a x = createSFR "gamma_inc_e" $ gsl_sf_gamma_inc_e a x
242foreign import ccall "gamma.h gsl_sf_gamma_inc_e" gsl_sf_gamma_inc_e :: Double -> Double -> Ptr Double -> IO(Int)
243
244-- | wrapper for double gsl_sf_gamma_inc(double a,double x);
245gamma_inc :: Double -> Double -> Double
246gamma_inc = gsl_sf_gamma_inc
247foreign import ccall "gamma.h gsl_sf_gamma_inc" gsl_sf_gamma_inc :: Double -> Double -> Double
248
249-- | wrapper for int gsl_sf_lnbeta_e(double a,double b,gsl_sf_result* result);
250lnbeta_e :: Double -> Double -> (Double,Double)
251lnbeta_e a b = createSFR "lnbeta_e" $ gsl_sf_lnbeta_e a b
252foreign import ccall "gamma.h gsl_sf_lnbeta_e" gsl_sf_lnbeta_e :: Double -> Double -> Ptr Double -> IO(Int)
253
254-- | wrapper for double gsl_sf_lnbeta(double a,double b);
255lnbeta :: Double -> Double -> Double
256lnbeta = gsl_sf_lnbeta
257foreign import ccall "gamma.h gsl_sf_lnbeta" gsl_sf_lnbeta :: Double -> Double -> Double
258
259-- | wrapper for int gsl_sf_beta_e(double a,double b,gsl_sf_result* result);
260beta_e :: Double -> Double -> (Double,Double)
261beta_e a b = createSFR "beta_e" $ gsl_sf_beta_e a b
262foreign import ccall "gamma.h gsl_sf_beta_e" gsl_sf_beta_e :: Double -> Double -> Ptr Double -> IO(Int)
263
264-- | wrapper for double gsl_sf_beta(double a,double b);
265beta :: Double -> Double -> Double
266beta = gsl_sf_beta
267foreign import ccall "gamma.h gsl_sf_beta" gsl_sf_beta :: Double -> Double -> Double
268
269-- | wrapper for int gsl_sf_beta_inc_e(double a,double b,double x,gsl_sf_result* result);
270beta_inc_e :: Double -> Double -> Double -> (Double,Double)
271beta_inc_e a b x = createSFR "beta_inc_e" $ gsl_sf_beta_inc_e a b x
272foreign import ccall "gamma.h gsl_sf_beta_inc_e" gsl_sf_beta_inc_e :: Double -> Double -> Double -> Ptr Double -> IO(Int)
273
274-- | wrapper for double gsl_sf_beta_inc(double a,double b,double x);
275beta_inc :: Double -> Double -> Double -> Double
276beta_inc = gsl_sf_beta_inc
277foreign import ccall "gamma.h gsl_sf_beta_inc" gsl_sf_beta_inc :: Double -> Double -> Double -> Double
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)
diff --git a/lib/GSL/Special/airy.h b/lib/GSL/Special/airy.h
new file mode 100644
index 0000000..e34e012
--- /dev/null
+++ b/lib/GSL/Special/airy.h
@@ -0,0 +1,24 @@
1int gsl_sf_airy_Ai_e(double x,int mode,double* result);
2double gsl_sf_airy_Ai(double x,int mode);
3int gsl_sf_airy_Bi_e(double x,int mode,double* result);
4double gsl_sf_airy_Bi(double x,int mode);
5int gsl_sf_airy_Ai_scaled_e(double x,int mode,double* result);
6double gsl_sf_airy_Ai_scaled(double x,int mode);
7int gsl_sf_airy_Bi_scaled_e(double x,int mode,double* result);
8double gsl_sf_airy_Bi_scaled(double x,int mode);
9int gsl_sf_airy_Ai_deriv_e(double x,int mode,double* result);
10double gsl_sf_airy_Ai_deriv(double x,int mode);
11int gsl_sf_airy_Bi_deriv_e(double x,int mode,double* result);
12double gsl_sf_airy_Bi_deriv(double x,int mode);
13int gsl_sf_airy_Ai_deriv_scaled_e(double x,int mode,double* result);
14double gsl_sf_airy_Ai_deriv_scaled(double x,int mode);
15int gsl_sf_airy_Bi_deriv_scaled_e(double x,int mode,double* result);
16double gsl_sf_airy_Bi_deriv_scaled(double x,int mode);
17int gsl_sf_airy_zero_Ai_e(int s,double* result);
18double gsl_sf_airy_zero_Ai(int s);
19int gsl_sf_airy_zero_Bi_e(int s,double* result);
20double gsl_sf_airy_zero_Bi(int s);
21int gsl_sf_airy_zero_Ai_deriv_e(int s,double* result);
22double gsl_sf_airy_zero_Ai_deriv(int s);
23int gsl_sf_airy_zero_Bi_deriv_e(int s,double* result);
24double gsl_sf_airy_zero_Bi_deriv(int s);
diff --git a/lib/GSL/Special/auto.hs b/lib/GSL/Special/auto.hs
new file mode 100644
index 0000000..f047bcb
--- /dev/null
+++ b/lib/GSL/Special/auto.hs
@@ -0,0 +1,201 @@
1-- automatic generation of wrappers for simple GSL special functions
2
3import Text.ParserCombinators.Parsec
4import System
5import Data.List(intersperse, isPrefixOf)
6import Data.Char(toUpper)
7
8data Type = Normal Ident | Pointer Ident deriving (Eq, Show)
9
10type Ident = String
11
12data Header = Header Type Ident [(Type,Ident)] deriving Show
13
14headers f = case parse parseHeaders "" f of
15 Right l -> l
16 Left s -> error (show s)
17
18
19rep (c,r) [] = []
20rep (c,r) f@(x:xs)
21 | c `isPrefixOf` f = r ++ rep (c,r) (drop (length c) f)
22 | otherwise = x:(rep (c,r) xs)
23
24
25fixlong [] = []
26fixlong "\\" = []
27fixlong ('\\':'\n':xs) = xs
28fixlong (x:xs) = x : fixlong xs
29
30
31safe (Header _ _ args) = all ok args
32 || all ok (init args) && kn (last args)
33 where ok ((Normal s),_) | s `elem` ["double","float","int","gsl_mode_t"] = True
34 ok _ = False
35 kn ((Pointer "gsl_sf_result"),_) = True
36 kn _ = False
37
38
39
40fixC s = rep ("gsl_mode_t","int") $ rep ("gsl_sf_result","double") $ s
41
42main = do
43 args <- getArgs
44 file <- readFile (args!!1)
45 let name = args!!0
46 putStrLn (args!!1)
47 --mapM_ print (headers $ fixlong file)
48 let parsed = (headers $ fixlong file)
49 writeFile (name ++".h") (fixC $ unlines $ map showC parsed)
50
51 --putStrLn ""
52 --mapM (\(Header _ n _) -> putStrLn (drop 7 n ++",")) parsed
53 --putStrLn ""
54 --mapM_ (putStrLn.showFull (name ++".h")) parsed
55 let exports = rep (")",") where") $ rep ("(\n","(\n ") $ rep (",\n",", ") $ unlines $ ["("]++intersperse "," (map (\(Header _ n _) -> drop 7 n) (filter safe parsed))++[")"]
56 let defs = unlines $ map (showFull (name ++".h")) parsed
57 let imports = "\nimport Foreign(Ptr)\nimport GSL.Special.Internal\n"
58 let mod = modhead name ++ "module GSL.Special."++ upperFirst name++exports++imports++defs
59 writeFile (upperFirst name ++ ".hs") mod
60
61
62modhead name = replicate 60 '-' ++ "\n"
63 ++"{- |\n"
64 ++"Module : GSL.Special."++upperFirst name++"\n"
65 ++"Copyright : (c) Alberto Ruiz 2006\n"
66 ++"License : GPL-style\n"
67 ++"Maintainer : Alberto Ruiz (aruiz at um dot es)\n"
68 ++"Stability : provisional\n"
69 ++"Portability : uses ffi\n"
70 ++"\n\n\n-}\n"
71 ++ replicate 60 '-' ++ "\n\n"
72
73upperFirst (x:xs) = toUpper x : xs
74
75comment = do
76 string "/*"
77 closecomment
78 spaces
79 return "comment"
80
81closecomment = try (string "*/")
82 <|> (do anyChar
83 closecomment)
84
85ident = do
86 spaces
87 id <- many1 (noneOf "()[]* \n\t,;")
88 spaces
89 return id
90
91comment' = between (char '(') (char ')') (many $ noneOf ")")
92
93
94define = do
95 string "#"
96 closedefine
97 spaces
98 return "define"
99
100closedefine = try (string "\n")
101 <|> (do anyChar
102 closedefine)
103
104marks = do
105 try (string "__BEGIN_DECLS" >> spaces >> return "begin")
106 <|>
107 try (string "__END_DECLS" >> spaces >> return "end")
108
109
110
111irrelevant =
112 try comment
113 <|>
114 try define
115 <|>
116 marks
117
118
119parseHeaders = many parseHeader
120
121parseHeader = do
122 spaces
123 many irrelevant
124 spaces
125 (res,name) <- typ
126 spaces
127 args <- between (char '(') (char ')') (sepBy typ (char ','))
128 spaces
129 char ';'
130 spaces
131 many irrelevant
132 return $ Header res name args
133
134typ = try t1 <|> t2
135
136symbol s = spaces >> string s >> spaces
137
138t1 = do
139 t <- try (symbol "const" >> symbol "unsigned" >> ident) -- aaagh
140 <|>
141 try (symbol "const" >> ident)
142 <|>
143 try (symbol "unsigned" >> ident)
144 <|> ident
145 n <- ident
146 return (Normal t,n)
147
148t2 = do
149 t <- ident
150 spaces
151 char '*'
152 spaces
153 n <- ident
154 return (Pointer t,n)
155
156pure (Header _ _ args) | fst (last args) == Pointer "gsl_sf_result" = False
157 | otherwise = True
158
159showC (Header t n args) = showCt t ++ " " ++ n ++ "(" ++ (concat $ intersperse "," $ map showCa args) ++ ");"
160
161showCt (Normal s) = s
162showCt (Pointer s) = s ++ "*"
163
164showCa (t, a) = showCt t ++" "++ a
165
166showH hc h@(Header t n args) = "foreign import ccall \""++hc++" "++n++"\" "++n++" :: "++ (concat$intersperse" -> "$map showHa args) ++" -> " ++ t'
167 where t' | pure h = showHt t
168 | otherwise = "IO("++showHt t++")"
169
170showHt (Normal (s:ss)) = toUpper s : ss
171showHt (Pointer "gsl_sf_result") = "Ptr Double"
172showHt (Pointer (s:ss)) = "Ptr "++toUpper s : ss
173
174showHa (t,a) = showHt t
175
176showFull hc h@(Header t n args) = "\n-- | wrapper for "++showC h++"\n"++ boiler h ++"\n" ++showH hc h
177
178fixmd1 = rep ("Gsl_mode_t","Precision")
179fixmd2 = rep ("mode"," (precCode mode)")
180
181boiler h@(Header t n args) | fst (last args) == Pointer "gsl_sf_result" = boilerResult h
182 | any isMode args = boilerMode h
183 | otherwise = boilerBasic h
184
185isMode (Normal "gsl_mode_t",_) = True
186isMode _ = False
187
188
189boilerResult h@(Header t n args) =
190 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$ map showHa (init args)) ++" -> " ++ "(Double,Double)\n" ++
191 drop 7 n ++ " "++(unwords (map snd (init args)))++
192 " = createSFR \""++ drop 7 n ++"\" $ " ++ n ++ " "++(fixmd2 $ unwords (map snd (init args)))
193
194boilerBasic h@(Header t n args) =
195 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$map showHa args) ++" -> " ++showHt t ++ "\n" ++
196 drop 7 n ++ " = " ++fixmd2 n
197
198boilerMode h@(Header t n args) =
199 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$ map showHa args) ++" -> " ++ showHt t++"\n" ++
200 drop 7 n ++ " "++(unwords (map snd args))++
201 " = " ++ n ++ " "++(fixmd2 $ unwords (map snd args))
diff --git a/lib/GSL/Special/erf.h b/lib/GSL/Special/erf.h
new file mode 100644
index 0000000..17369cf
--- /dev/null
+++ b/lib/GSL/Special/erf.h
@@ -0,0 +1,12 @@
1int gsl_sf_erfc_e(double x,double* result);
2double gsl_sf_erfc(double x);
3int gsl_sf_log_erfc_e(double x,double* result);
4double gsl_sf_log_erfc(double x);
5int gsl_sf_erf_e(double x,double* result);
6double gsl_sf_erf(double x);
7int gsl_sf_erf_Z_e(double x,double* result);
8int gsl_sf_erf_Q_e(double x,double* result);
9double gsl_sf_erf_Z(double x);
10double gsl_sf_erf_Q(double x);
11int gsl_sf_hazard_e(double x,double* result);
12double gsl_sf_hazard(double x);
diff --git a/lib/GSL/Special/gamma.h b/lib/GSL/Special/gamma.h
new file mode 100644
index 0000000..c5cc417
--- /dev/null
+++ b/lib/GSL/Special/gamma.h
@@ -0,0 +1,43 @@
1int gsl_sf_lngamma_e(double x,double* result);
2double gsl_sf_lngamma(double x);
3int gsl_sf_lngamma_sgn_e(double x,double* result_lg,double* sgn);
4int gsl_sf_gamma_e(double x,double* result);
5double gsl_sf_gamma(double x);
6int gsl_sf_gammastar_e(double x,double* result);
7double gsl_sf_gammastar(double x);
8int gsl_sf_gammainv_e(double x,double* result);
9double gsl_sf_gammainv(double x);
10int gsl_sf_lngamma_complex_e(double zr,double zi,double* lnr,double* arg);
11int gsl_sf_taylorcoeff_e(int n,double x,double* result);
12double gsl_sf_taylorcoeff(int n,double x);
13int gsl_sf_fact_e(int n,double* result);
14double gsl_sf_fact(int n);
15int gsl_sf_doublefact_e(int n,double* result);
16double gsl_sf_doublefact(int n);
17int gsl_sf_lnfact_e(int n,double* result);
18double gsl_sf_lnfact(int n);
19int gsl_sf_lndoublefact_e(int n,double* result);
20double gsl_sf_lndoublefact(int n);
21int gsl_sf_lnchoose_e(int n,int m,double* result);
22double gsl_sf_lnchoose(int n,int m);
23int gsl_sf_choose_e(int n,int m,double* result);
24double gsl_sf_choose(int n,int m);
25int gsl_sf_lnpoch_e(double a,double x,double* result);
26double gsl_sf_lnpoch(double a,double x);
27int gsl_sf_lnpoch_sgn_e(double a,double x,double* result,double* sgn);
28int gsl_sf_poch_e(double a,double x,double* result);
29double gsl_sf_poch(double a,double x);
30int gsl_sf_pochrel_e(double a,double x,double* result);
31double gsl_sf_pochrel(double a,double x);
32int gsl_sf_gamma_inc_Q_e(double a,double x,double* result);
33double gsl_sf_gamma_inc_Q(double a,double x);
34int gsl_sf_gamma_inc_P_e(double a,double x,double* result);
35double gsl_sf_gamma_inc_P(double a,double x);
36int gsl_sf_gamma_inc_e(double a,double x,double* result);
37double gsl_sf_gamma_inc(double a,double x);
38int gsl_sf_lnbeta_e(double a,double b,double* result);
39double gsl_sf_lnbeta(double a,double b);
40int gsl_sf_beta_e(double a,double b,double* result);
41double gsl_sf_beta(double a,double b);
42int gsl_sf_beta_inc_e(double a,double b,double x,double* result);
43double gsl_sf_beta_inc(double a,double b,double x);
diff --git a/lib/HSSL.hs b/lib/HSSL.hs
deleted file mode 100644
index 4506386..0000000
--- a/lib/HSSL.hs
+++ /dev/null
@@ -1,17 +0,0 @@
1{- |
2
3Module : GSL
4Copyright : (c) Alberto Ruiz 2006-7
5License : GPL-style
6
7Maintainer : Alberto Ruiz (aruiz at um dot es)
8Stability : provisional
9Portability : uses -fffi and -fglasgow-exts
10
11This module reexports the basic functionality and a collection of utilities.
12
13-}
14
15module HSSL (
16
17) where