OpenWareLaboratory
SmoothValue< T > Class Template Reference

Applies exponential smoothing to a scalar value. More...

Public Member Functions

getValue ()
 
template<>
float normal (float lambda, int blocksize)
 
template<>
int normal (float lambda, int blocksize)
 
 operator T ()
 
SmoothValue< T > & operator*= (const T &other)
 
SmoothValue< T > & operator+= (const T &other)
 
SmoothValue< T > & operator-= (const T &other)
 
SmoothValue< T > & operator/= (const T &other)
 
SmoothValue< T > & operator= (const T &other)
 
void reset (T newValue)
 
 SmoothValue ()
 
 SmoothValue (T lambda)
 
 SmoothValue (T lambda, T initialValue)
 
 SmoothValue (const SmoothValue< T > &other)
 
void update (T newValue)
 

Static Public Member Functions

static T normal (float lambda, int blocksize)
 

Data Fields

lambda
 

Detailed Description

template<typename T>
class SmoothValue< T >

Applies exponential smoothing to a scalar value.

y(n) = lambda*y(n-1) + (1.0-lambda)*y(n) for floats y(n) = (lambda*y(n-1) + y(n))/(lambda+1) for ints Smoothing is applied when the value is written to, not when it is read. todo: adjust for sampling frequency / blocksize (time delay of the response (mean) is 1/α data points) https://en.wikipedia.org/wiki/Exponential_smoothing

Definition at line 13 of file SmoothValue.h.

Constructor & Destructor Documentation

SmoothFloat::SmoothValue ( )

Definition at line 5 of file SmoothValue.cpp.

template<typename T>
SmoothValue< T >::SmoothValue ( lambda)
template<typename T>
SmoothValue< T >::SmoothValue ( lambda,
initialValue 
)
template<typename T>
SmoothValue< T >::SmoothValue ( const SmoothValue< T > &  other)
inline

Definition at line 21 of file SmoothValue.h.

Member Function Documentation

template<typename T>
T SmoothValue< T >::getValue ( )
inline

Definition at line 29 of file SmoothValue.h.

Referenced by SmoothValue< T >::operator T().

template<>
float SmoothValue< float >::normal ( float  lambda,
int  blocksize 
)

Definition at line 50 of file SmoothValue.cpp.

template<typename T>
static T SmoothValue< T >::normal ( float  lambda,
int  blocksize 
)
static
template<>
int SmoothValue< int >::normal ( float  lambda,
int  blocksize 
)

Definition at line 55 of file SmoothValue.cpp.

template<typename T>
SmoothValue< T >::operator T ( )
inline

Definition at line 52 of file SmoothValue.h.

References SmoothValue< T >::getValue().

template<typename T>
SmoothValue<T>& SmoothValue< T >::operator*= ( const T &  other)
inline

Definition at line 44 of file SmoothValue.h.

References SmoothValue< T >::update().

template<typename T>
SmoothValue<T>& SmoothValue< T >::operator+= ( const T &  other)
inline

Definition at line 36 of file SmoothValue.h.

References SmoothValue< T >::update().

template<typename T>
SmoothValue<T>& SmoothValue< T >::operator-= ( const T &  other)
inline

Definition at line 40 of file SmoothValue.h.

References SmoothValue< T >::update().

template<typename T>
SmoothValue<T>& SmoothValue< T >::operator/= ( const T &  other)
inline

Definition at line 48 of file SmoothValue.h.

References SmoothValue< T >::update().

template<typename T>
SmoothValue<T>& SmoothValue< T >::operator= ( const T &  other)
inline

Definition at line 32 of file SmoothValue.h.

References SmoothValue< T >::update().

template<typename T>
void SmoothValue< T >::reset ( newValue)
inline

Definition at line 26 of file SmoothValue.h.

Field Documentation

template<typename T>
T SmoothValue< T >::lambda

Definition at line 17 of file SmoothValue.h.


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