alpaqa 1.0.0a13
Nonconvex constrained optimization
Loading...
Searching...
No Matches
quadmath.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifdef ALPAQA_WITH_QUAD_PRECISION
4#pragma GCC system_header
5
6#include <quadmath.h>
7
8#include <alpaqa/export.h>
9
10#include <cmath>
11#include <iosfwd>
12#include <limits>
13
14namespace std {
15
16// From GCC 11's <limits>
17
18/// numeric_limits<__float128> specialization.
19template <>
20struct numeric_limits<__float128> {
21 static constexpr bool is_specialized = true;
22
23 static constexpr __float128 min() noexcept { return FLT128_MIN; }
24 static constexpr __float128 max() noexcept { return FLT128_MAX; }
25 static constexpr __float128 lowest() noexcept { return -FLT128_MAX; }
26
27 static constexpr int digits = FLT128_MANT_DIG;
28 static constexpr int digits10 = FLT128_DIG;
29 static constexpr int max_digits10 = (2 + FLT128_MANT_DIG * 643L / 2136);
30 static constexpr bool is_signed = true;
31 static constexpr bool is_integer = false;
32 static constexpr bool is_exact = false;
33 static constexpr int radix = 2;
34
35 static constexpr __float128 epsilon() noexcept { return FLT128_EPSILON; }
36 static constexpr __float128 round_error() noexcept { return 0.5Q; }
37
38 static constexpr int min_exponent = FLT128_MIN_EXP;
39 static constexpr int min_exponent10 = FLT128_MIN_10_EXP;
40 static constexpr int max_exponent = FLT128_MAX_EXP;
41 static constexpr int max_exponent10 = FLT128_MAX_10_EXP;
42
43 static constexpr bool has_infinity = true;
44 static constexpr bool has_quiet_NaN = true;
45 static constexpr bool has_signaling_NaN = has_quiet_NaN;
46 static constexpr float_denorm_style has_denorm = denorm_present;
47 static constexpr bool has_denorm_loss = false;
48
49 static constexpr __float128 infinity() noexcept { return __builtin_huge_valq(); }
50 static constexpr __float128 quiet_NaN() noexcept { return __builtin_nanq(""); }
51 static constexpr __float128 signaling_NaN() noexcept { return __builtin_nansq(""); }
52 static constexpr __float128 denorm_min() noexcept { return FLT128_DENORM_MIN; }
53
54 static constexpr bool is_iec559 = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
55 static constexpr bool is_bounded = true;
56 static constexpr bool is_modulo = false;
57
58 static constexpr bool traps = false;
59 static constexpr bool tinyness_before = false;
60 static constexpr float_round_style round_style = round_to_nearest;
61};
62
63// From GCC's quadmath.h
64
65inline __float128 acos(__float128 x) { return ::acosq(x); }
66inline __float128 acosh(__float128 x) { return ::acoshq(x); }
67inline __float128 asin(__float128 x) { return ::asinq(x); }
68inline __float128 asinh(__float128 x) { return ::asinhq(x); }
69inline __float128 atan(__float128 x) { return ::atanq(x); }
70inline __float128 atanh(__float128 x) { return ::atanhq(x); }
71inline __float128 atan2(__float128 x, __float128 y) { return ::atan2q(x, y); }
72inline __float128 cbrt(__float128 x) { return ::cbrtq(x); }
73inline __float128 ceil(__float128 x) { return ::ceilq(x); }
74inline __float128 copysign(__float128 x, __float128 y) { return ::copysignq(x, y); }
75inline __float128 cosh(__float128 x) { return ::coshq(x); }
76inline __float128 cos(__float128 x) { return ::cosq(x); }
77inline __float128 erf(__float128 x) { return ::erfq(x); }
78inline __float128 erfc(__float128 x) { return ::erfcq(x); }
79inline __float128 exp2(__float128 x) { return ::exp2q(x); }
80inline __float128 exp(__float128 x) { return ::expq(x); }
81inline __float128 expm1(__float128 x) { return ::expm1q(x); }
82inline __float128 fabs(__float128 x) { return ::fabsq(x); }
83inline __float128 fdim(__float128 x, __float128 y) { return ::fdimq(x, y); }
84inline int finite(__float128 x) { return ::finiteq(x); }
85inline __float128 floor(__float128 x) { return ::floorq(x); }
86inline __float128 fma(__float128 x, __float128 y, __float128 z) { return ::fmaq(x, y, z); }
87inline __float128 fmax(__float128 x, __float128 y) { return ::fmaxq(x, y); }
88inline __float128 fmin(__float128 x, __float128 y) { return ::fminq(x, y); }
89inline __float128 fmod(__float128 x, __float128 y) { return ::fmodq(x, y); }
90inline __float128 frexp(__float128 x, int *y) { return ::frexpq(x, y); }
91inline __float128 hypot(__float128 x, __float128 y) { return ::hypotq(x, y); }
92inline int isinf(__float128 x) { return ::isinfq(x); }
93inline int ilogb(__float128 x) { return ::ilogbq(x); }
94inline int isfinite(__float128 x) { return ::finiteq(x); }
95inline int isnan(__float128 x) { return ::isnanq(x); }
96inline int issignaling(__float128 x) { return ::issignalingq(x); }
97inline __float128 j0(__float128 x) { return ::j0q(x); }
98inline __float128 j1(__float128 x) { return ::j1q(x); }
99inline __float128 jn(int n, __float128 x) { return ::jnq(n, x); }
100inline __float128 ldexp(__float128 x, int y) { return ::ldexpq(x, y); }
101inline __float128 lgamma(__float128 x) { return ::lgammaq(x); }
102inline long long int llrint(__float128 x) { return ::llrintq(x); }
103inline long long int llround(__float128 x) { return ::llroundq(x); }
104inline __float128 logb(__float128 x) { return ::logbq(x); }
105inline __float128 log(__float128 x) { return ::logq(x); }
106inline __float128 log10(__float128 x) { return ::log10q(x); }
107inline __float128 log2(__float128 x) { return ::log2q(x); }
108inline __float128 log1p(__float128 x) { return ::log1pq(x); }
109inline long int lrint(__float128 x) { return ::lrintq(x); }
110inline long int lround(__float128 x) { return ::lroundq(x); }
111inline __float128 modf(__float128 x, __float128 *y) { return ::modfq(x, y); }
112// inline __float128 nan(const char *x) { return ::nanq(x); }
113inline __float128 nearbyint(__float128 x) { return ::nearbyintq(x); }
114inline __float128 nextafter(__float128 x, __float128 y) { return ::nextafterq(x, y); }
115inline __float128 pow(__float128 x, __float128 y) { return ::powq(x, y); }
116inline __float128 remainder(__float128 x, __float128 y) { return ::remainderq(x, y); }
117inline __float128 remquo(__float128 x, __float128 y, int *z) { return ::remquoq(x, y, z); }
118inline __float128 rint(__float128 x) { return ::rintq(x); }
119inline __float128 round(__float128 x) { return ::roundq(x); }
120inline __float128 scalbln(__float128 x, long int y) { return ::scalblnq(x, y); }
121inline __float128 scalbn(__float128 x, int y) { return ::scalbnq(x, y); }
122inline int signbit(__float128 x) { return ::signbitq(x); }
123inline void sincosq(__float128 x, __float128 *y, __float128 *z) { return ::sincosq(x, y, z); }
124inline __float128 sinh(__float128 x) { return ::sinhq(x); }
125inline __float128 sin(__float128 x) { return ::sinq(x); }
126inline __float128 sqrt(__float128 x) { return ::sqrtq(x); }
127inline __float128 tan(__float128 x) { return ::tanq(x); }
128inline __float128 tanh(__float128 x) { return ::tanhq(x); }
129inline __float128 tgamma(__float128 x) { return ::tgammaq(x); }
130inline __float128 trunc(__float128 x) { return ::truncq(x); }
131inline __float128 y0(__float128 x) { return ::y0q(x); }
132inline __float128 y1(__float128 x) { return ::y1q(x); }
133inline __float128 yn(int n, __float128 x) { return ::ynq(n, x); }
134
135} // namespace std
136
137#endif