HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
AccurateSum< SampleType > Class Template Reference

Implements Kahan algorithm for floating point accumulations. More...

#include <hart_accurate_sum.hpp>

Public Member Functions

 AccurateSum (SampleType initialSum=(SampleType) 0)
 Inits AccurateSum with a specific value.
 
AccurateSumoperator= (SampleType initialSum)
 Assigns AccurateSum's accumulated sum to a specific value.
 
AccurateSumoperator+= (SampleType value)
 Adds a value to a sum, tracking the potential floating point error.
 
 operator SampleType () const
 Value accumulated by the += operator.
 
template<typename RequestedType >
RequestedType get () const
 Value accumulated by the += operator, converted to the requested type.
 
SampleType getValue () const
 

Detailed Description

template<typename SampleType>
class hart::AccurateSum< SampleType >

Implements Kahan algorithm for floating point accumulations.

Template Parameters
SampleTypeType of values to accumulate, typically float or double

Definition at line 10 of file hart_accurate_sum.hpp.

Constructor & Destructor Documentation

◆ AccurateSum()

template<typename SampleType >
AccurateSum ( SampleType  initialSum = (SampleType) 0)
inline

Inits AccurateSum with a specific value.

Parameters
initialSumInitial sum value

Definition at line 15 of file hart_accurate_sum.hpp.

Member Function Documentation

◆ operator=()

template<typename SampleType >
AccurateSum & operator= ( SampleType  initialSum)
inline

Assigns AccurateSum's accumulated sum to a specific value.

Parameters
initialSumInitial sum value

Definition at line 23 of file hart_accurate_sum.hpp.

◆ operator+=()

template<typename SampleType >
AccurateSum & operator+= ( SampleType  value)
inline

Adds a value to a sum, tracking the potential floating point error.

Parameters
valueValue to add to the sum
Returns
Reference to updated AccurateSum

Definition at line 33 of file hart_accurate_sum.hpp.

◆ operator SampleType()

template<typename SampleType >
operator SampleType ( ) const
inline

Value accumulated by the += operator.

Definition at line 43 of file hart_accurate_sum.hpp.

◆ get()

template<typename SampleType >
template<typename RequestedType >
RequestedType get ( ) const
inline

Value accumulated by the += operator, converted to the requested type.

Definition at line 50 of file hart_accurate_sum.hpp.

◆ getValue()

template<typename SampleType >
SampleType getValue ( ) const
inline

Definition at line 55 of file hart_accurate_sum.hpp.


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