diff options
Diffstat (limited to 'lib/GSL/Special')
-rw-r--r-- | lib/GSL/Special/Airy.hs | 166 | ||||
-rw-r--r-- | lib/GSL/Special/Erf.hs | 93 | ||||
-rw-r--r-- | lib/GSL/Special/Gamma.hs | 277 | ||||
-rw-r--r-- | lib/GSL/Special/Internal.hs | 65 | ||||
-rw-r--r-- | lib/GSL/Special/airy.h | 24 | ||||
-rw-r--r-- | lib/GSL/Special/auto.hs | 201 | ||||
-rw-r--r-- | lib/GSL/Special/erf.h | 12 | ||||
-rw-r--r-- | lib/GSL/Special/gamma.h | 43 |
8 files changed, 881 insertions, 0 deletions
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 | {- | | ||
3 | Module : GSL.Special.Airy | ||
4 | Copyright : (c) Alberto Ruiz 2006 | ||
5 | License : GPL-style | ||
6 | Maintainer : Alberto Ruiz (aruiz at um dot es) | ||
7 | Stability : provisional | ||
8 | Portability : uses ffi | ||
9 | |||
10 | Wrappers 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 | |||
17 | module 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 | |||
45 | import Foreign(Ptr) | ||
46 | import GSL.Special.Internal | ||
47 | |||
48 | -- | wrapper for int gsl_sf_airy_Ai_e(double x,gsl_mode_t mode,gsl_sf_result* result); | ||
49 | airy_Ai_e :: Double -> Precision -> (Double,Double) | ||
50 | airy_Ai_e x mode = createSFR "airy_Ai_e" $ gsl_sf_airy_Ai_e x (precCode mode) | ||
51 | foreign 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); | ||
54 | airy_Ai :: Double -> Precision -> Double | ||
55 | airy_Ai x mode = gsl_sf_airy_Ai x (precCode mode) | ||
56 | foreign 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); | ||
59 | airy_Bi_e :: Double -> Precision -> (Double,Double) | ||
60 | airy_Bi_e x mode = createSFR "airy_Bi_e" $ gsl_sf_airy_Bi_e x (precCode mode) | ||
61 | foreign 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); | ||
64 | airy_Bi :: Double -> Precision -> Double | ||
65 | airy_Bi x mode = gsl_sf_airy_Bi x (precCode mode) | ||
66 | foreign 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); | ||
69 | airy_Ai_scaled_e :: Double -> Precision -> (Double,Double) | ||
70 | airy_Ai_scaled_e x mode = createSFR "airy_Ai_scaled_e" $ gsl_sf_airy_Ai_scaled_e x (precCode mode) | ||
71 | foreign 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); | ||
74 | airy_Ai_scaled :: Double -> Precision -> Double | ||
75 | airy_Ai_scaled x mode = gsl_sf_airy_Ai_scaled x (precCode mode) | ||
76 | foreign 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); | ||
79 | airy_Bi_scaled_e :: Double -> Precision -> (Double,Double) | ||
80 | airy_Bi_scaled_e x mode = createSFR "airy_Bi_scaled_e" $ gsl_sf_airy_Bi_scaled_e x (precCode mode) | ||
81 | foreign 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); | ||
84 | airy_Bi_scaled :: Double -> Precision -> Double | ||
85 | airy_Bi_scaled x mode = gsl_sf_airy_Bi_scaled x (precCode mode) | ||
86 | foreign 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); | ||
89 | airy_Ai_deriv_e :: Double -> Precision -> (Double,Double) | ||
90 | airy_Ai_deriv_e x mode = createSFR "airy_Ai_deriv_e" $ gsl_sf_airy_Ai_deriv_e x (precCode mode) | ||
91 | foreign 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); | ||
94 | airy_Ai_deriv :: Double -> Precision -> Double | ||
95 | airy_Ai_deriv x mode = gsl_sf_airy_Ai_deriv x (precCode mode) | ||
96 | foreign 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); | ||
99 | airy_Bi_deriv_e :: Double -> Precision -> (Double,Double) | ||
100 | airy_Bi_deriv_e x mode = createSFR "airy_Bi_deriv_e" $ gsl_sf_airy_Bi_deriv_e x (precCode mode) | ||
101 | foreign 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); | ||
104 | airy_Bi_deriv :: Double -> Precision -> Double | ||
105 | airy_Bi_deriv x mode = gsl_sf_airy_Bi_deriv x (precCode mode) | ||
106 | foreign 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); | ||
109 | airy_Ai_deriv_scaled_e :: Double -> Precision -> (Double,Double) | ||
110 | airy_Ai_deriv_scaled_e x mode = createSFR "airy_Ai_deriv_scaled_e" $ gsl_sf_airy_Ai_deriv_scaled_e x (precCode mode) | ||
111 | foreign 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); | ||
114 | airy_Ai_deriv_scaled :: Double -> Precision -> Double | ||
115 | airy_Ai_deriv_scaled x mode = gsl_sf_airy_Ai_deriv_scaled x (precCode mode) | ||
116 | foreign 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); | ||
119 | airy_Bi_deriv_scaled_e :: Double -> Precision -> (Double,Double) | ||
120 | airy_Bi_deriv_scaled_e x mode = createSFR "airy_Bi_deriv_scaled_e" $ gsl_sf_airy_Bi_deriv_scaled_e x (precCode mode) | ||
121 | foreign 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); | ||
124 | airy_Bi_deriv_scaled :: Double -> Precision -> Double | ||
125 | airy_Bi_deriv_scaled x mode = gsl_sf_airy_Bi_deriv_scaled x (precCode mode) | ||
126 | foreign 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); | ||
129 | airy_zero_Ai_e :: Int -> (Double,Double) | ||
130 | airy_zero_Ai_e s = createSFR "airy_zero_Ai_e" $ gsl_sf_airy_zero_Ai_e s | ||
131 | foreign 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); | ||
134 | airy_zero_Ai :: Int -> Double | ||
135 | airy_zero_Ai = gsl_sf_airy_zero_Ai | ||
136 | foreign 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); | ||
139 | airy_zero_Bi_e :: Int -> (Double,Double) | ||
140 | airy_zero_Bi_e s = createSFR "airy_zero_Bi_e" $ gsl_sf_airy_zero_Bi_e s | ||
141 | foreign 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); | ||
144 | airy_zero_Bi :: Int -> Double | ||
145 | airy_zero_Bi = gsl_sf_airy_zero_Bi | ||
146 | foreign 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); | ||
149 | airy_zero_Ai_deriv_e :: Int -> (Double,Double) | ||
150 | airy_zero_Ai_deriv_e s = createSFR "airy_zero_Ai_deriv_e" $ gsl_sf_airy_zero_Ai_deriv_e s | ||
151 | foreign 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); | ||
154 | airy_zero_Ai_deriv :: Int -> Double | ||
155 | airy_zero_Ai_deriv = gsl_sf_airy_zero_Ai_deriv | ||
156 | foreign 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); | ||
159 | airy_zero_Bi_deriv_e :: Int -> (Double,Double) | ||
160 | airy_zero_Bi_deriv_e s = createSFR "airy_zero_Bi_deriv_e" $ gsl_sf_airy_zero_Bi_deriv_e s | ||
161 | foreign 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); | ||
164 | airy_zero_Bi_deriv :: Int -> Double | ||
165 | airy_zero_Bi_deriv = gsl_sf_airy_zero_Bi_deriv | ||
166 | foreign 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 | {- | | ||
3 | Module : GSL.Special.Erf | ||
4 | Copyright : (c) Alberto Ruiz 2006 | ||
5 | License : GPL-style | ||
6 | Maintainer : Alberto Ruiz (aruiz at um dot es) | ||
7 | Stability : provisional | ||
8 | Portability : uses ffi | ||
9 | |||
10 | Wrappers for selected functions described at: | ||
11 | |||
12 | <http://www.gnu.org/software/gsl/manual/html_node/Error-Functions.html> | ||
13 | |||
14 | -} | ||
15 | ------------------------------------------------------------ | ||
16 | |||
17 | module 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 | |||
32 | import Foreign(Ptr) | ||
33 | import GSL.Special.Internal | ||
34 | |||
35 | -- | wrapper for int gsl_sf_erfc_e(double x,gsl_sf_result* result); | ||
36 | erfc_e :: Double -> (Double,Double) | ||
37 | erfc_e x = createSFR "erfc_e" $ gsl_sf_erfc_e x | ||
38 | foreign 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); | ||
41 | erfc :: Double -> Double | ||
42 | erfc = gsl_sf_erfc | ||
43 | foreign 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); | ||
46 | log_erfc_e :: Double -> (Double,Double) | ||
47 | log_erfc_e x = createSFR "log_erfc_e" $ gsl_sf_log_erfc_e x | ||
48 | foreign 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); | ||
51 | log_erfc :: Double -> Double | ||
52 | log_erfc = gsl_sf_log_erfc | ||
53 | foreign 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); | ||
56 | erf_e :: Double -> (Double,Double) | ||
57 | erf_e x = createSFR "erf_e" $ gsl_sf_erf_e x | ||
58 | foreign 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); | ||
61 | erf :: Double -> Double | ||
62 | erf = gsl_sf_erf | ||
63 | foreign 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); | ||
66 | erf_Z_e :: Double -> (Double,Double) | ||
67 | erf_Z_e x = createSFR "erf_Z_e" $ gsl_sf_erf_Z_e x | ||
68 | foreign 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); | ||
71 | erf_Q_e :: Double -> (Double,Double) | ||
72 | erf_Q_e x = createSFR "erf_Q_e" $ gsl_sf_erf_Q_e x | ||
73 | foreign 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); | ||
76 | erf_Z :: Double -> Double | ||
77 | erf_Z = gsl_sf_erf_Z | ||
78 | foreign 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); | ||
81 | erf_Q :: Double -> Double | ||
82 | erf_Q = gsl_sf_erf_Q | ||
83 | foreign 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); | ||
86 | hazard_e :: Double -> (Double,Double) | ||
87 | hazard_e x = createSFR "hazard_e" $ gsl_sf_hazard_e x | ||
88 | foreign 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); | ||
91 | hazard :: Double -> Double | ||
92 | hazard = gsl_sf_hazard | ||
93 | foreign 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 | {- | | ||
3 | Module : GSL.Special.Gamma | ||
4 | Copyright : (c) Alberto Ruiz 2006 | ||
5 | License : GPL-style | ||
6 | Maintainer : Alberto Ruiz (aruiz at um dot es) | ||
7 | Stability : provisional | ||
8 | Portability : uses ffi | ||
9 | |||
10 | Wrappers 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 | |||
18 | module 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 | |||
61 | import Foreign(Ptr) | ||
62 | import GSL.Special.Internal | ||
63 | |||
64 | -- | wrapper for int gsl_sf_lngamma_e(double x,gsl_sf_result* result); | ||
65 | lngamma_e :: Double -> (Double,Double) | ||
66 | lngamma_e x = createSFR "lngamma_e" $ gsl_sf_lngamma_e x | ||
67 | foreign 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); | ||
70 | lngamma :: Double -> Double | ||
71 | lngamma = gsl_sf_lngamma | ||
72 | foreign 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); | ||
75 | lngamma_sgn_e :: Double -> Ptr Double -> Ptr Double -> Int | ||
76 | lngamma_sgn_e = gsl_sf_lngamma_sgn_e | ||
77 | foreign 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); | ||
80 | gamma_e :: Double -> (Double,Double) | ||
81 | gamma_e x = createSFR "gamma_e" $ gsl_sf_gamma_e x | ||
82 | foreign 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); | ||
85 | gamma :: Double -> Double | ||
86 | gamma = gsl_sf_gamma | ||
87 | foreign 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); | ||
90 | gammastar_e :: Double -> (Double,Double) | ||
91 | gammastar_e x = createSFR "gammastar_e" $ gsl_sf_gammastar_e x | ||
92 | foreign 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); | ||
95 | gammastar :: Double -> Double | ||
96 | gammastar = gsl_sf_gammastar | ||
97 | foreign 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); | ||
100 | gammainv_e :: Double -> (Double,Double) | ||
101 | gammainv_e x = createSFR "gammainv_e" $ gsl_sf_gammainv_e x | ||
102 | foreign 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); | ||
105 | gammainv :: Double -> Double | ||
106 | gammainv = gsl_sf_gammainv | ||
107 | foreign 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); | ||
110 | lngamma_complex_e :: Double -> Double -> Ptr Double -> (Double,Double) | ||
111 | lngamma_complex_e zr zi lnr = createSFR "lngamma_complex_e" $ gsl_sf_lngamma_complex_e zr zi lnr | ||
112 | foreign 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); | ||
115 | taylorcoeff_e :: Int -> Double -> (Double,Double) | ||
116 | taylorcoeff_e n x = createSFR "taylorcoeff_e" $ gsl_sf_taylorcoeff_e n x | ||
117 | foreign 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); | ||
120 | taylorcoeff :: Int -> Double -> Double | ||
121 | taylorcoeff = gsl_sf_taylorcoeff | ||
122 | foreign 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); | ||
125 | fact_e :: Int -> (Double,Double) | ||
126 | fact_e n = createSFR "fact_e" $ gsl_sf_fact_e n | ||
127 | foreign 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); | ||
130 | fact :: Int -> Double | ||
131 | fact = gsl_sf_fact | ||
132 | foreign 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); | ||
135 | doublefact_e :: Int -> (Double,Double) | ||
136 | doublefact_e n = createSFR "doublefact_e" $ gsl_sf_doublefact_e n | ||
137 | foreign 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); | ||
140 | doublefact :: Int -> Double | ||
141 | doublefact = gsl_sf_doublefact | ||
142 | foreign 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); | ||
145 | lnfact_e :: Int -> (Double,Double) | ||
146 | lnfact_e n = createSFR "lnfact_e" $ gsl_sf_lnfact_e n | ||
147 | foreign 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); | ||
150 | lnfact :: Int -> Double | ||
151 | lnfact = gsl_sf_lnfact | ||
152 | foreign 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); | ||
155 | lndoublefact_e :: Int -> (Double,Double) | ||
156 | lndoublefact_e n = createSFR "lndoublefact_e" $ gsl_sf_lndoublefact_e n | ||
157 | foreign 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); | ||
160 | lndoublefact :: Int -> Double | ||
161 | lndoublefact = gsl_sf_lndoublefact | ||
162 | foreign 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); | ||
165 | lnchoose_e :: Int -> Int -> (Double,Double) | ||
166 | lnchoose_e n m = createSFR "lnchoose_e" $ gsl_sf_lnchoose_e n m | ||
167 | foreign 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); | ||
170 | lnchoose :: Int -> Int -> Double | ||
171 | lnchoose = gsl_sf_lnchoose | ||
172 | foreign 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); | ||
175 | choose_e :: Int -> Int -> (Double,Double) | ||
176 | choose_e n m = createSFR "choose_e" $ gsl_sf_choose_e n m | ||
177 | foreign 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); | ||
180 | choose :: Int -> Int -> Double | ||
181 | choose = gsl_sf_choose | ||
182 | foreign 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); | ||
185 | lnpoch_e :: Double -> Double -> (Double,Double) | ||
186 | lnpoch_e a x = createSFR "lnpoch_e" $ gsl_sf_lnpoch_e a x | ||
187 | foreign 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); | ||
190 | lnpoch :: Double -> Double -> Double | ||
191 | lnpoch = gsl_sf_lnpoch | ||
192 | foreign 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); | ||
195 | lnpoch_sgn_e :: Double -> Double -> Ptr Double -> Ptr Double -> Int | ||
196 | lnpoch_sgn_e = gsl_sf_lnpoch_sgn_e | ||
197 | foreign 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); | ||
200 | poch_e :: Double -> Double -> (Double,Double) | ||
201 | poch_e a x = createSFR "poch_e" $ gsl_sf_poch_e a x | ||
202 | foreign 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); | ||
205 | poch :: Double -> Double -> Double | ||
206 | poch = gsl_sf_poch | ||
207 | foreign 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); | ||
210 | pochrel_e :: Double -> Double -> (Double,Double) | ||
211 | pochrel_e a x = createSFR "pochrel_e" $ gsl_sf_pochrel_e a x | ||
212 | foreign 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); | ||
215 | pochrel :: Double -> Double -> Double | ||
216 | pochrel = gsl_sf_pochrel | ||
217 | foreign 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); | ||
220 | gamma_inc_Q_e :: Double -> Double -> (Double,Double) | ||
221 | gamma_inc_Q_e a x = createSFR "gamma_inc_Q_e" $ gsl_sf_gamma_inc_Q_e a x | ||
222 | foreign 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); | ||
225 | gamma_inc_Q :: Double -> Double -> Double | ||
226 | gamma_inc_Q = gsl_sf_gamma_inc_Q | ||
227 | foreign 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); | ||
230 | gamma_inc_P_e :: Double -> Double -> (Double,Double) | ||
231 | gamma_inc_P_e a x = createSFR "gamma_inc_P_e" $ gsl_sf_gamma_inc_P_e a x | ||
232 | foreign 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); | ||
235 | gamma_inc_P :: Double -> Double -> Double | ||
236 | gamma_inc_P = gsl_sf_gamma_inc_P | ||
237 | foreign 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); | ||
240 | gamma_inc_e :: Double -> Double -> (Double,Double) | ||
241 | gamma_inc_e a x = createSFR "gamma_inc_e" $ gsl_sf_gamma_inc_e a x | ||
242 | foreign 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); | ||
245 | gamma_inc :: Double -> Double -> Double | ||
246 | gamma_inc = gsl_sf_gamma_inc | ||
247 | foreign 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); | ||
250 | lnbeta_e :: Double -> Double -> (Double,Double) | ||
251 | lnbeta_e a b = createSFR "lnbeta_e" $ gsl_sf_lnbeta_e a b | ||
252 | foreign 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); | ||
255 | lnbeta :: Double -> Double -> Double | ||
256 | lnbeta = gsl_sf_lnbeta | ||
257 | foreign 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); | ||
260 | beta_e :: Double -> Double -> (Double,Double) | ||
261 | beta_e a b = createSFR "beta_e" $ gsl_sf_beta_e a b | ||
262 | foreign 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); | ||
265 | beta :: Double -> Double -> Double | ||
266 | beta = gsl_sf_beta | ||
267 | foreign 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); | ||
270 | beta_inc_e :: Double -> Double -> Double -> (Double,Double) | ||
271 | beta_inc_e a b x = createSFR "beta_inc_e" $ gsl_sf_beta_inc_e a b x | ||
272 | foreign 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); | ||
275 | beta_inc :: Double -> Double -> Double -> Double | ||
276 | beta_inc = gsl_sf_beta_inc | ||
277 | foreign 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 | {- | | ||
4 | Module : GSL.Special.Internal | ||
5 | Copyright : (c) Alberto Ruiz 2007 | ||
6 | License : GPL-style | ||
7 | |||
8 | Maintainer : Alberto Ruiz (aruiz at um dot es) | ||
9 | Stability : provisional | ||
10 | Portability : uses ffi | ||
11 | |||
12 | Support for Special functions. | ||
13 | |||
14 | <http://www.gnu.org/software/gsl/manual/html_node/Special-Functions.html#Special-Functions> | ||
15 | -} | ||
16 | ----------------------------------------------------------------------------- | ||
17 | |||
18 | module GSL.Special.Internal ( | ||
19 | createSFR, | ||
20 | createSFR_E10, | ||
21 | Precision(..), | ||
22 | Gsl_mode_t, | ||
23 | precCode | ||
24 | ) | ||
25 | where | ||
26 | |||
27 | import Foreign | ||
28 | import Data.Packed.Internal.Common(check,(//)) | ||
29 | |||
30 | |||
31 | data Precision = PrecDouble | PrecSingle | PrecApprox | ||
32 | |||
33 | precCode :: Precision -> Int | ||
34 | precCode PrecDouble = 0 | ||
35 | precCode PrecSingle = 1 | ||
36 | precCode PrecApprox = 2 | ||
37 | |||
38 | type Gsl_mode_t = Int | ||
39 | |||
40 | ---------------------------------------------------------------- | ||
41 | -- | access to a sf_result | ||
42 | createSFR :: Storable a => t -> (Ptr a -> IO Int) -> (a, a) | ||
43 | createSFR 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 | ||
55 | createSFR_E10 :: (Storable t2, Storable t3, Storable t1) => t -> (Ptr a -> IO Int) -> (t1, t2, t3) | ||
56 | createSFR_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 @@ | |||
1 | int gsl_sf_airy_Ai_e(double x,int mode,double* result); | ||
2 | double gsl_sf_airy_Ai(double x,int mode); | ||
3 | int gsl_sf_airy_Bi_e(double x,int mode,double* result); | ||
4 | double gsl_sf_airy_Bi(double x,int mode); | ||
5 | int gsl_sf_airy_Ai_scaled_e(double x,int mode,double* result); | ||
6 | double gsl_sf_airy_Ai_scaled(double x,int mode); | ||
7 | int gsl_sf_airy_Bi_scaled_e(double x,int mode,double* result); | ||
8 | double gsl_sf_airy_Bi_scaled(double x,int mode); | ||
9 | int gsl_sf_airy_Ai_deriv_e(double x,int mode,double* result); | ||
10 | double gsl_sf_airy_Ai_deriv(double x,int mode); | ||
11 | int gsl_sf_airy_Bi_deriv_e(double x,int mode,double* result); | ||
12 | double gsl_sf_airy_Bi_deriv(double x,int mode); | ||
13 | int gsl_sf_airy_Ai_deriv_scaled_e(double x,int mode,double* result); | ||
14 | double gsl_sf_airy_Ai_deriv_scaled(double x,int mode); | ||
15 | int gsl_sf_airy_Bi_deriv_scaled_e(double x,int mode,double* result); | ||
16 | double gsl_sf_airy_Bi_deriv_scaled(double x,int mode); | ||
17 | int gsl_sf_airy_zero_Ai_e(int s,double* result); | ||
18 | double gsl_sf_airy_zero_Ai(int s); | ||
19 | int gsl_sf_airy_zero_Bi_e(int s,double* result); | ||
20 | double gsl_sf_airy_zero_Bi(int s); | ||
21 | int gsl_sf_airy_zero_Ai_deriv_e(int s,double* result); | ||
22 | double gsl_sf_airy_zero_Ai_deriv(int s); | ||
23 | int gsl_sf_airy_zero_Bi_deriv_e(int s,double* result); | ||
24 | double 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 | |||
3 | import Text.ParserCombinators.Parsec | ||
4 | import System | ||
5 | import Data.List(intersperse, isPrefixOf) | ||
6 | import Data.Char(toUpper) | ||
7 | |||
8 | data Type = Normal Ident | Pointer Ident deriving (Eq, Show) | ||
9 | |||
10 | type Ident = String | ||
11 | |||
12 | data Header = Header Type Ident [(Type,Ident)] deriving Show | ||
13 | |||
14 | headers f = case parse parseHeaders "" f of | ||
15 | Right l -> l | ||
16 | Left s -> error (show s) | ||
17 | |||
18 | |||
19 | rep (c,r) [] = [] | ||
20 | rep (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 | |||
25 | fixlong [] = [] | ||
26 | fixlong "\\" = [] | ||
27 | fixlong ('\\':'\n':xs) = xs | ||
28 | fixlong (x:xs) = x : fixlong xs | ||
29 | |||
30 | |||
31 | safe (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 | |||
40 | fixC s = rep ("gsl_mode_t","int") $ rep ("gsl_sf_result","double") $ s | ||
41 | |||
42 | main = 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 | |||
62 | modhead 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 | |||
73 | upperFirst (x:xs) = toUpper x : xs | ||
74 | |||
75 | comment = do | ||
76 | string "/*" | ||
77 | closecomment | ||
78 | spaces | ||
79 | return "comment" | ||
80 | |||
81 | closecomment = try (string "*/") | ||
82 | <|> (do anyChar | ||
83 | closecomment) | ||
84 | |||
85 | ident = do | ||
86 | spaces | ||
87 | id <- many1 (noneOf "()[]* \n\t,;") | ||
88 | spaces | ||
89 | return id | ||
90 | |||
91 | comment' = between (char '(') (char ')') (many $ noneOf ")") | ||
92 | |||
93 | |||
94 | define = do | ||
95 | string "#" | ||
96 | closedefine | ||
97 | spaces | ||
98 | return "define" | ||
99 | |||
100 | closedefine = try (string "\n") | ||
101 | <|> (do anyChar | ||
102 | closedefine) | ||
103 | |||
104 | marks = do | ||
105 | try (string "__BEGIN_DECLS" >> spaces >> return "begin") | ||
106 | <|> | ||
107 | try (string "__END_DECLS" >> spaces >> return "end") | ||
108 | |||
109 | |||
110 | |||
111 | irrelevant = | ||
112 | try comment | ||
113 | <|> | ||
114 | try define | ||
115 | <|> | ||
116 | marks | ||
117 | |||
118 | |||
119 | parseHeaders = many parseHeader | ||
120 | |||
121 | parseHeader = 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 | |||
134 | typ = try t1 <|> t2 | ||
135 | |||
136 | symbol s = spaces >> string s >> spaces | ||
137 | |||
138 | t1 = 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 | |||
148 | t2 = do | ||
149 | t <- ident | ||
150 | spaces | ||
151 | char '*' | ||
152 | spaces | ||
153 | n <- ident | ||
154 | return (Pointer t,n) | ||
155 | |||
156 | pure (Header _ _ args) | fst (last args) == Pointer "gsl_sf_result" = False | ||
157 | | otherwise = True | ||
158 | |||
159 | showC (Header t n args) = showCt t ++ " " ++ n ++ "(" ++ (concat $ intersperse "," $ map showCa args) ++ ");" | ||
160 | |||
161 | showCt (Normal s) = s | ||
162 | showCt (Pointer s) = s ++ "*" | ||
163 | |||
164 | showCa (t, a) = showCt t ++" "++ a | ||
165 | |||
166 | showH 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 | |||
170 | showHt (Normal (s:ss)) = toUpper s : ss | ||
171 | showHt (Pointer "gsl_sf_result") = "Ptr Double" | ||
172 | showHt (Pointer (s:ss)) = "Ptr "++toUpper s : ss | ||
173 | |||
174 | showHa (t,a) = showHt t | ||
175 | |||
176 | showFull hc h@(Header t n args) = "\n-- | wrapper for "++showC h++"\n"++ boiler h ++"\n" ++showH hc h | ||
177 | |||
178 | fixmd1 = rep ("Gsl_mode_t","Precision") | ||
179 | fixmd2 = rep ("mode"," (precCode mode)") | ||
180 | |||
181 | boiler 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 | |||
185 | isMode (Normal "gsl_mode_t",_) = True | ||
186 | isMode _ = False | ||
187 | |||
188 | |||
189 | boilerResult 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 | |||
194 | boilerBasic 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 | |||
198 | boilerMode 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 @@ | |||
1 | int gsl_sf_erfc_e(double x,double* result); | ||
2 | double gsl_sf_erfc(double x); | ||
3 | int gsl_sf_log_erfc_e(double x,double* result); | ||
4 | double gsl_sf_log_erfc(double x); | ||
5 | int gsl_sf_erf_e(double x,double* result); | ||
6 | double gsl_sf_erf(double x); | ||
7 | int gsl_sf_erf_Z_e(double x,double* result); | ||
8 | int gsl_sf_erf_Q_e(double x,double* result); | ||
9 | double gsl_sf_erf_Z(double x); | ||
10 | double gsl_sf_erf_Q(double x); | ||
11 | int gsl_sf_hazard_e(double x,double* result); | ||
12 | double 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 @@ | |||
1 | int gsl_sf_lngamma_e(double x,double* result); | ||
2 | double gsl_sf_lngamma(double x); | ||
3 | int gsl_sf_lngamma_sgn_e(double x,double* result_lg,double* sgn); | ||
4 | int gsl_sf_gamma_e(double x,double* result); | ||
5 | double gsl_sf_gamma(double x); | ||
6 | int gsl_sf_gammastar_e(double x,double* result); | ||
7 | double gsl_sf_gammastar(double x); | ||
8 | int gsl_sf_gammainv_e(double x,double* result); | ||
9 | double gsl_sf_gammainv(double x); | ||
10 | int gsl_sf_lngamma_complex_e(double zr,double zi,double* lnr,double* arg); | ||
11 | int gsl_sf_taylorcoeff_e(int n,double x,double* result); | ||
12 | double gsl_sf_taylorcoeff(int n,double x); | ||
13 | int gsl_sf_fact_e(int n,double* result); | ||
14 | double gsl_sf_fact(int n); | ||
15 | int gsl_sf_doublefact_e(int n,double* result); | ||
16 | double gsl_sf_doublefact(int n); | ||
17 | int gsl_sf_lnfact_e(int n,double* result); | ||
18 | double gsl_sf_lnfact(int n); | ||
19 | int gsl_sf_lndoublefact_e(int n,double* result); | ||
20 | double gsl_sf_lndoublefact(int n); | ||
21 | int gsl_sf_lnchoose_e(int n,int m,double* result); | ||
22 | double gsl_sf_lnchoose(int n,int m); | ||
23 | int gsl_sf_choose_e(int n,int m,double* result); | ||
24 | double gsl_sf_choose(int n,int m); | ||
25 | int gsl_sf_lnpoch_e(double a,double x,double* result); | ||
26 | double gsl_sf_lnpoch(double a,double x); | ||
27 | int gsl_sf_lnpoch_sgn_e(double a,double x,double* result,double* sgn); | ||
28 | int gsl_sf_poch_e(double a,double x,double* result); | ||
29 | double gsl_sf_poch(double a,double x); | ||
30 | int gsl_sf_pochrel_e(double a,double x,double* result); | ||
31 | double gsl_sf_pochrel(double a,double x); | ||
32 | int gsl_sf_gamma_inc_Q_e(double a,double x,double* result); | ||
33 | double gsl_sf_gamma_inc_Q(double a,double x); | ||
34 | int gsl_sf_gamma_inc_P_e(double a,double x,double* result); | ||
35 | double gsl_sf_gamma_inc_P(double a,double x); | ||
36 | int gsl_sf_gamma_inc_e(double a,double x,double* result); | ||
37 | double gsl_sf_gamma_inc(double a,double x); | ||
38 | int gsl_sf_lnbeta_e(double a,double b,double* result); | ||
39 | double gsl_sf_lnbeta(double a,double b); | ||
40 | int gsl_sf_beta_e(double a,double b,double* result); | ||
41 | double gsl_sf_beta(double a,double b); | ||
42 | int gsl_sf_beta_inc_e(double a,double b,double x,double* result); | ||
43 | double gsl_sf_beta_inc(double a,double b,double x); | ||