template<typename T>
hub::Kahan struct

Kahan number

A way to reduce the round off error when adding a small number to a big one. See details in Kahan summation

Constructors, destructors, conversion operators

Kahan() defaulted
Kahan(T r) constexpr
Kahan(const Kahan& k) constexpr
operator T() constexpr
operator T() const constexpr

Public functions

void zero_err()

Friends

auto operator-(const Kahan& hs) -> Kahan
auto operator+=(Kahan& lhs, const Kahan& rhs) -> Kahan&
auto operator-=(Kahan& lhs, const Kahan& rhs) -> Kahan&
auto operator/=(Kahan& lhs, const Kahan& rhs) -> Kahan&
auto operator*=(Kahan& lhs, const Kahan& rhs) -> Kahan&
auto operator<<(std::ostream& output, const Kahan& v) -> std::ostream&
auto operator>>(std::istream& input, Kahan& v) -> std::istream&

Function documentation

template<typename T>
hub::Kahan<T>::Kahan() defaulted

Default constructor

template<typename T>
hub::Kahan<T>::Kahan(T r) constexpr

Parameters
r Scalar

Single parameter constructor.

template<typename T>
hub::Kahan<T>::Kahan(const Kahan& k) constexpr

Parameters
k

Copy constructor.

template<typename T>
hub::Kahan<T>::operator T() constexpr

Assignment operator. Conversion operator. Convert Khan number to Scalar i.e double, float,...

template<typename T>
hub::Kahan<T>::operator T() const constexpr

Conversion operator. Convert Khan number to Scalar i.e double, float,...

template<typename T>
void hub::Kahan<T>::zero_err()

Set error to 0.

template<typename T>
Kahan operator-(const Kahan& hs)

Opposite operator.

template<typename T>
Kahan& operator+=(Kahan& lhs, const Kahan& rhs)

Addition assignment operator.

template<typename T>
Kahan& operator-=(Kahan& lhs, const Kahan& rhs)

Subtraction assignment operator.

template<typename T>
Kahan& operator/=(Kahan& lhs, const Kahan& rhs)

Division assignment operator.

template<typename T>
Kahan& operator*=(Kahan& lhs, const Kahan& rhs)

Multiple assignment operator.

template<typename T>
std::ostream& operator<<(std::ostream& output, const Kahan& v)

Output stream

template<typename T>
std::istream& operator>>(std::istream& input, Kahan& v)

Input stream