29 #if !defined OPM_COMMON_QUAD_HPP && HAVE_QUAD
30 #define OPM_COMMON_QUAD_HPP
38 #include <type_traits>
44 typedef __float128 quad;
50 class numeric_limits<quad>
53 static constexpr
bool is_specialized =
true;
55 static constexpr quad min() throw()
56 {
return FLT128_MIN; }
57 static constexpr quad max() throw()
58 {
return FLT128_MAX; }
61 static constexpr
int digits = FLT128_MANT_DIG;
63 static constexpr
int digits10 = FLT128_DIG;
64 static constexpr
bool is_signed =
true;
65 static constexpr
bool is_integer =
false;
66 static constexpr
bool is_exact =
false;
67 static constexpr
int radix = 0;
68 static constexpr quad epsilon() throw()
69 {
return FLT128_EPSILON; }
70 static constexpr quad round_error() throw()
73 static constexpr
int min_exponent = FLT128_MIN_EXP;
74 static constexpr
int min_exponent10 = FLT128_MIN_10_EXP;
75 static constexpr
int max_exponent = FLT128_MAX_EXP;
76 static constexpr
int max_exponent10 = FLT128_MAX_10_EXP;
78 static constexpr
bool has_infinity =
true;
79 static constexpr
bool has_quiet_NaN =
true;
80 static constexpr
bool has_signaling_NaN =
true;
81 static constexpr float_denorm_style has_denorm = denorm_present;
82 static constexpr
bool has_denorm_loss =
false;
83 static constexpr quad infinity() throw()
84 {
return __builtin_huge_valq(); }
85 static constexpr quad quiet_NaN() throw()
86 {
return __builtin_nan(
""); }
87 static constexpr quad signaling_NaN() throw()
88 {
return __builtin_nans(
""); }
89 static constexpr quad denorm_min() throw()
90 {
return FLT128_DENORM_MIN; }
92 static constexpr
bool is_iec559 =
true;
93 static constexpr
bool is_bounded =
true;
94 static constexpr
bool is_modulo =
false;
96 static constexpr
bool traps = std::numeric_limits<double>::traps;
97 static constexpr
bool tinyness_before = std::numeric_limits<double>::tinyness_before;
98 static constexpr float_round_style round_style = round_to_nearest;
103 struct is_floating_point<quad>
104 :
public integral_constant<bool, true>
108 struct is_arithmetic<quad>
109 :
public integral_constant<bool, true>
113 struct is_fundamental<quad>
114 :
public integral_constant<bool, true>
118 struct is_scalar<quad>
119 :
public integral_constant<bool, true>
124 :
public integral_constant<bool, true>
128 struct is_signed<quad>
129 :
public integral_constant<bool, true>
134 struct is_standard_layout<quad>
135 :
public integral_constant<bool, true>
139 struct is_trivial<quad>
140 :
public integral_constant<bool, true>
150 template <
class OtherType>
151 struct is_assignable<quad, OtherType>
152 :
public integral_constant<bool, is_arithmetic<OtherType>::value>
155 template <
class OtherType>
156 struct is_nothrow_assignable<quad, OtherType>
157 :
public is_assignable<quad, OtherType>
168 struct is_copy_assignable<quad>
169 :
public integral_constant<bool, true>
173 struct is_nothrow_copy_assignable<quad>
174 :
public integral_constant<bool, true>
178 struct is_move_assignable<quad>
179 :
public integral_constant<bool, true>
183 struct is_nothrow_move_assignable<quad>
184 :
public integral_constant<bool, true>
188 struct is_constructible<quad>
189 :
public integral_constant<bool, true>
193 struct is_nothrow_constructible<quad>
194 :
public integral_constant<bool, true>
198 struct is_default_constructible<quad>
199 :
public integral_constant<bool, true>
203 struct is_nothrow_default_constructible<quad>
204 :
public integral_constant<bool, true>
215 struct is_copy_constructible<quad>
216 :
public integral_constant<bool, true>
220 struct is_move_constructible<quad>
221 :
public integral_constant<bool, true>
225 struct is_nothrow_move_constructible<quad>
226 :
public integral_constant<bool, true>
231 struct is_destructible<quad>
232 :
public integral_constant<bool, true>
236 struct is_nothrow_destructible<quad>
237 :
public integral_constant<bool, true>
240 template <
class OtherType>
241 struct is_convertible<quad, OtherType>
242 :
public is_arithmetic<OtherType>
245 inline std::ostream& operator<<(std::ostream& os,
const quad& val)
247 if (os.precision() > std::numeric_limits<double>::digits10)
248 throw std::runtime_error(
"The precision requested for output cannot "
249 "be represented by a double precision floating "
252 return os << static_cast<double>(val);
255 inline std::istream& operator>>(std::istream& is, quad& val)
258 std::istream& ret = (is >> tmp);
263 inline quad real(quad val)
266 inline quad real(
const std::complex<quad>& val)
267 {
return val.real(); }
269 inline quad imag(quad)
272 inline quad imag(
const std::complex<quad>& val)
273 {
return val.imag(); }
275 inline quad abs(quad val)
276 {
return (val < 0) ? -val : val; }
278 inline quad floor(quad val)
279 {
return floorq(val); }
281 inline quad ceil(quad val)
282 {
return ceilq(val); }
284 inline quad max(quad a, quad b)
285 {
return (a > b) ? a : b; }
287 inline quad min(quad a, quad b)
288 {
return (a < b) ? a : b; }
290 inline quad sqrt(quad val)
291 {
return sqrtq(val); }
293 template <
class ExpType>
294 inline quad pow(quad base, ExpType exp)
295 {
return powq(base,
static_cast<quad
>(exp)); }
297 template <
class BaseType>
298 inline quad pow(BaseType base, quad exp)
299 {
return powq(
static_cast<quad
>(base), exp); }
301 inline quad pow(quad base, quad exp)
302 {
return powq(base, exp); }
304 inline quad exp(quad val)
305 {
return expq(val); }
307 inline quad log(quad val)
308 {
return logq(val); }
310 inline quad sin(quad val)
311 {
return sinq(val); }
313 inline quad cos(quad val)
314 {
return cosq(val); }
316 inline quad tan(quad val)
317 {
return tanq(val); }
319 inline quad atan(quad val)
320 {
return atanq(val); }
322 inline quad atan2(quad a, quad b)
323 {
return atan2q(a, b); }
325 inline quad round(quad val)
326 {
return roundq(val); }
328 inline bool isfinite(quad val)
329 {
return finiteq(val); }
331 inline bool isnan(quad val)
332 {
return isnanq(val); }
334 inline bool isinf(quad val)
335 {
return isinfq(val); }
341 #include <dune/common/classname.hh>
345 inline std::string className<__float128>()
350 #include <dune/fem/io/streams/streams_inline.hh>
354 template <
class Traits>
355 inline OutStreamInterface<Traits>&
356 operator<<(OutStreamInterface<Traits>& out, quad value)
358 out.writeDouble(
static_cast<double>(value));
362 template <
class Traits>
363 inline InStreamInterface<Traits>&
364 operator>>(InStreamInterface<Traits>& in, quad& value)