numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
|
Class to add numbers using Kahan summation [14]. More...
#include <num_collect/util/kahan_adder.h>
Public Member Functions | |
kahan_adder () | |
Constructor. | |
kahan_adder (const T &zero) | |
Construct with zero number. | |
auto | add (const T &value) -> kahan_adder & |
Add a number. | |
operator T () const | |
Get sum. | |
auto | operator+= (const T &value) -> kahan_adder & |
Add a number. | |
auto | operator-= (const T &value) -> kahan_adder & |
Subtract a number. | |
auto | sub (const T &value) -> kahan_adder & |
Subtract a number. | |
auto | sum () const noexcept -> const T & |
Get sum. | |
Private Attributes | |
T | prev_sum_ |
Previous sum. | |
T | rem_ |
Remaining. | |
T | sum_ |
Sum. | |
Class to add numbers using Kahan summation [14].
T | Type of numbers. |
Definition at line 32 of file kahan_adder.h.
|
inline |
Constructor.
Definition at line 40 of file kahan_adder.h.
|
inlineexplicit |
Construct with zero number.
This constructor is useful for Eigen's vectors and matrices.
[in] | zero | Zero. |
Definition at line 49 of file kahan_adder.h.
|
inline |
Add a number.
[in] | value | Added value. |
Definition at line 58 of file kahan_adder.h.
|
inline |
|
inline |
Add a number.
[in] | value | Added value. |
Definition at line 86 of file kahan_adder.h.
|
inline |
Subtract a number.
[in] | value | Added value. |
Definition at line 97 of file kahan_adder.h.
|
inline |
Subtract a number.
[in] | value | Added value. |
Definition at line 72 of file kahan_adder.h.
|
inlinenodiscardnoexcept |
|
private |
Previous sum.
Definition at line 126 of file kahan_adder.h.
|
private |
Remaining.
Definition at line 123 of file kahan_adder.h.
|
private |
Sum.
Definition at line 120 of file kahan_adder.h.