MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
error_free.hpp File Reference
#include <cmath>
#include <concepts>
#include <cstdint>
#include <limits>
#include <type_traits>

Classes

struct  mtl::math::exact_pair< T >
 The exact result of one operation as hi + lo: hi the rounded result, lo its rounding error. More...

Namespaces

namespace  mtl
namespace  mtl::math
namespace  mtl::math::error_free_detail

Concepts

concept  mtl::math::binary_floating_point
 Binary IEEE floating point: the types the error-free transformations hold for.

Typedefs

template<typename T>
using mtl::math::split_product = exact_pair<T>
 The name two_product returned before the other transformations (#602).

Functions

template<typename T>
requires binary_floating_point<T>
exact_pair< T > mtl::math::two_sum (T a, T b)
 Knuth's TwoSum: a + b == hi + lo for any a, b, with hi = fl(a + b).
template<typename T>
requires binary_floating_point<T>
exact_pair< T > mtl::math::fast_two_sum (T a, T b)
 Dekker's FastTwoSum: a + b == hi + lo, provided |a| >= |b| (more precisely, exponent(a) >= exponent(b), or a == 0).
template<typename T>
requires std::is_floating_point_v<T>
exact_pair< T > mtl::math::two_product (T a, T b)
 The error-free product with an FMA: a * b == hi + lo, hi = fl(a * b).
template<typename T>
constexpr T mtl::math::error_free_detail::pow2 (int e)
template<typename T>
requires binary_floating_point<T>
exact_pair< T > mtl::math::split (T a)
 Veltkamp's Split: a == hi + lo exactly, with hi at most digits - s significant bits and lo at most s - 1 (s = ceil(digits / 2)): 26 and 26 for double, 12 and 11 for float.
template<typename T>
requires binary_floating_point<T>
exact_pair< T > mtl::math::two_product_dekker (T a, T b)
 Dekker's TwoProduct, without an FMA: a * b == hi + lo, hi = fl(a * b).

Variables

template<typename T>
constexpr int mtl::math::error_free_detail::split_shift = (std::numeric_limits<T>::digits + 1) / 2
 Veltkamp's splitting point: s = ceil(digits / 2), factor = 2^s + 1.
template<typename T>
constexpr T mtl::math::error_free_detail::split_factor = T((std::uint64_t(1) << split_shift<T>) + 1)
template<typename T>
constexpr T mtl::math::error_free_detail::split_limit = pow2<T>(std::numeric_limits<T>::max_exponent - split_shift<T> - 1)
 The end of split's domain, 2^(max_exponent - s - 1): factor * a is at most 2^(max_exponent - 1) + 2^(max_exponent - s - 1), so it cannot overflow.