30 #ifdef DUNE_CLASSNAME_HH
31 #error "Due to some trickery required for the linker, this file must be included _before_ Dune's classname.hh!"
34 #include <dune/common/classname.hh>
35 #endif // HAVE_DUNE_COMMON
37 #if !defined OPM_COMMON_QUAD_HPP && HAVE_QUAD
38 #define OPM_COMMON_QUAD_HPP
45 #include <type_traits>
51 typedef __float128 quad;
57 class numeric_limits<quad>
60 static constexpr
bool is_specialized =
true;
62 static constexpr quad min() throw()
63 {
return FLT128_MIN; }
64 static constexpr quad max() throw()
65 {
return FLT128_MAX; }
68 static constexpr
int digits = FLT128_MANT_DIG;
70 static constexpr
int digits10 = FLT128_DIG;
71 static constexpr
bool is_signed =
true;
72 static constexpr
bool is_integer =
false;
73 static constexpr
bool is_exact =
false;
74 static constexpr
int radix = 0;
75 static constexpr quad epsilon() throw()
76 {
return FLT128_EPSILON; }
77 static constexpr quad round_error() throw()
80 static constexpr
int min_exponent = FLT128_MIN_EXP;
81 static constexpr
int min_exponent10 = FLT128_MIN_10_EXP;
82 static constexpr
int max_exponent = FLT128_MAX_EXP;
83 static constexpr
int max_exponent10 = FLT128_MAX_10_EXP;
85 static constexpr
bool has_infinity =
true;
86 static constexpr
bool has_quiet_NaN =
true;
87 static constexpr
bool has_signaling_NaN =
true;
88 static constexpr float_denorm_style has_denorm = denorm_present;
89 static constexpr
bool has_denorm_loss =
false;
90 static constexpr quad infinity() throw()
91 {
return __builtin_huge_valq(); }
92 static constexpr quad quiet_NaN() throw()
93 {
return __builtin_nan(
""); }
94 static constexpr quad signaling_NaN() throw()
95 {
return __builtin_nans(
""); }
96 static constexpr quad denorm_min() throw()
97 {
return FLT128_DENORM_MIN; }
99 static constexpr
bool is_iec559 =
true;
100 static constexpr
bool is_bounded =
true;
101 static constexpr
bool is_modulo =
false;
103 static constexpr
bool traps = std::numeric_limits<double>::traps;
104 static constexpr
bool tinyness_before = std::numeric_limits<double>::tinyness_before;
105 static constexpr float_round_style round_style = round_to_nearest;
110 struct is_floating_point<quad>
111 :
public integral_constant<bool, true>
115 struct is_arithmetic<quad>
116 :
public integral_constant<bool, true>
120 struct is_fundamental<quad>
121 :
public integral_constant<bool, true>
125 struct is_scalar<quad>
126 :
public integral_constant<bool, true>
131 :
public integral_constant<bool, true>
135 struct is_signed<quad>
136 :
public integral_constant<bool, true>
141 struct is_standard_layout<quad>
142 :
public integral_constant<bool, true>
146 struct is_trivial<quad>
147 :
public integral_constant<bool, true>
157 template <
class OtherType>
158 struct is_assignable<quad, OtherType>
159 :
public integral_constant<bool, is_arithmetic<OtherType>::value>
162 template <
class OtherType>
163 struct is_nothrow_assignable<quad, OtherType>
164 :
public is_assignable<quad, OtherType>
175 struct is_copy_assignable<quad>
176 :
public integral_constant<bool, true>
180 struct is_nothrow_copy_assignable<quad>
181 :
public integral_constant<bool, true>
185 struct is_move_assignable<quad>
186 :
public integral_constant<bool, true>
190 struct is_nothrow_move_assignable<quad>
191 :
public integral_constant<bool, true>
195 struct is_constructible<quad>
196 :
public integral_constant<bool, true>
200 struct is_nothrow_constructible<quad>
201 :
public integral_constant<bool, true>
205 struct is_default_constructible<quad>
206 :
public integral_constant<bool, true>
210 struct is_nothrow_default_constructible<quad>
211 :
public integral_constant<bool, true>
222 struct is_copy_constructible<quad>
223 :
public integral_constant<bool, true>
227 struct is_move_constructible<quad>
228 :
public integral_constant<bool, true>
232 struct is_nothrow_move_constructible<quad>
233 :
public integral_constant<bool, true>
238 struct is_destructible<quad>
239 :
public integral_constant<bool, true>
243 struct is_nothrow_destructible<quad>
244 :
public integral_constant<bool, true>
247 template <
class OtherType>
248 struct is_convertible<quad, OtherType>
249 :
public is_arithmetic<OtherType>
252 inline std::ostream& operator<<(std::ostream& os,
const quad& val)
254 if (os.precision() > std::numeric_limits<double>::digits10)
255 throw std::runtime_error(
"The precision requested for output cannot "
256 "be represented by a double precision floating "
259 return os << static_cast<double>(val);
262 inline std::istream& operator>>(std::istream& is, quad& val)
265 std::istream& ret = (is >> tmp);
270 inline quad abs(quad val)
271 {
return (val < 0) ? -val : val; }
273 inline quad floor(quad val)
274 {
return floorq(val); }
276 inline quad ceil(quad val)
277 {
return ceilq(val); }
279 inline quad max(quad a, quad b)
280 {
return (a > b) ? a : b; }
282 inline quad min(quad a, quad b)
283 {
return (a < b) ? a : b; }
285 inline quad sqrt(quad val)
286 {
return sqrtq(val); }
288 template <
class ExpType>
289 inline quad pow(quad base, ExpType exp)
290 {
return powq(base, static_cast<quad>(exp)); }
292 template <
class BaseType>
293 inline quad pow(BaseType base, quad exp)
294 {
return powq(static_cast<quad>(base), exp); }
296 inline quad pow(quad base, quad exp)
297 {
return powq(base, exp); }
299 inline quad exp(quad val)
300 {
return expq(val); }
302 inline quad log(quad val)
303 {
return logq(val); }
305 inline quad sin(quad val)
306 {
return sinq(val); }
308 inline quad cos(quad val)
309 {
return cosq(val); }
311 inline quad tan(quad val)
312 {
return tanq(val); }
314 inline quad atan(quad val)
315 {
return atanq(val); }
317 inline quad atan2(quad a, quad b)
318 {
return atan2q(a, b); }
320 inline quad round(quad val)
321 {
return roundq(val); }
323 inline bool isfinite(quad val)
324 {
return finiteq(val); }
326 inline bool isnan(quad val)
327 {
return isnanq(val); }
329 inline bool isinf(quad val)
330 {
return isinfq(val); }
339 inline std::string className<__float128>()
342 #endif // HAVE_DUNE_COMMON
344 #endif // OPM_COMMON_QUAD_HPP