ITK
5.2.0
Insight Toolkit
|
#include <itkCompensatedSummation.h>
Public Types | |
using | AccumulateType = typename NumericTraits< FloatType >::AccumulateType |
using | FloatType = TFloat |
using | Self = CompensatedSummation |
AccumulateType | m_Sum |
AccumulateType | m_Compensation |
CompensatedSummation () | |
CompensatedSummation (FloatType value) | |
CompensatedSummation (const Self &rhs) | |
Self & | operator= (const Self &rhs) |
void | AddElement (const FloatType &element) |
Self & | operator+= (const FloatType &rhs) |
Self & | operator+= (const Self &rhs) |
Self & | operator-= (const FloatType &rhs) |
Self & | operator*= (const FloatType &rhs) |
Self & | operator/= (const FloatType &rhs) |
void | ResetToZero () |
Self & | operator= (const FloatType &rhs) |
const AccumulateType & | GetSum () const |
operator FloatType () const | |
Perform more precise accumulation of floating point numbers.
The float
and double
datatypes only have finite precision. When performing a running sum of floats, the accumulated errors get progressively worse as the magnitude of the sum gets large relative to new elements.
From Wikipedia, http://en.wikipedia.org/wiki/Kahan_summation_algorithm
"In numerical analysis, the Kahan summation algorithm (also known as compensated summation) significantly reduces the numerical error in the total obtained by adding a sequence of finite precision floating point numbers, compared to the obvious approach. This is done by keeping a separate running compensation (a variable to accumulate small errors)."
For example, instead of
do
Definition at line 66 of file itkCompensatedSummation.h.
using itk::CompensatedSummation< TFloat >::AccumulateType = typename NumericTraits<FloatType>::AccumulateType |
Type used for the sum and compensation.
Definition at line 73 of file itkCompensatedSummation.h.
using itk::CompensatedSummation< TFloat >::FloatType = TFloat |
Type of the input elements.
Definition at line 70 of file itkCompensatedSummation.h.
using itk::CompensatedSummation< TFloat >::Self = CompensatedSummation |
Standard class type aliases.
Definition at line 76 of file itkCompensatedSummation.h.
itk::CompensatedSummation< TFloat >::CompensatedSummation | ( | ) |
Constructors.
itk::CompensatedSummation< TFloat >::CompensatedSummation | ( | FloatType | value | ) |
Constructors.
itk::CompensatedSummation< TFloat >::CompensatedSummation | ( | const Self & | rhs | ) |
Copy constructor.
void itk::CompensatedSummation< TFloat >::AddElement | ( | const FloatType & | element | ) |
Add an element to the sum.
const AccumulateType& itk::CompensatedSummation< TFloat >::GetSum | ( | ) | const |
Get the sum.
|
explicit |
explicit conversion
Self& itk::CompensatedSummation< TFloat >::operator*= | ( | const FloatType & | rhs | ) |
Division and multiplication. These do not provide any numerical advantages relative to vanilla division and multiplication.
Self& itk::CompensatedSummation< TFloat >::operator+= | ( | const FloatType & | rhs | ) |
Constructors.
Self& itk::CompensatedSummation< TFloat >::operator+= | ( | const Self & | rhs | ) |
Constructors.
Self& itk::CompensatedSummation< TFloat >::operator-= | ( | const FloatType & | rhs | ) |
Subtract an element from the sum.
Self& itk::CompensatedSummation< TFloat >::operator/= | ( | const FloatType & | rhs | ) |
Constructors.
Self& itk::CompensatedSummation< TFloat >::operator= | ( | const FloatType & | rhs | ) |
Reset the sum to the given value and the compensation to zero.
Self& itk::CompensatedSummation< TFloat >::operator= | ( | const Self & | rhs | ) |
Assignment operator.
void itk::CompensatedSummation< TFloat >::ResetToZero | ( | ) |
Reset the sum and compensation to zero.
|
private |
Constructors.
Definition at line 128 of file itkCompensatedSummation.h.
|
private |
Constructors.
Definition at line 127 of file itkCompensatedSummation.h.