-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquadmath_cpp.h
190 lines (150 loc) · 6.55 KB
/
quadmath_cpp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
** Author: zerico2005 (2024 - 2025)
** Project: quadmath_cpp
** License: MIT License
** A copy of the MIT License should be included with
** this project. If not, see https://opensource.org/license/MIT
*/
#ifndef QUADMATH_CPP_H
#define QUADMATH_CPP_H
//------------------------------------------------------------------------------
// <quadmath.h> overloads
//------------------------------------------------------------------------------
#ifndef QUADMATH_CPP_NAMESPACE_STD
/* disabled by default */
#define QUADMATH_CPP_NAMESPACE_STD 0
#endif
#include <quadmath.h>
#if __cplusplus >= 201103L
/* for fpclassify return values */
#include <cmath>
#endif
#if QUADMATH_CPP_NAMESPACE_STD
namespace std {
#endif
/* Classification */
inline bool signbit(__float128 x) { return (signbitq(x) != 0); }
inline bool isfinite(__float128 x) { return (finiteq(x) != 0); }
inline bool isinf(__float128 x) { return (isinfq(x) != 0); }
inline bool isnan(__float128 x) { return (isnanq(x) != 0); }
inline bool issignaling(__float128 x) { return (issignalingq(x) != 0); }
inline bool isunordered(__float128 x, __float128 y) {
return ((isnanq(x) != 0) || (isnanq(y) != 0));
}
inline bool isnormal(__float128 x) {
return ((finiteq(x) != 0) && (fabsq(x) >= FLT128_MIN));
}
inline bool issubnormal(__float128 x) {
return ((finiteq(x) != 0) && (fabsq(x) < FLT128_MIN) && (x != static_cast<__float128>(0.0)));
}
#if __cplusplus >= 201103L
inline int fpclassify(__float128 x) {
return
isinfq(x) ? FP_INFINITE :
isnanq(x) ? FP_NAN :
x == static_cast<__float128>(0.0) ? FP_ZERO :
isnormal(x) ? FP_NORMAL :
FP_SUBNORMAL;
}
#endif /* __cplusplus >= 201103L */
/* Quiet Compairison */
inline bool islessgreater(__float128 x, __float128 y) {
return ((x != y) && (isnanq(x) == 0) && (isnanq(y) == 0));
}
inline bool isless(__float128 x, __float128 y) {
if ((isnanq(x) != 0) || (isnanq(y) != 0)) {
return false;
}
return (x < y);
}
inline bool islessequal(__float128 x, __float128 y) {
if ((isnanq(x) != 0) || (isnanq(y) != 0)) {
return false;
}
return (x <= y);
}
inline bool isgreater(__float128 x, __float128 y) {
if ((isnanq(x) != 0) || (isnanq(y) != 0)) {
return false;
}
return (x > y);
}
inline bool isgreaterequal(__float128 x, __float128 y) {
if ((isnanq(x) != 0) || (isnanq(y) != 0)) {
return false;
}
return (x >= y);
}
/* signaling comparison */
inline bool iseqsig(__float128 x, __float128 y) {
return ((x >= y) && (x <= y));
}
/* Manipulation */
inline __float128 fabs(__float128 x) { return fabsq(x); }
inline __float128 copysign(__float128 x, __float128 y) { return copysignq(x, y); }
inline __float128 nextafter(__float128 x, __float128 y) { return nextafterq(x, y); }
inline __float128 nexttoward(__float128 x, long double y) { return nextafterq(x, static_cast<__float128>(y)); }
/* Float Exponents */
inline int ilogb(__float128 x) { return ilogbq(x); }
inline __float128 frexp (__float128 x, int* expon) { return frexpq (x, expon); }
inline __float128 ldexp (__float128 x, int expon) { return ldexpq (x, expon); }
inline __float128 scalbn (__float128 x, int expon) { return scalbnq (x, expon); }
inline __float128 scalbln(__float128 x, long expon) { return scalblnq(x, expon); }
/* Arithmetic */
inline __float128 fmax(__float128 x, __float128 y) { return fmaxq(x, y); }
inline __float128 fmin(__float128 x, __float128 y) { return fminq(x, y); }
inline __float128 fdim(__float128 x, __float128 y) { return fdimq(x, y); }
inline __float128 fma(__float128 x, __float128 y, __float128 z) { return fmaq(x, y, z); }
inline __float128 sqrt(__float128 x) { return sqrtq(x); }
inline __float128 cbrt(__float128 x) { return cbrtq(x); }
inline __float128 hypot(__float128 x, __float128 y) { return hypotq(x, y); }
/* Remainder and Modulus */
inline __float128 fmod(__float128 x, __float128 y) { return fmodq(x, y); }
inline __float128 remainder(__float128 x, __float128 y) { return remainderq(x, y); }
inline __float128 remquo(__float128 x, __float128 y, int* quo) { return remquoq(x, y, quo); }
/* Rounding */
inline __float128 modf(__float128 x, __float128* integral_part) { return modfq(x, integral_part); }
inline __float128 trunc(__float128 x) { return truncq(x); }
inline __float128 floor(__float128 x) { return floorq(x); }
inline __float128 ceil (__float128 x) { return ceilq (x); }
inline __float128 rint (__float128 x) { return rintq (x); }
inline __float128 round(__float128 x) { return roundq(x); }
inline long lrint (__float128 x) { return lrintq (x); }
inline long lround(__float128 x) { return lroundq(x); }
inline long long llrint (__float128 x) { return llrintq (x); }
inline long long llround(__float128 x) { return llroundq(x); }
inline __float128 nearbyint(__float128 x) { return nearbyintq(x); }
/* Logarithms and Exponents */
inline __float128 log (__float128 x) { return logq (x); }
inline __float128 log1p(__float128 x) { return log1pq(x); }
inline __float128 logb (__float128 x) { return logbq (x); }
inline __float128 log2 (__float128 x) { return log2q (x); }
inline __float128 log10(__float128 x) { return log10q(x); }
inline __float128 exp (__float128 x) { return expq (x); }
inline __float128 expm1(__float128 x) { return expm1q(x); }
inline __float128 exp2 (__float128 x) { return exp2q (x); }
inline __float128 pow(__float128 x, __float128 y) { return powq(x, y); }
/* Trigonometry */
inline __float128 sin (__float128 x) { return sinq (x); }
inline __float128 cos (__float128 x) { return cosq (x); }
inline __float128 tan (__float128 x) { return tanq (x); }
inline __float128 asin (__float128 x) { return asinq (x); }
inline __float128 acos (__float128 x) { return acosq (x); }
inline __float128 atan (__float128 x) { return atanq (x); }
inline __float128 sinh(__float128 x) { return sinhq(x); }
inline __float128 cosh(__float128 x) { return coshq(x); }
inline __float128 tanh(__float128 x) { return tanhq(x); }
inline __float128 asinh(__float128 x) { return asinhq(x); }
inline __float128 acosh(__float128 x) { return acoshq(x); }
inline __float128 atanh(__float128 x) { return atanhq(x); }
inline __float128 atan2(__float128 y, __float128 x) { return atan2q(y, x); }
inline void sincos(__float128 x, __float128* p_sin, __float128* p_cos) { sincosq(x, p_sin, p_cos); }
/* Transcendental Functions */
inline __float128 erf (__float128 x) { return erfq (x); }
inline __float128 erfc(__float128 x) { return erfcq(x); }
inline __float128 lgamma(__float128 x) { return lgammaq(x); }
inline __float128 tgamma(__float128 x) { return tgammaq(x); }
#if QUADMATH_CPP_NAMESPACE_STD
}
#endif
#endif /* QUADMATH_CPP_H */