31#warning "Use of -ffast-math is unsafe for multi_double module."
44inline auto quick_two_sum(
double a,
double b) -> std::tuple<double, double> {
45 const double s = a + b;
46 const double e = b - (s - a);
57inline auto two_sum(
double a,
double b) -> std::tuple<double, double> {
58 const double s = a + b;
59 const double v = s - a;
60 const double e = (a - (s - v)) + (b - v);
70inline auto split(
double a) -> std::tuple<double, double> {
71 constexpr double coeff = 0x1.0p+27 + 1.0;
72 const double t = coeff * a;
73 const double a_h = t - (t - a);
74 const double a_l = a - a_h;
87 const double p = a * b;
88 const auto [a_h, a_l] =
split(a);
89 const auto [b_h, b_l] =
split(b);
90 const double e = ((a_h * b_h - p) + a_h * b_l + a_l * b_h) + a_l * b_l;
104inline auto two_prod_fma(
double a,
double b) -> std::tuple<double, double> {
105 const double p = a * b;
106 const __m128d a_mm = _mm_set_sd(a);
107 const __m128d b_mm = _mm_set_sd(b);
108 const __m128d p_mm = _mm_set_sd(p);
109 const __m128d e_mm = _mm_fmsub_sd(a_mm, b_mm, p_mm);
111 _mm_store_sd(&e, e_mm);
124inline auto two_prod(
double a,
double b) -> std::tuple<double, double> {
126 return two_prod_fma(a, b);
Namespace of internal implementations.
auto split(double a) -> std::tuple< double, double >
split a number to higher bits and lower bits
auto two_sum(double a, double b) -> std::tuple< double, double >
calculate sum of a and b, and error of the sum
auto two_prod_no_fma(double a, double b) -> std::tuple< double, double >
calculate product of a and b, and error of the product without FMA instructions
auto two_prod(double a, double b) -> std::tuple< double, double >
calculate product of a and b, and error of the product
auto quick_two_sum(double a, double b) -> std::tuple< double, double >
calculate sum of a and b, and error of the sum on the condition that absolute value of a is larger th...