BazisLib::_ExponentialFilter< _T, _Divider > Class Template Reference

Provides exponential filtration for some data stream. More...

#include <filters.h>

List of all members.

Public Member Functions

 _ExponentialFilter (_T FilteringCoef)
void ResetValue (_T Value)
 Forcibly resets the filtered value.
void SetCoef (_T Coef)
 Updates the filtering coefficient.
_T UpdateValue (_T Value)
 Takes the new value and returns the filtered one.
_T GetValue ()
 Returns last filtered value.

Private Attributes

_T m_Value
_T m_FilteringCoef


Detailed Description

template<class _T, _T _Divider>
class BazisLib::_ExponentialFilter< _T, _Divider >

Provides exponential filtration for some data stream.

The _ExponentialFilter template allows filtering some set of values according to the exponential law (value = old + delta * coef, where coef < 1)

Parameters:
_T Represents value type. Can be double, int, LONGLONG, etc.
_Divider Represents the divider part of the coefficient the multiplier is specified on construction and can be changed during operation. The real coefficient is determined as Coef / _Divider. This parameter allows avoiding floating point operations for integer data types by specifying filtering coefficient as integer divided by constant integer (template parameter).
Remarks:
Note that this type of filter is less accurate than sliding average filter, however it consumes less memory and is faster and simplier. The typical use case is the following:
ExponentialFilterI32 filter(500);	//500/1000 means 1/2, 1000 is the divider set for ExponentialFilterI32
...
for (...)
{
	...
	int val = GetNextValue();
	val = filter.UpdateValue(val);
	DoSomethingWithNextValue(val);
	...
}

Constructor & Destructor Documentation

template<class _T , _T _Divider>
BazisLib::_ExponentialFilter< _T, _Divider >::_ExponentialFilter ( _T  FilteringCoef  )  [inline]


Member Function Documentation

template<class _T , _T _Divider>
_T BazisLib::_ExponentialFilter< _T, _Divider >::GetValue (  )  [inline]

Returns last filtered value.

template<class _T , _T _Divider>
void BazisLib::_ExponentialFilter< _T, _Divider >::ResetValue ( _T  Value  )  [inline]

Forcibly resets the filtered value.

template<class _T , _T _Divider>
void BazisLib::_ExponentialFilter< _T, _Divider >::SetCoef ( _T  Coef  )  [inline]

Updates the filtering coefficient.

This method updates the filtering coefficient.

Parameters:
Coef Specifies the coefficient. The real one equals to Coef / _Divider, where _Divider is the template parameter.

template<class _T , _T _Divider>
_T BazisLib::_ExponentialFilter< _T, _Divider >::UpdateValue ( _T  Value  )  [inline]

Takes the new value and returns the filtered one.


Member Data Documentation

template<class _T , _T _Divider>
_T BazisLib::_ExponentialFilter< _T, _Divider >::m_FilteringCoef [private]

template<class _T , _T _Divider>
_T BazisLib::_ExponentialFilter< _T, _Divider >::m_Value [private]


The documentation for this class was generated from the following file:
SourceForge.net Logo