1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright Christopher Kormanyos 2014.
3 // Copyright John Maddock 2014.
4 // Copyright Paul Bristow 2014.
5 // Distributed under the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt
7 // or copy at http://www.boost.org/LICENSE_1_0.txt)
8 //
9
10 // Implement quadruple-precision <cmath> support.
11
12 #ifndef BOOST_MATH_CSTDFLOAT_CMATH_2014_02_15_HPP_
13 #define BOOST_MATH_CSTDFLOAT_CMATH_2014_02_15_HPP_
14
15 #include <boost/math/cstdfloat/cstdfloat_types.hpp>
16 #include <boost/math/cstdfloat/cstdfloat_limits.hpp>
17
18 #if defined(BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T) && defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT)
19
20 #include <cstdint>
21 #include <cmath>
22 #include <stdexcept>
23 #include <iostream>
24 #include <type_traits>
25 #include <memory>
26 #include <boost/math/tools/assert.hpp>
27 #include <boost/math/tools/throw_exception.hpp>
28
29 #if defined(_WIN32) && defined(__GNUC__)
30 // Several versions of Mingw and probably cygwin too have broken
31 // libquadmath implementations that segfault as soon as you call
32 // expq or any function that depends on it.
33 #define BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
34 #endif
35
36 // Here is a helper function used for raising the value of a given
37 // floating-point type to the power of n, where n has integral type.
38 namespace boost {
39 namespace math {
40 namespace cstdfloat {
41 namespace detail {
42
43 template<class float_type, class integer_type>
pown(const float_type & x,const integer_type p)44 inline float_type pown(const float_type& x, const integer_type p)
45 {
46 const bool isneg = (x < 0);
47 const bool isnan = (x != x);
48 const bool isinf = ((!isneg) ? bool(+x > (std::numeric_limits<float_type>::max)())
49 : bool(-x > (std::numeric_limits<float_type>::max)()));
50
51 if (isnan) { return x; }
52
53 if (isinf) { return std::numeric_limits<float_type>::quiet_NaN(); }
54
55 const bool x_is_neg = (x < 0);
56 const float_type abs_x = (x_is_neg ? -x : x);
57
58 if (p < static_cast<integer_type>(0))
59 {
60 if (abs_x < (std::numeric_limits<float_type>::min)())
61 {
62 return (x_is_neg ? -std::numeric_limits<float_type>::infinity()
63 : +std::numeric_limits<float_type>::infinity());
64 }
65 else
66 {
67 return float_type(1) / pown(x, static_cast<integer_type>(-p));
68 }
69 }
70
71 if (p == static_cast<integer_type>(0))
72 {
73 return float_type(1);
74 }
75 else
76 {
77 if (p == static_cast<integer_type>(1)) { return x; }
78
79 if (abs_x > (std::numeric_limits<float_type>::max)())
80 {
81 return (x_is_neg ? -std::numeric_limits<float_type>::infinity()
82 : +std::numeric_limits<float_type>::infinity());
83 }
84
85 if (p == static_cast<integer_type>(2)) { return (x * x); }
86 else if (p == static_cast<integer_type>(3)) { return ((x * x) * x); }
87 else if (p == static_cast<integer_type>(4)) { const float_type x2 = (x * x); return (x2 * x2); }
88 else
89 {
90 // The variable xn stores the binary powers of x.
91 float_type result(((p % integer_type(2)) != integer_type(0)) ? x : float_type(1));
92 float_type xn(x);
93
94 integer_type p2 = p;
95
96 while (integer_type(p2 /= 2) != integer_type(0))
97 {
98 // Square xn for each binary power.
99 xn *= xn;
100
101 const bool has_binary_power = (integer_type(p2 % integer_type(2)) != integer_type(0));
102
103 if (has_binary_power)
104 {
105 // Multiply the result with each binary power contained in the exponent.
106 result *= xn;
107 }
108 }
109
110 return result;
111 }
112 }
113 }
114
115 }
116 }
117 }
118 } // boost::math::cstdfloat::detail
119
120 // We will now define preprocessor symbols representing quadruple-precision <cmath> functions.
121 #if defined(__INTEL_COMPILER)
122 #define BOOST_CSTDFLOAT_FLOAT128_LDEXP __ldexpq
123 #define BOOST_CSTDFLOAT_FLOAT128_FREXP __frexpq
124 #define BOOST_CSTDFLOAT_FLOAT128_FABS __fabsq
125 #define BOOST_CSTDFLOAT_FLOAT128_FLOOR __floorq
126 #define BOOST_CSTDFLOAT_FLOAT128_CEIL __ceilq
127 #if !defined(BOOST_CSTDFLOAT_FLOAT128_SQRT)
128 #define BOOST_CSTDFLOAT_FLOAT128_SQRT __sqrtq
129 #endif
130 #define BOOST_CSTDFLOAT_FLOAT128_TRUNC __truncq
131 #define BOOST_CSTDFLOAT_FLOAT128_EXP __expq
132 #define BOOST_CSTDFLOAT_FLOAT128_EXPM1 __expm1q
133 #define BOOST_CSTDFLOAT_FLOAT128_POW __powq
134 #define BOOST_CSTDFLOAT_FLOAT128_LOG __logq
135 #define BOOST_CSTDFLOAT_FLOAT128_LOG10 __log10q
136 #define BOOST_CSTDFLOAT_FLOAT128_SIN __sinq
137 #define BOOST_CSTDFLOAT_FLOAT128_COS __cosq
138 #define BOOST_CSTDFLOAT_FLOAT128_TAN __tanq
139 #define BOOST_CSTDFLOAT_FLOAT128_ASIN __asinq
140 #define BOOST_CSTDFLOAT_FLOAT128_ACOS __acosq
141 #define BOOST_CSTDFLOAT_FLOAT128_ATAN __atanq
142 #define BOOST_CSTDFLOAT_FLOAT128_SINH __sinhq
143 #define BOOST_CSTDFLOAT_FLOAT128_COSH __coshq
144 #define BOOST_CSTDFLOAT_FLOAT128_TANH __tanhq
145 #define BOOST_CSTDFLOAT_FLOAT128_ASINH __asinhq
146 #define BOOST_CSTDFLOAT_FLOAT128_ACOSH __acoshq
147 #define BOOST_CSTDFLOAT_FLOAT128_ATANH __atanhq
148 #define BOOST_CSTDFLOAT_FLOAT128_FMOD __fmodq
149 #define BOOST_CSTDFLOAT_FLOAT128_ATAN2 __atan2q
150 #define BOOST_CSTDFLOAT_FLOAT128_LGAMMA __lgammaq
151 #define BOOST_CSTDFLOAT_FLOAT128_TGAMMA __tgammaq
152 // begin more functions
153 #define BOOST_CSTDFLOAT_FLOAT128_REMAINDER __remainderq
154 #define BOOST_CSTDFLOAT_FLOAT128_REMQUO __remquoq
155 #define BOOST_CSTDFLOAT_FLOAT128_FMA __fmaq
156 #define BOOST_CSTDFLOAT_FLOAT128_FMAX __fmaxq
157 #define BOOST_CSTDFLOAT_FLOAT128_FMIN __fminq
158 #define BOOST_CSTDFLOAT_FLOAT128_FDIM __fdimq
159 #define BOOST_CSTDFLOAT_FLOAT128_NAN __nanq
160 //#define BOOST_CSTDFLOAT_FLOAT128_EXP2 __exp2q
161 #define BOOST_CSTDFLOAT_FLOAT128_LOG2 __log2q
162 #define BOOST_CSTDFLOAT_FLOAT128_LOG1P __log1pq
163 #define BOOST_CSTDFLOAT_FLOAT128_CBRT __cbrtq
164 #define BOOST_CSTDFLOAT_FLOAT128_HYPOT __hypotq
165 #define BOOST_CSTDFLOAT_FLOAT128_ERF __erfq
166 #define BOOST_CSTDFLOAT_FLOAT128_ERFC __erfcq
167 #define BOOST_CSTDFLOAT_FLOAT128_LLROUND __llroundq
168 #define BOOST_CSTDFLOAT_FLOAT128_LROUND __lroundq
169 #define BOOST_CSTDFLOAT_FLOAT128_ROUND __roundq
170 #define BOOST_CSTDFLOAT_FLOAT128_NEARBYINT __nearbyintq
171 #define BOOST_CSTDFLOAT_FLOAT128_LLRINT __llrintq
172 #define BOOST_CSTDFLOAT_FLOAT128_LRINT __lrintq
173 #define BOOST_CSTDFLOAT_FLOAT128_RINT __rintq
174 #define BOOST_CSTDFLOAT_FLOAT128_MODF __modfq
175 #define BOOST_CSTDFLOAT_FLOAT128_SCALBLN __scalblnq
176 #define BOOST_CSTDFLOAT_FLOAT128_SCALBN __scalbnq
177 #define BOOST_CSTDFLOAT_FLOAT128_ILOGB __ilogbq
178 #define BOOST_CSTDFLOAT_FLOAT128_LOGB __logbq
179 #define BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER __nextafterq
180 //#define BOOST_CSTDFLOAT_FLOAT128_NEXTTOWARD __nexttowardq
181 #define BOOST_CSTDFLOAT_FLOAT128_COPYSIGN __copysignq
182 #define BOOST_CSTDFLOAT_FLOAT128_SIGNBIT __signbitq
183 //#define BOOST_CSTDFLOAT_FLOAT128_FPCLASSIFY __fpclassifyq
184 //#define BOOST_CSTDFLOAT_FLOAT128_ISFINITE __isfiniteq
185 #define BOOST_CSTDFLOAT_FLOAT128_ISINF __isinfq
186 #define BOOST_CSTDFLOAT_FLOAT128_ISNAN __isnanq
187 //#define BOOST_CSTDFLOAT_FLOAT128_ISNORMAL __isnormalq
188 //#define BOOST_CSTDFLOAT_FLOAT128_ISGREATER __isgreaterq
189 //#define BOOST_CSTDFLOAT_FLOAT128_ISGREATEREQUAL __isgreaterequalq
190 //#define BOOST_CSTDFLOAT_FLOAT128_ISLESS __islessq
191 //#define BOOST_CSTDFLOAT_FLOAT128_ISLESSEQUAL __islessequalq
192 //#define BOOST_CSTDFLOAT_FLOAT128_ISLESSGREATER __islessgreaterq
193 //#define BOOST_CSTDFLOAT_FLOAT128_ISUNORDERED __isunorderedq
194 // end more functions
195 #elif defined(__GNUC__)
196 #define BOOST_CSTDFLOAT_FLOAT128_LDEXP ldexpq
197 #define BOOST_CSTDFLOAT_FLOAT128_FREXP frexpq
198 #define BOOST_CSTDFLOAT_FLOAT128_FABS fabsq
199 #define BOOST_CSTDFLOAT_FLOAT128_FLOOR floorq
200 #define BOOST_CSTDFLOAT_FLOAT128_CEIL ceilq
201 #if !defined(BOOST_CSTDFLOAT_FLOAT128_SQRT)
202 #define BOOST_CSTDFLOAT_FLOAT128_SQRT sqrtq
203 #endif
204 #define BOOST_CSTDFLOAT_FLOAT128_TRUNC truncq
205 #define BOOST_CSTDFLOAT_FLOAT128_POW powq
206 #define BOOST_CSTDFLOAT_FLOAT128_LOG logq
207 #define BOOST_CSTDFLOAT_FLOAT128_LOG10 log10q
208 #define BOOST_CSTDFLOAT_FLOAT128_SIN sinq
209 #define BOOST_CSTDFLOAT_FLOAT128_COS cosq
210 #define BOOST_CSTDFLOAT_FLOAT128_TAN tanq
211 #define BOOST_CSTDFLOAT_FLOAT128_ASIN asinq
212 #define BOOST_CSTDFLOAT_FLOAT128_ACOS acosq
213 #define BOOST_CSTDFLOAT_FLOAT128_ATAN atanq
214 #define BOOST_CSTDFLOAT_FLOAT128_FMOD fmodq
215 #define BOOST_CSTDFLOAT_FLOAT128_ATAN2 atan2q
216 #define BOOST_CSTDFLOAT_FLOAT128_LGAMMA lgammaq
217 #if !defined(BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS)
218 #define BOOST_CSTDFLOAT_FLOAT128_EXP expq
219 #define BOOST_CSTDFLOAT_FLOAT128_EXPM1 expm1q
220 #define BOOST_CSTDFLOAT_FLOAT128_SINH sinhq
221 #define BOOST_CSTDFLOAT_FLOAT128_COSH coshq
222 #define BOOST_CSTDFLOAT_FLOAT128_TANH tanhq
223 #define BOOST_CSTDFLOAT_FLOAT128_ASINH asinhq
224 #define BOOST_CSTDFLOAT_FLOAT128_ACOSH acoshq
225 #define BOOST_CSTDFLOAT_FLOAT128_ATANH atanhq
226 #define BOOST_CSTDFLOAT_FLOAT128_TGAMMA tgammaq
227 #else // BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
228 #define BOOST_CSTDFLOAT_FLOAT128_EXP expq_patch
229 #define BOOST_CSTDFLOAT_FLOAT128_SINH sinhq_patch
230 #define BOOST_CSTDFLOAT_FLOAT128_COSH coshq_patch
231 #define BOOST_CSTDFLOAT_FLOAT128_TANH tanhq_patch
232 #define BOOST_CSTDFLOAT_FLOAT128_ASINH asinhq_patch
233 #define BOOST_CSTDFLOAT_FLOAT128_ACOSH acoshq_patch
234 #define BOOST_CSTDFLOAT_FLOAT128_ATANH atanhq_patch
235 #define BOOST_CSTDFLOAT_FLOAT128_TGAMMA tgammaq_patch
236 #endif // BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
237 // begin more functions
238 #define BOOST_CSTDFLOAT_FLOAT128_REMAINDER remainderq
239 #define BOOST_CSTDFLOAT_FLOAT128_REMQUO remquoq
240 #define BOOST_CSTDFLOAT_FLOAT128_FMA fmaq
241 #define BOOST_CSTDFLOAT_FLOAT128_FMAX fmaxq
242 #define BOOST_CSTDFLOAT_FLOAT128_FMIN fminq
243 #define BOOST_CSTDFLOAT_FLOAT128_FDIM fdimq
244 #define BOOST_CSTDFLOAT_FLOAT128_NAN nanq
245 //#define BOOST_CSTDFLOAT_FLOAT128_EXP2 exp2q
246 #define BOOST_CSTDFLOAT_FLOAT128_LOG2 log2q
247 #define BOOST_CSTDFLOAT_FLOAT128_LOG1P log1pq
248 #define BOOST_CSTDFLOAT_FLOAT128_CBRT cbrtq
249 #define BOOST_CSTDFLOAT_FLOAT128_HYPOT hypotq
250 #define BOOST_CSTDFLOAT_FLOAT128_ERF erfq
251 #define BOOST_CSTDFLOAT_FLOAT128_ERFC erfcq
252 #define BOOST_CSTDFLOAT_FLOAT128_LLROUND llroundq
253 #define BOOST_CSTDFLOAT_FLOAT128_LROUND lroundq
254 #define BOOST_CSTDFLOAT_FLOAT128_ROUND roundq
255 #define BOOST_CSTDFLOAT_FLOAT128_NEARBYINT nearbyintq
256 #define BOOST_CSTDFLOAT_FLOAT128_LLRINT llrintq
257 #define BOOST_CSTDFLOAT_FLOAT128_LRINT lrintq
258 #define BOOST_CSTDFLOAT_FLOAT128_RINT rintq
259 #define BOOST_CSTDFLOAT_FLOAT128_MODF modfq
260 #define BOOST_CSTDFLOAT_FLOAT128_SCALBLN scalblnq
261 #define BOOST_CSTDFLOAT_FLOAT128_SCALBN scalbnq
262 #define BOOST_CSTDFLOAT_FLOAT128_ILOGB ilogbq
263 #define BOOST_CSTDFLOAT_FLOAT128_LOGB logbq
264 #define BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER nextafterq
265 //#define BOOST_CSTDFLOAT_FLOAT128_NEXTTOWARD nexttowardq
266 #define BOOST_CSTDFLOAT_FLOAT128_COPYSIGN copysignq
267 #define BOOST_CSTDFLOAT_FLOAT128_SIGNBIT signbitq
268 //#define BOOST_CSTDFLOAT_FLOAT128_FPCLASSIFY fpclassifyq
269 //#define BOOST_CSTDFLOAT_FLOAT128_ISFINITE isfiniteq
270 #define BOOST_CSTDFLOAT_FLOAT128_ISINF isinfq
271 #define BOOST_CSTDFLOAT_FLOAT128_ISNAN isnanq
272 //#define BOOST_CSTDFLOAT_FLOAT128_ISNORMAL isnormalq
273 //#define BOOST_CSTDFLOAT_FLOAT128_ISGREATER isgreaterq
274 //#define BOOST_CSTDFLOAT_FLOAT128_ISGREATEREQUAL isgreaterequalq
275 //#define BOOST_CSTDFLOAT_FLOAT128_ISLESS islessq
276 //#define BOOST_CSTDFLOAT_FLOAT128_ISLESSEQUAL islessequalq
277 //#define BOOST_CSTDFLOAT_FLOAT128_ISLESSGREATER islessgreaterq
278 //#define BOOST_CSTDFLOAT_FLOAT128_ISUNORDERED isunorderedq
279 // end more functions
280 #endif
281
282 // Implement quadruple-precision <cmath> functions in the namespace
283 // boost::math::cstdfloat::detail. Subsequently inject these into the
284 // std namespace via *using* directive.
285
286 // Begin with some forward function declarations. Also implement patches
287 // for compilers that have broken float128 exponential functions.
288
289 extern "C" int quadmath_snprintf(char*, std::size_t, const char*, ...) throw();
290
291 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LDEXP(boost::math::cstdfloat::detail::float_internal128_t, int) throw();
292 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FREXP(boost::math::cstdfloat::detail::float_internal128_t, int*) throw();
293 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FABS(boost::math::cstdfloat::detail::float_internal128_t) throw();
294 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FLOOR(boost::math::cstdfloat::detail::float_internal128_t) throw();
295 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_CEIL(boost::math::cstdfloat::detail::float_internal128_t) throw();
296 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SQRT(boost::math::cstdfloat::detail::float_internal128_t) throw();
297 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TRUNC(boost::math::cstdfloat::detail::float_internal128_t) throw();
298 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_POW(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
299 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LOG(boost::math::cstdfloat::detail::float_internal128_t) throw();
300 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LOG10(boost::math::cstdfloat::detail::float_internal128_t) throw();
301 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SIN(boost::math::cstdfloat::detail::float_internal128_t) throw();
302 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_COS(boost::math::cstdfloat::detail::float_internal128_t) throw();
303 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TAN(boost::math::cstdfloat::detail::float_internal128_t) throw();
304 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ASIN(boost::math::cstdfloat::detail::float_internal128_t) throw();
305 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ACOS(boost::math::cstdfloat::detail::float_internal128_t) throw();
306 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATAN(boost::math::cstdfloat::detail::float_internal128_t) throw();
307 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FMOD(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
308 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATAN2(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
309 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LGAMMA(boost::math::cstdfloat::detail::float_internal128_t) throw();
310
311 // begin more functions
312 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_REMAINDER(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
313 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_REMQUO(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t, int*) throw();
314 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FMA(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
315 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FMAX(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
316 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FMIN(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
317 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_FDIM(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
318 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_NAN(const char*) throw();
319 //extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_EXP2 (boost::math::cstdfloat::detail::float_internal128_t) throw();
320 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LOG2(boost::math::cstdfloat::detail::float_internal128_t) throw();
321 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LOG1P(boost::math::cstdfloat::detail::float_internal128_t) throw();
322 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_CBRT(boost::math::cstdfloat::detail::float_internal128_t) throw();
323 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_HYPOT(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
324 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ERF(boost::math::cstdfloat::detail::float_internal128_t) throw();
325 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ERFC(boost::math::cstdfloat::detail::float_internal128_t) throw();
326 extern "C" long long int BOOST_CSTDFLOAT_FLOAT128_LLROUND(boost::math::cstdfloat::detail::float_internal128_t) throw();
327 extern "C" long int BOOST_CSTDFLOAT_FLOAT128_LROUND(boost::math::cstdfloat::detail::float_internal128_t) throw();
328 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ROUND(boost::math::cstdfloat::detail::float_internal128_t) throw();
329 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_NEARBYINT(boost::math::cstdfloat::detail::float_internal128_t) throw();
330 extern "C" long long int BOOST_CSTDFLOAT_FLOAT128_LLRINT(boost::math::cstdfloat::detail::float_internal128_t) throw();
331 extern "C" long int BOOST_CSTDFLOAT_FLOAT128_LRINT(boost::math::cstdfloat::detail::float_internal128_t) throw();
332 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_RINT(boost::math::cstdfloat::detail::float_internal128_t) throw();
333 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_MODF(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t*) throw();
334 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SCALBLN(boost::math::cstdfloat::detail::float_internal128_t, long int) throw();
335 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SCALBN(boost::math::cstdfloat::detail::float_internal128_t, int) throw();
336 extern "C" int BOOST_CSTDFLOAT_FLOAT128_ILOGB(boost::math::cstdfloat::detail::float_internal128_t) throw();
337 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_LOGB(boost::math::cstdfloat::detail::float_internal128_t) throw();
338 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
339 //extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_NEXTTOWARD (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
340 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_COPYSIGN(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
341 extern "C" int BOOST_CSTDFLOAT_FLOAT128_SIGNBIT(boost::math::cstdfloat::detail::float_internal128_t) throw();
342 //extern "C" int BOOST_CSTDFLOAT_FLOAT128_FPCLASSIFY (boost::math::cstdfloat::detail::float_internal128_t) throw();
343 //extern "C" int BOOST_CSTDFLOAT_FLOAT128_ISFINITE (boost::math::cstdfloat::detail::float_internal128_t) throw();
344 extern "C" int BOOST_CSTDFLOAT_FLOAT128_ISINF(boost::math::cstdfloat::detail::float_internal128_t) throw();
345 extern "C" int BOOST_CSTDFLOAT_FLOAT128_ISNAN(boost::math::cstdfloat::detail::float_internal128_t) throw();
346 //extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ISNORMAL (boost::math::cstdfloat::detail::float_internal128_t) throw();
347 //extern "C" int BOOST_CSTDFLOAT_FLOAT128_ISGREATER (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
348 //extern "C" int BOOST_CSTDFLOAT_FLOAT128_ISGREATEREQUAL(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
349 //extern "C" int BOOST_CSTDFLOAT_FLOAT128_ISLESS (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
350 //extern "C" int BOOST_CSTDFLOAT_FLOAT128_ISLESSEQUAL (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
351 //extern "C" int BOOST_CSTDFLOAT_FLOAT128_ISLESSGREATER(boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
352 //extern "C" int BOOST_CSTDFLOAT_FLOAT128_ISUNORDERED (boost::math::cstdfloat::detail::float_internal128_t, boost::math::cstdfloat::detail::float_internal128_t) throw();
353 // end more functions
354
355 #if !defined(BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS)
356
357 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_EXP(boost::math::cstdfloat::detail::float_internal128_t x) throw();
358 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_EXPM1(boost::math::cstdfloat::detail::float_internal128_t x) throw();
359 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SINH(boost::math::cstdfloat::detail::float_internal128_t x) throw();
360 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_COSH(boost::math::cstdfloat::detail::float_internal128_t x) throw();
361 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TANH(boost::math::cstdfloat::detail::float_internal128_t x) throw();
362 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ASINH(boost::math::cstdfloat::detail::float_internal128_t x) throw();
363 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ACOSH(boost::math::cstdfloat::detail::float_internal128_t x) throw();
364 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATANH(boost::math::cstdfloat::detail::float_internal128_t x) throw();
365 extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TGAMMA(boost::math::cstdfloat::detail::float_internal128_t x) throw();
366
367 #else // BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
368
369 // Forward declaration of the patched exponent function, exp(x).
370 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_EXP(boost::math::cstdfloat::detail::float_internal128_t x);
371
BOOST_CSTDFLOAT_FLOAT128_EXPM1(boost::math::cstdfloat::detail::float_internal128_t x)372 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_EXPM1(boost::math::cstdfloat::detail::float_internal128_t x)
373 {
374 // Compute exp(x) - 1 for x small.
375
376 // Use an order-12 Pade approximation of the exponential function.
377 // PadeApproximant[Exp[x] - 1, {x, 0, 12, 12}].
378
379 typedef boost::math::cstdfloat::detail::float_internal128_t float_type;
380
381 float_type sum;
382
383 if (x > BOOST_FLOAT128_C(0.693147180559945309417232121458176568075500134360255))
384 {
385 sum = ::BOOST_CSTDFLOAT_FLOAT128_EXP(x) - float_type(1);
386 }
387 else
388 {
389 const float_type x2 = (x * x);
390
391 const float_type top = ((((( float_type(BOOST_FLOAT128_C(2.4087176110456818621091195109360728010934088788572E-13)) * x2
392 + float_type(BOOST_FLOAT128_C(9.2735628025258751691201101171038802842096241836000E-10))) * x2
393 + float_type(BOOST_FLOAT128_C(9.0806726962333369656024118266681195742980640005812E-07))) * x2
394 + float_type(BOOST_FLOAT128_C(3.1055900621118012422360248447204968944099378881988E-04))) * x2
395 + float_type(BOOST_FLOAT128_C(3.6231884057971014492753623188405797101449275362319E-02))) * x2
396 + float_type(BOOST_FLOAT128_C(1.00000000000000000000000000000000000000000000000000000)))
397 ;
398
399 const float_type bot = (((((((((((( float_type(BOOST_FLOAT128_C(+7.7202487533515444298369215094104897470942592271063E-16)) * x
400 + float_type(BOOST_FLOAT128_C(-1.2043588055228409310545597554680364005467044394286E-13))) * x
401 + float_type(BOOST_FLOAT128_C(+9.2735628025258751691201101171038802842096241836000E-12))) * x
402 + float_type(BOOST_FLOAT128_C(-4.6367814012629375845600550585519401421048120918000E-10))) * x
403 + float_type(BOOST_FLOAT128_C(+1.6692413044546575304416198210786984511577323530480E-08))) * x
404 + float_type(BOOST_FLOAT128_C(-4.5403363481166684828012059133340597871490320002906E-07))) * x
405 + float_type(BOOST_FLOAT128_C(+9.5347063310450038138825324180015255530129672006102E-06))) * x
406 + float_type(BOOST_FLOAT128_C(-1.5527950310559006211180124223602484472049689440994E-04))) * x
407 + float_type(BOOST_FLOAT128_C(+1.9409937888198757763975155279503105590062111801242E-03))) * x
408 + float_type(BOOST_FLOAT128_C(-1.8115942028985507246376811594202898550724637681159E-02))) * x
409 + float_type(BOOST_FLOAT128_C(+1.1956521739130434782608695652173913043478260869565E-01))) * x
410 + float_type(BOOST_FLOAT128_C(-0.50000000000000000000000000000000000000000000000000000))) * x
411 + float_type(BOOST_FLOAT128_C(+1.00000000000000000000000000000000000000000000000000000)))
412 ;
413
414 sum = (x * top) / bot;
415 }
416
417 return sum;
418 }
BOOST_CSTDFLOAT_FLOAT128_EXP(boost::math::cstdfloat::detail::float_internal128_t x)419 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_EXP(boost::math::cstdfloat::detail::float_internal128_t x)
420 {
421 // Patch the expq() function for a subset of broken GCC compilers
422 // like GCC 4.7, 4.8 on MinGW.
423
424 typedef boost::math::cstdfloat::detail::float_internal128_t float_type;
425
426 // Scale the argument x to the range (-ln2 < x < ln2).
427 constexpr float_type one_over_ln2 = float_type(BOOST_FLOAT128_C(1.44269504088896340735992468100189213742664595415299));
428 const float_type x_over_ln2 = x * one_over_ln2;
429
430 int n;
431
432 if (x != x)
433 {
434 // The argument is NaN.
435 return std::numeric_limits<float_type>::quiet_NaN();
436 }
437 else if (::BOOST_CSTDFLOAT_FLOAT128_FABS(x) > BOOST_FLOAT128_C(+0.693147180559945309417232121458176568075500134360255))
438 {
439 // The absolute value of the argument exceeds ln2.
440 n = static_cast<int>(::BOOST_CSTDFLOAT_FLOAT128_FLOOR(x_over_ln2));
441 }
442 else if (::BOOST_CSTDFLOAT_FLOAT128_FABS(x) < BOOST_FLOAT128_C(+0.693147180559945309417232121458176568075500134360255))
443 {
444 // The absolute value of the argument is less than ln2.
445 n = 0;
446 }
447 else
448 {
449 // The absolute value of the argument is exactly equal to ln2 (in the sense of floating-point equality).
450 return float_type(2);
451 }
452
453 // Check if the argument is very near an integer.
454 const float_type floor_of_x = ::BOOST_CSTDFLOAT_FLOAT128_FLOOR(x);
455
456 if (::BOOST_CSTDFLOAT_FLOAT128_FABS(x - floor_of_x) < float_type(BOOST_CSTDFLOAT_FLOAT128_EPS))
457 {
458 // Return e^n for arguments very near an integer.
459 return boost::math::cstdfloat::detail::pown(BOOST_FLOAT128_C(2.71828182845904523536028747135266249775724709369996), static_cast<std::int_fast32_t>(floor_of_x));
460 }
461
462 // Compute the scaled argument alpha.
463 const float_type alpha = x - (n * BOOST_FLOAT128_C(0.693147180559945309417232121458176568075500134360255));
464
465 // Compute the polynomial approximation of expm1(alpha) and add to it
466 // in order to obtain the scaled result.
467 const float_type scaled_result = ::BOOST_CSTDFLOAT_FLOAT128_EXPM1(alpha) + float_type(1);
468
469 // Rescale the result and return it.
470 return scaled_result * boost::math::cstdfloat::detail::pown(float_type(2), n);
471 }
BOOST_CSTDFLOAT_FLOAT128_SINH(boost::math::cstdfloat::detail::float_internal128_t x)472 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SINH(boost::math::cstdfloat::detail::float_internal128_t x)
473 {
474 // Patch the sinhq() function for a subset of broken GCC compilers
475 // like GCC 4.7, 4.8 on MinGW.
476 typedef boost::math::cstdfloat::detail::float_internal128_t float_type;
477
478 // Here, we use the following:
479 // Set: ex = exp(x)
480 // Set: em1 = expm1(x)
481 // Then
482 // sinh(x) = (ex - 1/ex) / 2 ; for |x| >= 1
483 // sinh(x) = (2em1 + em1^2) / (2ex) ; for |x| < 1
484
485 const float_type ex = ::BOOST_CSTDFLOAT_FLOAT128_EXP(x);
486
487 if (::BOOST_CSTDFLOAT_FLOAT128_FABS(x) < float_type(+1))
488 {
489 const float_type em1 = ::BOOST_CSTDFLOAT_FLOAT128_EXPM1(x);
490
491 return ((em1 * 2) + (em1 * em1)) / (ex * 2);
492 }
493 else
494 {
495 return (ex - (float_type(1) / ex)) / 2;
496 }
497 }
BOOST_CSTDFLOAT_FLOAT128_COSH(boost::math::cstdfloat::detail::float_internal128_t x)498 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_COSH(boost::math::cstdfloat::detail::float_internal128_t x)
499 {
500 // Patch the coshq() function for a subset of broken GCC compilers
501 // like GCC 4.7, 4.8 on MinGW.
502 typedef boost::math::cstdfloat::detail::float_internal128_t float_type;
503 const float_type ex = ::BOOST_CSTDFLOAT_FLOAT128_EXP(x);
504 return (ex + (float_type(1) / ex)) / 2;
505 }
BOOST_CSTDFLOAT_FLOAT128_TANH(boost::math::cstdfloat::detail::float_internal128_t x)506 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TANH(boost::math::cstdfloat::detail::float_internal128_t x)
507 {
508 // Patch the tanhq() function for a subset of broken GCC compilers
509 // like GCC 4.7, 4.8 on MinGW.
510 typedef boost::math::cstdfloat::detail::float_internal128_t float_type;
511 const float_type ex_plus = ::BOOST_CSTDFLOAT_FLOAT128_EXP(x);
512 const float_type ex_minus = (float_type(1) / ex_plus);
513 return (ex_plus - ex_minus) / (ex_plus + ex_minus);
514 }
BOOST_CSTDFLOAT_FLOAT128_ASINH(boost::math::cstdfloat::detail::float_internal128_t x)515 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ASINH(boost::math::cstdfloat::detail::float_internal128_t x) throw()
516 {
517 // Patch the asinh() function since quadmath does not have it.
518 typedef boost::math::cstdfloat::detail::float_internal128_t float_type;
519 return ::BOOST_CSTDFLOAT_FLOAT128_LOG(x + ::BOOST_CSTDFLOAT_FLOAT128_SQRT((x * x) + float_type(1)));
520 }
BOOST_CSTDFLOAT_FLOAT128_ACOSH(boost::math::cstdfloat::detail::float_internal128_t x)521 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ACOSH(boost::math::cstdfloat::detail::float_internal128_t x) throw()
522 {
523 // Patch the acosh() function since quadmath does not have it.
524 typedef boost::math::cstdfloat::detail::float_internal128_t float_type;
525 const float_type zp(x + float_type(1));
526 const float_type zm(x - float_type(1));
527
528 return ::BOOST_CSTDFLOAT_FLOAT128_LOG(x + (zp * ::BOOST_CSTDFLOAT_FLOAT128_SQRT(zm / zp)));
529 }
BOOST_CSTDFLOAT_FLOAT128_ATANH(boost::math::cstdfloat::detail::float_internal128_t x)530 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_ATANH(boost::math::cstdfloat::detail::float_internal128_t x) throw()
531 {
532 // Patch the atanh() function since quadmath does not have it.
533 typedef boost::math::cstdfloat::detail::float_internal128_t float_type;
534 return (::BOOST_CSTDFLOAT_FLOAT128_LOG(float_type(1) + x)
535 - ::BOOST_CSTDFLOAT_FLOAT128_LOG(float_type(1) - x)) / 2;
536 }
BOOST_CSTDFLOAT_FLOAT128_TGAMMA(boost::math::cstdfloat::detail::float_internal128_t x)537 inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_TGAMMA(boost::math::cstdfloat::detail::float_internal128_t x) throw()
538 {
539 // Patch the tgammaq() function for a subset of broken GCC compilers
540 // like GCC 4.7, 4.8 on MinGW.
541 typedef boost::math::cstdfloat::detail::float_internal128_t float_type;
542
543 if (x > float_type(0))
544 {
545 return ::BOOST_CSTDFLOAT_FLOAT128_EXP(::BOOST_CSTDFLOAT_FLOAT128_LGAMMA(x));
546 }
547 else if (x < float_type(0))
548 {
549 // For x < 0, compute tgamma(-x) and use the reflection formula.
550 const float_type positive_x = -x;
551 float_type gamma_value = ::BOOST_CSTDFLOAT_FLOAT128_TGAMMA(positive_x);
552 const float_type floor_of_positive_x = ::BOOST_CSTDFLOAT_FLOAT128_FLOOR(positive_x);
553
554 // Take the reflection checks (slightly adapted) from <boost/math/gamma.hpp>.
555 const bool floor_of_z_is_equal_to_z = (positive_x == ::BOOST_CSTDFLOAT_FLOAT128_FLOOR(positive_x));
556
557 constexpr float_type my_pi = BOOST_FLOAT128_C(3.14159265358979323846264338327950288419716939937511);
558
559 if (floor_of_z_is_equal_to_z)
560 {
561 const bool is_odd = ((std::int32_t(floor_of_positive_x) % std::int32_t(2)) != std::int32_t(0));
562
563 return (is_odd ? -std::numeric_limits<float_type>::infinity()
564 : +std::numeric_limits<float_type>::infinity());
565 }
566
567 const float_type sinpx_value = x * ::BOOST_CSTDFLOAT_FLOAT128_SIN(my_pi * x);
568
569 gamma_value *= sinpx_value;
570
571 const bool result_is_too_large_to_represent = ((::BOOST_CSTDFLOAT_FLOAT128_FABS(gamma_value) < float_type(1))
572 && (((std::numeric_limits<float_type>::max)() * ::BOOST_CSTDFLOAT_FLOAT128_FABS(gamma_value)) < my_pi));
573
574 if (result_is_too_large_to_represent)
575 {
576 const bool is_odd = ((std::int32_t(floor_of_positive_x) % std::int32_t(2)) != std::int32_t(0));
577
578 return (is_odd ? -std::numeric_limits<float_type>::infinity()
579 : +std::numeric_limits<float_type>::infinity());
580 }
581
582 gamma_value = -my_pi / gamma_value;
583
584 if ((gamma_value > float_type(0)) || (gamma_value < float_type(0)))
585 {
586 return gamma_value;
587 }
588 else
589 {
590 // The value of gamma is too small to represent. Return 0.0 here.
591 return float_type(0);
592 }
593 }
594 else
595 {
596 // Gamma of zero is complex infinity. Return NaN here.
597 return std::numeric_limits<float_type>::quiet_NaN();
598 }
599 }
600 #endif // BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
601
602 // Define the quadruple-precision <cmath> functions in the namespace boost::math::cstdfloat::detail.
603
604 namespace boost {
605 namespace math {
606 namespace cstdfloat {
607 namespace detail {
ldexp(boost::math::cstdfloat::detail::float_internal128_t x,int n)608 inline boost::math::cstdfloat::detail::float_internal128_t ldexp(boost::math::cstdfloat::detail::float_internal128_t x, int n) { return ::BOOST_CSTDFLOAT_FLOAT128_LDEXP(x, n); }
frexp(boost::math::cstdfloat::detail::float_internal128_t x,int * pn)609 inline boost::math::cstdfloat::detail::float_internal128_t frexp(boost::math::cstdfloat::detail::float_internal128_t x, int* pn) { return ::BOOST_CSTDFLOAT_FLOAT128_FREXP(x, pn); }
fabs(boost::math::cstdfloat::detail::float_internal128_t x)610 inline boost::math::cstdfloat::detail::float_internal128_t fabs(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_FABS(x); }
abs(boost::math::cstdfloat::detail::float_internal128_t x)611 inline boost::math::cstdfloat::detail::float_internal128_t abs(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_FABS(x); }
floor(boost::math::cstdfloat::detail::float_internal128_t x)612 inline boost::math::cstdfloat::detail::float_internal128_t floor(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_FLOOR(x); }
ceil(boost::math::cstdfloat::detail::float_internal128_t x)613 inline boost::math::cstdfloat::detail::float_internal128_t ceil(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_CEIL(x); }
sqrt(boost::math::cstdfloat::detail::float_internal128_t x)614 inline boost::math::cstdfloat::detail::float_internal128_t sqrt(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_SQRT(x); }
trunc(boost::math::cstdfloat::detail::float_internal128_t x)615 inline boost::math::cstdfloat::detail::float_internal128_t trunc(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_TRUNC(x); }
exp(boost::math::cstdfloat::detail::float_internal128_t x)616 inline boost::math::cstdfloat::detail::float_internal128_t exp(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_EXP(x); }
expm1(boost::math::cstdfloat::detail::float_internal128_t x)617 inline boost::math::cstdfloat::detail::float_internal128_t expm1(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_EXPM1(x); }
pow(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t a)618 inline boost::math::cstdfloat::detail::float_internal128_t pow(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t a) { return ::BOOST_CSTDFLOAT_FLOAT128_POW(x, a); }
pow(boost::math::cstdfloat::detail::float_internal128_t x,int a)619 inline boost::math::cstdfloat::detail::float_internal128_t pow(boost::math::cstdfloat::detail::float_internal128_t x, int a) { return ::BOOST_CSTDFLOAT_FLOAT128_POW(x, boost::math::cstdfloat::detail::float_internal128_t(a)); }
log(boost::math::cstdfloat::detail::float_internal128_t x)620 inline boost::math::cstdfloat::detail::float_internal128_t log(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LOG(x); }
log10(boost::math::cstdfloat::detail::float_internal128_t x)621 inline boost::math::cstdfloat::detail::float_internal128_t log10(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LOG10(x); }
sin(boost::math::cstdfloat::detail::float_internal128_t x)622 inline boost::math::cstdfloat::detail::float_internal128_t sin(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_SIN(x); }
cos(boost::math::cstdfloat::detail::float_internal128_t x)623 inline boost::math::cstdfloat::detail::float_internal128_t cos(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_COS(x); }
tan(boost::math::cstdfloat::detail::float_internal128_t x)624 inline boost::math::cstdfloat::detail::float_internal128_t tan(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_TAN(x); }
asin(boost::math::cstdfloat::detail::float_internal128_t x)625 inline boost::math::cstdfloat::detail::float_internal128_t asin(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ASIN(x); }
acos(boost::math::cstdfloat::detail::float_internal128_t x)626 inline boost::math::cstdfloat::detail::float_internal128_t acos(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ACOS(x); }
atan(boost::math::cstdfloat::detail::float_internal128_t x)627 inline boost::math::cstdfloat::detail::float_internal128_t atan(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ATAN(x); }
sinh(boost::math::cstdfloat::detail::float_internal128_t x)628 inline boost::math::cstdfloat::detail::float_internal128_t sinh(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_SINH(x); }
cosh(boost::math::cstdfloat::detail::float_internal128_t x)629 inline boost::math::cstdfloat::detail::float_internal128_t cosh(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_COSH(x); }
tanh(boost::math::cstdfloat::detail::float_internal128_t x)630 inline boost::math::cstdfloat::detail::float_internal128_t tanh(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_TANH(x); }
asinh(boost::math::cstdfloat::detail::float_internal128_t x)631 inline boost::math::cstdfloat::detail::float_internal128_t asinh(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ASINH(x); }
acosh(boost::math::cstdfloat::detail::float_internal128_t x)632 inline boost::math::cstdfloat::detail::float_internal128_t acosh(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ACOSH(x); }
atanh(boost::math::cstdfloat::detail::float_internal128_t x)633 inline boost::math::cstdfloat::detail::float_internal128_t atanh(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ATANH(x); }
fmod(boost::math::cstdfloat::detail::float_internal128_t a,boost::math::cstdfloat::detail::float_internal128_t b)634 inline boost::math::cstdfloat::detail::float_internal128_t fmod(boost::math::cstdfloat::detail::float_internal128_t a, boost::math::cstdfloat::detail::float_internal128_t b) { return ::BOOST_CSTDFLOAT_FLOAT128_FMOD(a, b); }
atan2(boost::math::cstdfloat::detail::float_internal128_t y,boost::math::cstdfloat::detail::float_internal128_t x)635 inline boost::math::cstdfloat::detail::float_internal128_t atan2(boost::math::cstdfloat::detail::float_internal128_t y, boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ATAN2(y, x); }
lgamma(boost::math::cstdfloat::detail::float_internal128_t x)636 inline boost::math::cstdfloat::detail::float_internal128_t lgamma(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LGAMMA(x); }
tgamma(boost::math::cstdfloat::detail::float_internal128_t x)637 inline boost::math::cstdfloat::detail::float_internal128_t tgamma(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_TGAMMA(x); }
638 // begin more functions
remainder(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)639 inline boost::math::cstdfloat::detail::float_internal128_t remainder(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_REMAINDER(x, y); }
remquo(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y,int * z)640 inline boost::math::cstdfloat::detail::float_internal128_t remquo(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y, int* z) { return ::BOOST_CSTDFLOAT_FLOAT128_REMQUO(x, y, z); }
fma(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y,boost::math::cstdfloat::detail::float_internal128_t z)641 inline boost::math::cstdfloat::detail::float_internal128_t fma(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y, boost::math::cstdfloat::detail::float_internal128_t z) { return BOOST_CSTDFLOAT_FLOAT128_FMA(x, y, z); }
642
fmax(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)643 inline boost::math::cstdfloat::detail::float_internal128_t fmax(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_FMAX(x, y); }
644 template <class T>
645 inline typename std::enable_if<
646 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
647 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
fmax(boost::math::cstdfloat::detail::float_internal128_t x,T y)648 fmax(boost::math::cstdfloat::detail::float_internal128_t x, T y) { return ::BOOST_CSTDFLOAT_FLOAT128_FMAX(x, y); }
649 template <class T>
650 inline typename std::enable_if<
651 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
652 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
fmax(T x,boost::math::cstdfloat::detail::float_internal128_t y)653 fmax(T x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_FMAX(x, y); }
fmin(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)654 inline boost::math::cstdfloat::detail::float_internal128_t fmin(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_FMIN(x, y); }
655 template <class T>
656 inline typename std::enable_if<
657 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
658 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
fmin(boost::math::cstdfloat::detail::float_internal128_t x,T y)659 fmin(boost::math::cstdfloat::detail::float_internal128_t x, T y) { return ::BOOST_CSTDFLOAT_FLOAT128_FMIN(x, y); }
660 template <class T>
661 inline typename std::enable_if<
662 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
663 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
fmin(T x,boost::math::cstdfloat::detail::float_internal128_t y)664 fmin(T x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_FMIN(x, y); }
665
fdim(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)666 inline boost::math::cstdfloat::detail::float_internal128_t fdim(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_FDIM(x, y); }
nanq(const char * x)667 inline boost::math::cstdfloat::detail::float_internal128_t nanq(const char* x) { return ::BOOST_CSTDFLOAT_FLOAT128_NAN(x); }
exp2(boost::math::cstdfloat::detail::float_internal128_t x)668 inline boost::math::cstdfloat::detail::float_internal128_t exp2(boost::math::cstdfloat::detail::float_internal128_t x)
669 {
670 return ::BOOST_CSTDFLOAT_FLOAT128_POW(boost::math::cstdfloat::detail::float_internal128_t(2), x);
671 }
log2(boost::math::cstdfloat::detail::float_internal128_t x)672 inline boost::math::cstdfloat::detail::float_internal128_t log2(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LOG2(x); }
log1p(boost::math::cstdfloat::detail::float_internal128_t x)673 inline boost::math::cstdfloat::detail::float_internal128_t log1p(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LOG1P(x); }
cbrt(boost::math::cstdfloat::detail::float_internal128_t x)674 inline boost::math::cstdfloat::detail::float_internal128_t cbrt(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_CBRT(x); }
hypot(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y,boost::math::cstdfloat::detail::float_internal128_t z)675 inline boost::math::cstdfloat::detail::float_internal128_t hypot(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y, boost::math::cstdfloat::detail::float_internal128_t z) { return ::BOOST_CSTDFLOAT_FLOAT128_SQRT(x*x + y * y + z * z); }
hypot(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)676 inline boost::math::cstdfloat::detail::float_internal128_t hypot(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_HYPOT(x, y); }
677 template <class T>
678 inline typename std::enable_if<
679 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
680 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
hypot(boost::math::cstdfloat::detail::float_internal128_t x,T y)681 hypot(boost::math::cstdfloat::detail::float_internal128_t x, T y) { return ::BOOST_CSTDFLOAT_FLOAT128_HYPOT(x, y); }
682 template <class T>
683 inline typename std::enable_if<
684 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
685 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
hypot(T x,boost::math::cstdfloat::detail::float_internal128_t y)686 hypot(T x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_HYPOT(x, y); }
687
688
erf(boost::math::cstdfloat::detail::float_internal128_t x)689 inline boost::math::cstdfloat::detail::float_internal128_t erf(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ERF(x); }
erfc(boost::math::cstdfloat::detail::float_internal128_t x)690 inline boost::math::cstdfloat::detail::float_internal128_t erfc(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ERFC(x); }
llround(boost::math::cstdfloat::detail::float_internal128_t x)691 inline long long int llround(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LLROUND(x); }
lround(boost::math::cstdfloat::detail::float_internal128_t x)692 inline long int lround(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LROUND(x); }
round(boost::math::cstdfloat::detail::float_internal128_t x)693 inline boost::math::cstdfloat::detail::float_internal128_t round(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ROUND(x); }
nearbyint(boost::math::cstdfloat::detail::float_internal128_t x)694 inline boost::math::cstdfloat::detail::float_internal128_t nearbyint(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_NEARBYINT(x); }
llrint(boost::math::cstdfloat::detail::float_internal128_t x)695 inline long long int llrint(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LLRINT(x); }
lrint(boost::math::cstdfloat::detail::float_internal128_t x)696 inline long int lrint(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LRINT(x); }
rint(boost::math::cstdfloat::detail::float_internal128_t x)697 inline boost::math::cstdfloat::detail::float_internal128_t rint(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_RINT(x); }
modf(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t * y)698 inline boost::math::cstdfloat::detail::float_internal128_t modf(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t* y) { return ::BOOST_CSTDFLOAT_FLOAT128_MODF(x, y); }
scalbln(boost::math::cstdfloat::detail::float_internal128_t x,long int y)699 inline boost::math::cstdfloat::detail::float_internal128_t scalbln(boost::math::cstdfloat::detail::float_internal128_t x, long int y) { return ::BOOST_CSTDFLOAT_FLOAT128_SCALBLN(x, y); }
scalbn(boost::math::cstdfloat::detail::float_internal128_t x,int y)700 inline boost::math::cstdfloat::detail::float_internal128_t scalbn(boost::math::cstdfloat::detail::float_internal128_t x, int y) { return ::BOOST_CSTDFLOAT_FLOAT128_SCALBN(x, y); }
ilogb(boost::math::cstdfloat::detail::float_internal128_t x)701 inline int ilogb(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ILOGB(x); }
logb(boost::math::cstdfloat::detail::float_internal128_t x)702 inline boost::math::cstdfloat::detail::float_internal128_t logb(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_LOGB(x); }
nextafter(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)703 inline boost::math::cstdfloat::detail::float_internal128_t nextafter(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER(x, y); }
nexttoward(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)704 inline boost::math::cstdfloat::detail::float_internal128_t nexttoward(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y) { return -(::BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER(-x, -y)); }
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)705 inline boost::math::cstdfloat::detail::float_internal128_t copysign BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_COPYSIGN(x, y); }
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x)706 inline bool signbit BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_SIGNBIT(x); }
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x)707 inline int fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x)
708 {
709 if (::BOOST_CSTDFLOAT_FLOAT128_ISNAN(x))
710 return FP_NAN;
711 else if (::BOOST_CSTDFLOAT_FLOAT128_ISINF(x))
712 return FP_INFINITE;
713 else if (x == BOOST_FLOAT128_C(0.0))
714 return FP_ZERO;
715
716 if (::BOOST_CSTDFLOAT_FLOAT128_FABS(x) < BOOST_CSTDFLOAT_FLOAT128_MIN)
717 return FP_SUBNORMAL;
718 else
719 return FP_NORMAL;
720 }
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x)721 inline bool isfinite BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x)
722 {
723 return !::BOOST_CSTDFLOAT_FLOAT128_ISNAN(x) && !::BOOST_CSTDFLOAT_FLOAT128_ISINF(x);
724 }
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x)725 inline bool isinf BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ISINF(x); }
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x)726 inline bool isnan BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x) { return ::BOOST_CSTDFLOAT_FLOAT128_ISNAN(x); }
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x)727 inline bool isnormal BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x) { return boost::math::cstdfloat::detail::fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION(x) == FP_NORMAL; }
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)728 inline bool isgreater BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y)
729 {
730 if (isnan BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan BOOST_PREVENT_MACRO_SUBSTITUTION(y))
731 return false;
732 return x > y;
733 }
734 template <class T>
735 inline typename std::enable_if<
736 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
737 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,T y)738 isgreater BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, T y) { return isgreater BOOST_PREVENT_MACRO_SUBSTITUTION(x, (boost::math::cstdfloat::detail::float_internal128_t)y); }
739 template <class T>
740 inline typename std::enable_if<
741 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
742 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(T x,boost::math::cstdfloat::detail::float_internal128_t y)743 isgreater BOOST_PREVENT_MACRO_SUBSTITUTION(T x, boost::math::cstdfloat::detail::float_internal128_t y) { return isgreater BOOST_PREVENT_MACRO_SUBSTITUTION((boost::math::cstdfloat::detail::float_internal128_t)x, y); }
744
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)745 inline bool isgreaterequal BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y)
746 {
747 if (isnan BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan BOOST_PREVENT_MACRO_SUBSTITUTION(y))
748 return false;
749 return x >= y;
750 }
751 template <class T>
752 inline typename std::enable_if<
753 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
754 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,T y)755 isgreaterequal BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, T y) { return isgreaterequal BOOST_PREVENT_MACRO_SUBSTITUTION(x, (boost::math::cstdfloat::detail::float_internal128_t)y); }
756 template <class T>
757 inline typename std::enable_if<
758 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
759 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(T x,boost::math::cstdfloat::detail::float_internal128_t y)760 isgreaterequal BOOST_PREVENT_MACRO_SUBSTITUTION(T x, boost::math::cstdfloat::detail::float_internal128_t y) { return isgreaterequal BOOST_PREVENT_MACRO_SUBSTITUTION((boost::math::cstdfloat::detail::float_internal128_t)x, y); }
761
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)762 inline bool isless BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y)
763 {
764 if (isnan BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan BOOST_PREVENT_MACRO_SUBSTITUTION(y))
765 return false;
766 return x < y;
767 }
768 template <class T>
769 inline typename std::enable_if<
770 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
771 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,T y)772 isless BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, T y) { return isless BOOST_PREVENT_MACRO_SUBSTITUTION(x, (boost::math::cstdfloat::detail::float_internal128_t)y); }
773 template <class T>
774 inline typename std::enable_if<
775 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
776 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(T x,boost::math::cstdfloat::detail::float_internal128_t y)777 isless BOOST_PREVENT_MACRO_SUBSTITUTION(T x, boost::math::cstdfloat::detail::float_internal128_t y) { return isless BOOST_PREVENT_MACRO_SUBSTITUTION((boost::math::cstdfloat::detail::float_internal128_t)x, y); }
778
779
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)780 inline bool islessequal BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y)
781 {
782 if (isnan BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan BOOST_PREVENT_MACRO_SUBSTITUTION(y))
783 return false;
784 return x <= y;
785 }
786 template <class T>
787 inline typename std::enable_if<
788 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
789 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,T y)790 islessequal BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, T y) { return islessequal BOOST_PREVENT_MACRO_SUBSTITUTION(x, (boost::math::cstdfloat::detail::float_internal128_t)y); }
791 template <class T>
792 inline typename std::enable_if<
793 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
794 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(T x,boost::math::cstdfloat::detail::float_internal128_t y)795 islessequal BOOST_PREVENT_MACRO_SUBSTITUTION(T x, boost::math::cstdfloat::detail::float_internal128_t y) { return islessequal BOOST_PREVENT_MACRO_SUBSTITUTION((boost::math::cstdfloat::detail::float_internal128_t)x, y); }
796
797
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)798 inline bool islessgreater BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y)
799 {
800 if (isnan BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan BOOST_PREVENT_MACRO_SUBSTITUTION(y))
801 return false;
802 return (x < y) || (x > y);
803 }
804 template <class T>
805 inline typename std::enable_if<
806 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
807 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,T y)808 islessgreater BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, T y) { return islessgreater BOOST_PREVENT_MACRO_SUBSTITUTION(x, (boost::math::cstdfloat::detail::float_internal128_t)y); }
809 template <class T>
810 inline typename std::enable_if<
811 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
812 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(T x,boost::math::cstdfloat::detail::float_internal128_t y)813 islessgreater BOOST_PREVENT_MACRO_SUBSTITUTION(T x, boost::math::cstdfloat::detail::float_internal128_t y) { return islessgreater BOOST_PREVENT_MACRO_SUBSTITUTION((boost::math::cstdfloat::detail::float_internal128_t)x, y); }
814
815
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,boost::math::cstdfloat::detail::float_internal128_t y)816 inline bool isunordered BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, boost::math::cstdfloat::detail::float_internal128_t y) { return ::BOOST_CSTDFLOAT_FLOAT128_ISNAN(x) || ::BOOST_CSTDFLOAT_FLOAT128_ISNAN(y); }
817 template <class T>
818 inline typename std::enable_if<
819 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
820 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x,T y)821 isunordered BOOST_PREVENT_MACRO_SUBSTITUTION(boost::math::cstdfloat::detail::float_internal128_t x, T y) { return isunordered BOOST_PREVENT_MACRO_SUBSTITUTION(x, (boost::math::cstdfloat::detail::float_internal128_t)y); }
822 template <class T>
823 inline typename std::enable_if<
824 std::is_convertible<T, boost::math::cstdfloat::detail::float_internal128_t>::value
825 && !std::is_same<T, boost::math::cstdfloat::detail::float_internal128_t>::value, boost::math::cstdfloat::detail::float_internal128_t>::type
BOOST_PREVENT_MACRO_SUBSTITUTION(T x,boost::math::cstdfloat::detail::float_internal128_t y)826 isunordered BOOST_PREVENT_MACRO_SUBSTITUTION(T x, boost::math::cstdfloat::detail::float_internal128_t y) { return isunordered BOOST_PREVENT_MACRO_SUBSTITUTION((boost::math::cstdfloat::detail::float_internal128_t)x, y); }
827
828
829 // end more functions
830 }
831 }
832 }
833 } // boost::math::cstdfloat::detail
834
835 // We will now inject the quadruple-precision <cmath> functions
836 // into the std namespace. This is done via *using* directive.
837 namespace std
838 {
839 using boost::math::cstdfloat::detail::ldexp;
840 using boost::math::cstdfloat::detail::frexp;
841 using boost::math::cstdfloat::detail::fabs;
842
843 #if !(defined(_GLIBCXX_USE_FLOAT128) && defined(__GNUC__) && (__GNUC__ >= 7))
844 #if (defined(__clang__) && !(!defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128))) || (__GNUC__ <= 6 && !defined(__clang__))
845 // workaround for clang using libstdc++ and old GCC
846 using boost::math::cstdfloat::detail::abs;
847 #endif
848 #endif
849
850 using boost::math::cstdfloat::detail::floor;
851 using boost::math::cstdfloat::detail::ceil;
852 using boost::math::cstdfloat::detail::sqrt;
853 using boost::math::cstdfloat::detail::trunc;
854 using boost::math::cstdfloat::detail::exp;
855 using boost::math::cstdfloat::detail::expm1;
856 using boost::math::cstdfloat::detail::pow;
857 using boost::math::cstdfloat::detail::log;
858 using boost::math::cstdfloat::detail::log10;
859 using boost::math::cstdfloat::detail::sin;
860 using boost::math::cstdfloat::detail::cos;
861 using boost::math::cstdfloat::detail::tan;
862 using boost::math::cstdfloat::detail::asin;
863 using boost::math::cstdfloat::detail::acos;
864 using boost::math::cstdfloat::detail::atan;
865 using boost::math::cstdfloat::detail::sinh;
866 using boost::math::cstdfloat::detail::cosh;
867 using boost::math::cstdfloat::detail::tanh;
868 using boost::math::cstdfloat::detail::asinh;
869 using boost::math::cstdfloat::detail::acosh;
870 using boost::math::cstdfloat::detail::atanh;
871 using boost::math::cstdfloat::detail::fmod;
872 using boost::math::cstdfloat::detail::atan2;
873 using boost::math::cstdfloat::detail::lgamma;
874 using boost::math::cstdfloat::detail::tgamma;
875
876 // begin more functions
877 using boost::math::cstdfloat::detail::remainder;
878 using boost::math::cstdfloat::detail::remquo;
879 using boost::math::cstdfloat::detail::fma;
880 using boost::math::cstdfloat::detail::fmax;
881 using boost::math::cstdfloat::detail::fmin;
882 using boost::math::cstdfloat::detail::fdim;
883 using boost::math::cstdfloat::detail::nanq;
884 using boost::math::cstdfloat::detail::exp2;
885 using boost::math::cstdfloat::detail::log2;
886 using boost::math::cstdfloat::detail::log1p;
887 using boost::math::cstdfloat::detail::cbrt;
888 using boost::math::cstdfloat::detail::hypot;
889 using boost::math::cstdfloat::detail::erf;
890 using boost::math::cstdfloat::detail::erfc;
891 using boost::math::cstdfloat::detail::llround;
892 using boost::math::cstdfloat::detail::lround;
893 using boost::math::cstdfloat::detail::round;
894 using boost::math::cstdfloat::detail::nearbyint;
895 using boost::math::cstdfloat::detail::llrint;
896 using boost::math::cstdfloat::detail::lrint;
897 using boost::math::cstdfloat::detail::rint;
898 using boost::math::cstdfloat::detail::modf;
899 using boost::math::cstdfloat::detail::scalbln;
900 using boost::math::cstdfloat::detail::scalbn;
901 using boost::math::cstdfloat::detail::ilogb;
902 using boost::math::cstdfloat::detail::logb;
903 using boost::math::cstdfloat::detail::nextafter;
904 using boost::math::cstdfloat::detail::nexttoward;
905 using boost::math::cstdfloat::detail::copysign;
906 using boost::math::cstdfloat::detail::signbit;
907 using boost::math::cstdfloat::detail::fpclassify;
908 using boost::math::cstdfloat::detail::isfinite;
909 using boost::math::cstdfloat::detail::isinf;
910 using boost::math::cstdfloat::detail::isnan;
911 using boost::math::cstdfloat::detail::isnormal;
912 using boost::math::cstdfloat::detail::isgreater;
913 using boost::math::cstdfloat::detail::isgreaterequal;
914 using boost::math::cstdfloat::detail::isless;
915 using boost::math::cstdfloat::detail::islessequal;
916 using boost::math::cstdfloat::detail::islessgreater;
917 using boost::math::cstdfloat::detail::isunordered;
918 // end more functions
919
920 //
921 // Very basic iostream operator:
922 //
operator <<(std::ostream & os,__float128 m_value)923 inline std::ostream& operator << (std::ostream& os, __float128 m_value)
924 {
925 std::streamsize digits = os.precision();
926 std::ios_base::fmtflags f = os.flags();
927 std::string s;
928
929 char buf[100];
930 std::unique_ptr<char[]> buf2;
931 std::string format = "%";
932 if (f & std::ios_base::showpos)
933 format += "+";
934 if (f & std::ios_base::showpoint)
935 format += "#";
936 format += ".*";
937 if (digits == 0)
938 digits = 36;
939 format += "Q";
940 if (f & std::ios_base::scientific)
941 format += "e";
942 else if (f & std::ios_base::fixed)
943 format += "f";
944 else
945 format += "g";
946
947 int v = quadmath_snprintf(buf, 100, format.c_str(), digits, m_value);
948
949 if ((v < 0) || (v >= 99))
950 {
951 int v_max = v;
952 buf2.reset(new char[v + 3]);
953 v = quadmath_snprintf(&buf2[0], v_max + 3, format.c_str(), digits, m_value);
954 if (v >= v_max + 3)
955 {
956 BOOST_MATH_THROW_EXCEPTION(std::runtime_error("Formatting of float128_type failed."));
957 }
958 s = &buf2[0];
959 }
960 else
961 s = buf;
962 std::streamsize ss = os.width();
963 if (ss > static_cast<std::streamsize>(s.size()))
964 {
965 char fill = os.fill();
966 if ((os.flags() & std::ios_base::left) == std::ios_base::left)
967 s.append(static_cast<std::string::size_type>(ss - s.size()), fill);
968 else
969 s.insert(static_cast<std::string::size_type>(0), static_cast<std::string::size_type>(ss - s.size()), fill);
970 }
971
972 return os << s;
973 }
974
975
976 } // namespace std
977
978 // We will now remove the preprocessor symbols representing quadruple-precision <cmath>
979 // functions from the preprocessor.
980
981 #undef BOOST_CSTDFLOAT_FLOAT128_LDEXP
982 #undef BOOST_CSTDFLOAT_FLOAT128_FREXP
983 #undef BOOST_CSTDFLOAT_FLOAT128_FABS
984 #undef BOOST_CSTDFLOAT_FLOAT128_FLOOR
985 #undef BOOST_CSTDFLOAT_FLOAT128_CEIL
986 #undef BOOST_CSTDFLOAT_FLOAT128_SQRT
987 #undef BOOST_CSTDFLOAT_FLOAT128_TRUNC
988 #undef BOOST_CSTDFLOAT_FLOAT128_EXP
989 #undef BOOST_CSTDFLOAT_FLOAT128_EXPM1
990 #undef BOOST_CSTDFLOAT_FLOAT128_POW
991 #undef BOOST_CSTDFLOAT_FLOAT128_LOG
992 #undef BOOST_CSTDFLOAT_FLOAT128_LOG10
993 #undef BOOST_CSTDFLOAT_FLOAT128_SIN
994 #undef BOOST_CSTDFLOAT_FLOAT128_COS
995 #undef BOOST_CSTDFLOAT_FLOAT128_TAN
996 #undef BOOST_CSTDFLOAT_FLOAT128_ASIN
997 #undef BOOST_CSTDFLOAT_FLOAT128_ACOS
998 #undef BOOST_CSTDFLOAT_FLOAT128_ATAN
999 #undef BOOST_CSTDFLOAT_FLOAT128_SINH
1000 #undef BOOST_CSTDFLOAT_FLOAT128_COSH
1001 #undef BOOST_CSTDFLOAT_FLOAT128_TANH
1002 #undef BOOST_CSTDFLOAT_FLOAT128_ASINH
1003 #undef BOOST_CSTDFLOAT_FLOAT128_ACOSH
1004 #undef BOOST_CSTDFLOAT_FLOAT128_ATANH
1005 #undef BOOST_CSTDFLOAT_FLOAT128_FMOD
1006 #undef BOOST_CSTDFLOAT_FLOAT128_ATAN2
1007 #undef BOOST_CSTDFLOAT_FLOAT128_LGAMMA
1008 #undef BOOST_CSTDFLOAT_FLOAT128_TGAMMA
1009
1010 // begin more functions
1011 #undef BOOST_CSTDFLOAT_FLOAT128_REMAINDER
1012 #undef BOOST_CSTDFLOAT_FLOAT128_REMQUO
1013 #undef BOOST_CSTDFLOAT_FLOAT128_FMA
1014 #undef BOOST_CSTDFLOAT_FLOAT128_FMAX
1015 #undef BOOST_CSTDFLOAT_FLOAT128_FMIN
1016 #undef BOOST_CSTDFLOAT_FLOAT128_FDIM
1017 #undef BOOST_CSTDFLOAT_FLOAT128_NAN
1018 #undef BOOST_CSTDFLOAT_FLOAT128_EXP2
1019 #undef BOOST_CSTDFLOAT_FLOAT128_LOG2
1020 #undef BOOST_CSTDFLOAT_FLOAT128_LOG1P
1021 #undef BOOST_CSTDFLOAT_FLOAT128_CBRT
1022 #undef BOOST_CSTDFLOAT_FLOAT128_HYPOT
1023 #undef BOOST_CSTDFLOAT_FLOAT128_ERF
1024 #undef BOOST_CSTDFLOAT_FLOAT128_ERFC
1025 #undef BOOST_CSTDFLOAT_FLOAT128_LLROUND
1026 #undef BOOST_CSTDFLOAT_FLOAT128_LROUND
1027 #undef BOOST_CSTDFLOAT_FLOAT128_ROUND
1028 #undef BOOST_CSTDFLOAT_FLOAT128_NEARBYINT
1029 #undef BOOST_CSTDFLOAT_FLOAT128_LLRINT
1030 #undef BOOST_CSTDFLOAT_FLOAT128_LRINT
1031 #undef BOOST_CSTDFLOAT_FLOAT128_RINT
1032 #undef BOOST_CSTDFLOAT_FLOAT128_MODF
1033 #undef BOOST_CSTDFLOAT_FLOAT128_SCALBLN
1034 #undef BOOST_CSTDFLOAT_FLOAT128_SCALBN
1035 #undef BOOST_CSTDFLOAT_FLOAT128_ILOGB
1036 #undef BOOST_CSTDFLOAT_FLOAT128_LOGB
1037 #undef BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER
1038 #undef BOOST_CSTDFLOAT_FLOAT128_NEXTTOWARD
1039 #undef BOOST_CSTDFLOAT_FLOAT128_COPYSIGN
1040 #undef BOOST_CSTDFLOAT_FLOAT128_SIGNBIT
1041 #undef BOOST_CSTDFLOAT_FLOAT128_FPCLASSIFY
1042 #undef BOOST_CSTDFLOAT_FLOAT128_ISFINITE
1043 #undef BOOST_CSTDFLOAT_FLOAT128_ISINF
1044 #undef BOOST_CSTDFLOAT_FLOAT128_ISNAN
1045 #undef BOOST_CSTDFLOAT_FLOAT128_ISNORMAL
1046 #undef BOOST_CSTDFLOAT_FLOAT128_ISGREATER
1047 #undef BOOST_CSTDFLOAT_FLOAT128_ISGREATEREQUAL
1048 #undef BOOST_CSTDFLOAT_FLOAT128_ISLESS
1049 #undef BOOST_CSTDFLOAT_FLOAT128_ISLESSEQUAL
1050 #undef BOOST_CSTDFLOAT_FLOAT128_ISLESSGREATER
1051 #undef BOOST_CSTDFLOAT_FLOAT128_ISUNORDERED
1052 // end more functions
1053
1054 #endif // Not BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT (i.e., the user would like to have libquadmath support)
1055
1056 #endif // BOOST_MATH_CSTDFLOAT_CMATH_2014_02_15_HPP_
1057
1058