22#ifndef LSST_AFW_MATH_POLYNOMIALS_SafeSum_h_INCLUDED
23#define LSST_AFW_MATH_POLYNOMIALS_SafeSum_h_INCLUDED
65 explicit SafeSum(T initial=
static_cast<T
>(0)) noexcept :
67 _correction(static_cast<T>(0))
72 _correction =
static_cast<T
>(0);
80 if (std::abs(_sum) >= std::abs(value)) {
81 _correction += (_sum - t) + value;
83 _correction += (value - t) + _sum;
93 explicit operator T() const noexcept {
94 return _sum + _correction;
SafeSum & operator-=(T value) noexcept
SafeSum & operator+=(T value) noexcept
SafeSum(T initial=static_cast< T >(0)) noexcept
SafeSum & operator=(T value) noexcept
Low-level polynomials (including special polynomials) in C++.
SumMode
Enum used to control how to sum polynomial terms.
@ SAFE
Compensated summation using SafeSum. Involves ~4x as many floating point operations.
@ FAST
Summation using regular floating-point addition.