]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_gamma_hooks.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / test_gamma_hooks.hpp
1 // (C) Copyright John Maddock 2006.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef BOOST_MATH_TEST_GAMMA_OTHER_HOOKS_HPP
7 #define BOOST_MATH_TEST_GAMMA_OTHER_HOOKS_HPP
8
9 #ifdef TEST_CEPHES
10 namespace other{
11 extern "C" {
12 double gamma(double);
13 float gammaf(float);
14 long double gammal(long double);
15 double lgam(double);
16 float lgamf(float);
17 long double lgaml(long double);
18 float igamf(float, float);
19 double igam(double, double);
20 long double igaml(long double, long double);
21 float igamcf(float, float);
22 double igamc(double, double);
23 long double igamcl(long double, long double);
24 }
25 inline float tgamma(float x)
26 { return gammaf(x); }
27 inline double tgamma(double x)
28 { return gamma(x); }
29 inline long double tgamma(long double x)
30 {
31 #ifdef _MSC_VER
32 return gamma((double)x);
33 #else
34 return gammal(x);
35 #endif
36 }
37 inline float lgamma(float x)
38 { return lgamf(x); }
39 inline double lgamma(double x)
40 { return lgam(x); }
41 inline long double lgamma(long double x)
42 {
43 #ifdef _MSC_VER
44 return lgam((double)x);
45 #else
46 return lgaml(x);
47 #endif
48 }
49 inline float gamma_q(float x, float y)
50 { return igamcf(x, y); }
51 inline double gamma_q(double x, double y)
52 { return igamc(x, y); }
53 inline long double gamma_q(long double x, long double y)
54 {
55 #ifdef _MSC_VER
56 return igamc((double)x, (double)y);
57 #else
58 return igamcl(x, y);
59 #endif
60 }
61 inline float gamma_p(float x, float y)
62 { return igamf(x, y); }
63 inline double gamma_p(double x, double y)
64 { return igam(x, y); }
65 inline long double gamma_p(long double x, long double y)
66 {
67 #ifdef _MSC_VER
68 return igam((double)x, (double)y);
69 #else
70 return igaml(x, y);
71 #endif
72 }
73 }
74 #define TEST_OTHER
75 #endif
76
77 #ifdef TEST_NATIVE
78 #include <math.h>
79 namespace other{
80 #if defined(__FreeBSD__)
81 // no float version:
82 inline float tgamma(float x)
83 { return ::tgamma(x); }
84 #else
85 inline float tgamma(float x)
86 { return ::tgammaf(x); }
87 #endif
88 inline double tgamma(double x)
89 { return ::tgamma(x); }
90 inline long double tgamma(long double x)
91 {
92 #if defined(__CYGWIN__) || defined(__FreeBSD__)
93 // no long double versions:
94 return ::tgamma(x);
95 #else
96 return ::tgammal(x);
97 #endif
98 }
99 #if defined(__FreeBSD__)
100 inline float lgamma(float x)
101 { return ::lgamma(x); }
102 #else
103 inline float lgamma(float x)
104 { return ::lgammaf(x); }
105 #endif
106 inline double lgamma(double x)
107 { return ::lgamma(x); }
108 inline long double lgamma(long double x)
109 {
110 #if defined(__CYGWIN__) || defined(__FreeBSD__)
111 // no long double versions:
112 return ::lgamma(x);
113 #else
114 return ::lgammal(x);
115 #endif
116 }
117 }
118 #define TEST_OTHER
119 #endif
120
121 #ifdef TEST_GSL
122 #define TEST_OTHER
123 #include <gsl/gsl_sf_gamma.h>
124
125 namespace other{
126 float tgamma(float z)
127 {
128 return (float)gsl_sf_gamma(z);
129 }
130 double tgamma(double z)
131 {
132 return gsl_sf_gamma(z);
133 }
134 long double tgamma(long double z)
135 {
136 return gsl_sf_gamma(z);
137 }
138 float lgamma(float z)
139 {
140 return (float)gsl_sf_lngamma(z);
141 }
142 double lgamma(double z)
143 {
144 return gsl_sf_lngamma(z);
145 }
146 long double lgamma(long double z)
147 {
148 return gsl_sf_lngamma(z);
149 }
150 inline float gamma_q(float x, float y)
151 { return (float)gsl_sf_gamma_inc_Q(x, y); }
152 inline double gamma_q(double x, double y)
153 { return gsl_sf_gamma_inc_Q(x, y); }
154 inline long double gamma_q(long double x, long double y)
155 { return gsl_sf_gamma_inc_Q(x, y); }
156 inline float gamma_p(float x, float y)
157 { return (float)gsl_sf_gamma_inc_P(x, y); }
158 inline double gamma_p(double x, double y)
159 { return gsl_sf_gamma_inc_P(x, y); }
160 inline long double gamma_p(long double x, long double y)
161 { return gsl_sf_gamma_inc_P(x, y); }
162 }
163 #endif
164
165 #ifdef TEST_DCDFLIB
166 #define TEST_OTHER
167 #include <dcdflib.h>
168
169 namespace other{
170 float tgamma(float z)
171 {
172 double v = z;
173 return (float)gamma_x(&v);
174 }
175 double tgamma(double z)
176 {
177 return gamma_x(&z);
178 }
179 long double tgamma(long double z)
180 {
181 double v = z;
182 return gamma_x(&v);
183 }
184 float lgamma(float z)
185 {
186 double v = z;
187 return (float)gamma_log(&v);
188 }
189 double lgamma(double z)
190 {
191 double v = z;
192 return gamma_log(&v);
193 }
194 long double lgamma(long double z)
195 {
196 double v = z;
197 return gamma_log(&v);
198 }
199 inline double gamma_q(double x, double y)
200 {
201 double ans, qans;
202 int i = 0;
203 gamma_inc (&x, &y, &ans, &qans, &i);
204 return qans;
205 }
206 inline float gamma_q(float x, float y)
207 {
208 return (float)gamma_q((double)x, (double)y);
209 }
210 inline long double gamma_q(long double x, long double y)
211 {
212 return gamma_q((double)x, (double)y);
213 }
214 inline double gamma_p(double x, double y)
215 {
216 double ans, qans;
217 int i = 0;
218 gamma_inc (&x, &y, &ans, &qans, &i);
219 return ans;
220 }
221 inline float gamma_p(float x, float y)
222 {
223 return (float)gamma_p((double)x, (double)y);
224 }
225 inline long double gamma_p(long double x, long double y)
226 {
227 return gamma_p((double)x, (double)y);
228 }
229
230 inline double gamma_q_inv(double x, double y)
231 {
232 double ans, p, nul;
233 int i = 0;
234 p = 1 - y;
235 nul = 0;
236 gamma_inc_inv (&x, &ans, &nul, &p, &y, &i);
237 return ans;
238 }
239 inline float gamma_q_inv(float x, float y)
240 {
241 return (float)gamma_q_inv((double)x, (double)y);
242 }
243 inline long double gamma_q_inv(long double x, long double y)
244 {
245 return gamma_q_inv((double)x, (double)y);
246 }
247 inline double gamma_p_inv(double x, double y)
248 {
249 double ans, p, nul;
250 int i = 0;
251 p = 1 - y;
252 nul = 0;
253 gamma_inc_inv (&x, &ans, &nul, &y, &p, &i);
254 return ans;
255 }
256 inline float gamma_p_inv(float x, float y)
257 {
258 return (float)gamma_p_inv((double)x, (double)y);
259 }
260 inline long double gamma_p_inv(long double x, long double y)
261 {
262 return gamma_p_inv((double)x, (double)y);
263 }
264
265 }
266 #endif
267
268 #ifdef TEST_OTHER
269 namespace other{
270 boost::math::concepts::real_concept tgamma(boost::math::concepts::real_concept){ return 0; }
271 boost::math::concepts::real_concept lgamma(boost::math::concepts::real_concept){ return 0; }
272 boost::math::concepts::real_concept gamma_q(boost::math::concepts::real_concept, boost::math::concepts::real_concept){ return 0; }
273 boost::math::concepts::real_concept gamma_p(boost::math::concepts::real_concept, boost::math::concepts::real_concept){ return 0; }
274 boost::math::concepts::real_concept gamma_p_inv(boost::math::concepts::real_concept x, boost::math::concepts::real_concept y){ return 0; }
275 boost::math::concepts::real_concept gamma_q_inv(boost::math::concepts::real_concept x, boost::math::concepts::real_concept y){ return 0; }
276 }
277 #endif
278
279 #endif
280
281