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

Classes

struct  mtl::math::exact_accumulator< T >
 Exact sum of products of Ts (top of file). More...

Namespaces

namespace  mtl
namespace  mtl::math
namespace  mtl::math::exact_detail

Concepts

concept  mtl::math::exact_accumulable
 Is T a type the exact accumulator is defined for: binary32 or binary64.
concept  mtl::math::exact_detail::feeds
 May a V be fed into an exact_accumulator<T>: every V is exactly a T.

Functions

template<typename T>
void mtl::math::exact_detail::decompose (T v, std::uint64_t &m, int &e)
 |v| = m * 2^e with m odd (or v == 0, m == 0). Exact for every finite T.
void mtl::math::exact_detail::mul128 (std::uint64_t a, std::uint64_t b, std::uint64_t &hi, std::uint64_t &lo)
 64 x 64 -> 128, as (hi, lo).
template<std::size_t L>
void mtl::math::exact_detail::add_shifted (std::array< std::uint64_t, L > &w, std::uint64_t hi, std::uint64_t lo, int off, bool subtract)
 acc += sign * (hi:lo) * 2^off, modulo 2^(64 * limbs).
template<typename R, std::size_t L>
R mtl::math::exact_detail::round_out (const std::array< std::uint64_t, L > &w, int lsb)
 Round the nonnegative integer w times 2^lsb to R, once, to nearest-even.
template<typename T>
void mtl::math::accumulator_clear (exact_accumulator< T > &a)
template<typename T, typename V>
requires exact_detail::feeds<V, T>
void mtl::math::accumulator_add_product (exact_accumulator< T > &a, const V &m, const V &v)
template<typename T, typename V>
requires exact_detail::feeds<V, T>
void mtl::math::accumulator_assign (exact_accumulator< T > &a, const V &v)
template<typename T>
void mtl::math::accumulator_merge (exact_accumulator< T > &a, const exact_accumulator< T > &b)
 a += b, exactly: the finite parts add without rounding, the special states combine.
template<typename T, typename R>
requires exact_accumulable<R>
R mtl::math::accumulator_value (const exact_accumulator< T > &a, std::type_identity< R >)
 The single round-out, to nearest-even, of the exact sum to R (float or double).