MySQL 9.6.0
Source Code Documentation
mysql::math::Kahan_sum< Value_tp > Class Template Reference

Tracks the state of the Kahan summation algorithm, which produces a sum over a sequence of floating point numbers with very low numeric error, using an internal error compensation term. More...

#include <summation.h>

Public Types

using Value_t = Value_tp
 

Public Member Functions

 Kahan_sum (Value_t value=0)
 
 operator Value_t () const
 Return the current approximated sum. More...
 
Kahan_sumoperator+= (const Value_t &value)
 In-place add the given value to this object. More...
 
Kahan_sumoperator-= (const Value_t &value)
 In-place subtract the given value from this object. More...
 
Kahan_sum operator+ (const Value_t &value) const
 Return a new object holding the sum of this object and the given value. More...
 
Kahan_sum operator- (const Value_t &value) const
 Return a new object holding this object minus the given value. More...
 

Private Attributes

Value_t m_sum
 
Value_t m_compensation {0}
 

Detailed Description

template<class Value_tp = double>
class mysql::math::Kahan_sum< Value_tp >

Tracks the state of the Kahan summation algorithm, which produces a sum over a sequence of floating point numbers with very low numeric error, using an internal error compensation term.

Template Parameters
Value_tpThe numeric type used in internal computations, and to store the result.

Member Typedef Documentation

◆ Value_t

template<class Value_tp = double>
using mysql::math::Kahan_sum< Value_tp >::Value_t = Value_tp

Constructor & Destructor Documentation

◆ Kahan_sum()

template<class Value_tp = double>
mysql::math::Kahan_sum< Value_tp >::Kahan_sum ( Value_t  value = 0)
inlineexplicit

Member Function Documentation

◆ operator Value_t()

template<class Value_tp = double>
mysql::math::Kahan_sum< Value_tp >::operator Value_t ( ) const
inlineexplicit

Return the current approximated sum.

◆ operator+()

template<class Value_tp = double>
Kahan_sum mysql::math::Kahan_sum< Value_tp >::operator+ ( const Value_t value) const
inline

Return a new object holding the sum of this object and the given value.

◆ operator+=()

template<class Value_tp = double>
Kahan_sum & mysql::math::Kahan_sum< Value_tp >::operator+= ( const Value_t value)
inline

In-place add the given value to this object.

◆ operator-()

template<class Value_tp = double>
Kahan_sum mysql::math::Kahan_sum< Value_tp >::operator- ( const Value_t value) const
inline

Return a new object holding this object minus the given value.

◆ operator-=()

template<class Value_tp = double>
Kahan_sum & mysql::math::Kahan_sum< Value_tp >::operator-= ( const Value_t value)
inline

In-place subtract the given value from this object.

Member Data Documentation

◆ m_compensation

template<class Value_tp = double>
Value_t mysql::math::Kahan_sum< Value_tp >::m_compensation {0}
private

◆ m_sum

template<class Value_tp = double>
Value_t mysql::math::Kahan_sum< Value_tp >::m_sum
private

The documentation for this class was generated from the following file: