10#ifndef TLAPACK_GNUQUAD_HH
11#define TLAPACK_GNUQUAD_HH
21constexpr __float128 abs(__float128 x);
22inline __float128 ceil(__float128 x)
noexcept {
return ceilq(x); }
23inline __float128 floor(__float128 x)
noexcept {
return floorq(x); }
24inline bool isinf(__float128 x)
noexcept {
return isinfq(x); }
25inline bool isnan(__float128 x)
noexcept {
return isnanq(x); }
26inline __float128 log2(__float128 x)
noexcept {
return log2q(x); }
27inline __float128 max(__float128 x, __float128 y)
noexcept
31inline __float128 min(__float128 x, __float128 y)
noexcept
35inline __float128 pow(
int x, __float128 y)
noexcept {
return powq(x, y); }
36inline __float128 sqrt(__float128 x)
noexcept {
return sqrtq(x); }
38inline __float128 abs(complex<__float128> z)
40 __float128 x = z.real();
41 __float128 y = z.imag();
42 const __float128 __s = max(abs(x), abs(y));
43 if (__s == __float128())
47 return __s * sqrt(x * x + y * y);
49inline complex<__float128> sqrt(complex<__float128> z)
51 const __float128 x =
real(z);
52 const __float128 y =
imag(z);
53 const __float128 zero(0);
54 const __float128 two(2);
55 const __float128 half(0.5);
58 const __float128 t = sqrt(half * abs(y));
59 return complex<__float128>(t, (y < zero) ? -t : t);
62 const __float128 t = sqrt(two * (abs(z) + abs(x)));
63 const __float128 u = half * t;
65 ? complex<__float128>(u, y / t)
66 : complex<__float128>(abs(y) / t, (y < zero) ? -u : u);
71struct numeric_limits<__float128> {
72 static constexpr bool is_specialized =
true;
74 static constexpr __float128 min()
noexcept;
75 static constexpr __float128 max()
noexcept;
76 static constexpr __float128 lowest()
noexcept;
78 static constexpr int digits = FLT128_MANT_DIG;
79 static constexpr int digits10 = FLT128_DIG;
80 static constexpr int max_digits10 = (2 + FLT128_MANT_DIG * 643L / 2136);
82 static constexpr bool is_signed =
true;
83 static constexpr bool is_integer =
false;
84 static constexpr bool is_exact =
false;
86 static constexpr int radix = 2;
87 static constexpr __float128 epsilon()
noexcept;
88 static constexpr __float128 round_error()
noexcept {
return 0.5F; }
90 static constexpr int min_exponent = FLT128_MIN_EXP;
91 static constexpr int min_exponent10 = FLT128_MIN_10_EXP;
92 static constexpr int max_exponent = FLT128_MAX_EXP;
93 static constexpr int max_exponent10 = FLT128_MAX_10_EXP;
95 static constexpr bool has_infinity =
true;
96 static constexpr bool has_quiet_NaN =
true;
98 static constexpr float_denorm_style has_denorm = denorm_present;
99 static constexpr bool has_denorm_loss =
false;
101 static constexpr __float128 infinity()
noexcept
103 return __builtin_huge_valq();
105 static __float128 quiet_NaN()
noexcept {
return nanq(
""); }
107 static constexpr __float128 denorm_min()
noexcept;
110 static constexpr bool is_bounded =
true;
111 static constexpr bool is_modulo =
false;
115 static constexpr float_round_style round_style = round_to_nearest;
118inline ostream& operator<<(ostream& out,
const __float128& x)
121 quadmath_snprintf(buf,
sizeof buf,
"%+-#*.20Qe", x);
126inline istream& operator>>(istream& in, __float128& x)
130 x = strtoflt128(buf,
nullptr);
135 #pragma GCC system_header
138constexpr __float128 numeric_limits<__float128>::min() noexcept
142constexpr __float128 numeric_limits<__float128>::max() noexcept
146constexpr __float128 numeric_limits<__float128>::lowest() noexcept
150constexpr __float128 numeric_limits<__float128>::epsilon() noexcept
152 return FLT128_EPSILON;
154constexpr __float128 numeric_limits<__float128>::denorm_min() noexcept
156 return FLT128_DENORM_MIN;
constexpr bool isnan(const T &x) noexcept
Extends std::isnan() to complex numbers.
Definition utils.hpp:125
constexpr real_type< T > real(const T &x) noexcept
Extends std::real() to real datatypes.
Definition utils.hpp:71
constexpr real_type< T > imag(const T &x) noexcept
Extends std::imag() to real datatypes.
Definition utils.hpp:86
constexpr bool isinf(const T &x) noexcept
Extends std::isinf() to complex numbers.
Definition utils.hpp:117