MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
sum_dot_k.hpp File Reference
#include <cassert>
#include <cstddef>
#include <type_traits>
#include <vector>
#include <mtl/concepts/collection.hpp>
#include <mtl/concepts/vector.hpp>
#include <mtl/math/error_free.hpp>

Namespaces

namespace  mtl
namespace  mtl::detail
 mat*vec multiply into pre-allocated y: y = A * x.

Functions

template<typename T>
void mtl::detail::vec_sum (std::vector< T > &p)
 VecSum (Algorithm 4.3): p_i, p_{i-1} = TwoSum(p_i, p_{i-1}) for i = 2..n.
template<typename T>
T mtl::detail::sum_k_inplace (std::vector< T > &p, int K)
 SumK (Algorithm 4.8) on a vector it may overwrite: K - 1 VecSum passes, then fl(sum_{i<n} p_i + p_n).
template<int K, Collection C>
requires (K >= 1) && math::binary_floating_point<typename C::value_type>
auto mtl::sum_k (const C &x)
 The sum of x as if computed in K-fold working precision and rounded once: Ogita-Rump-Oishi SumK (K >= 2), and the plain recursive sum for K = 1.
template<int K, Vector V1, Vector V2>
requires (K >= 2) && std::is_same_v<typename V1::value_type, typename V2::value_type> && math::binary_floating_point<typename V1::value_type>
auto mtl::dot_k (const V1 &x, const V2 &y)
 The dot product of x and y as if computed in K-fold working precision and rounded once: Dot2 (Algorithm 5.3) for K = 2, DotK (Algorithm 5.10) for K >= 3.