Filter is pure virtual class describing the basic virtual interface for all filters More...
#include <Filter.h>
Public Member Functions | |
Filter () | |
Constructor. | |
double | get () const |
Get the latest value. | |
virtual double | next (double y)=0 |
Update the value. All inherited classes need to update value in next(). | |
operator double () | |
Get the latest value. | |
virtual void | reset ()=0 |
Reset the filter state. | |
Protected Attributes | |
double | value |
Filter is pure virtual class describing the basic virtual interface for all filters
Basic usage:
FilterAverage a(3); cout<<a.next(3)<<endl; cout<<a.next(3.2)<<endl; cout<<a.next(1.3)<<endl; cout<<a.next(2.9)<<endl;
The Filter library provides also the assignment operators (operator=) to simplify the process where you want to replace existing double's in code with filtered values. For example if you want to filter the d over time in the following code...
...you can add filter just by replacing the double with the selected filter:
FilterDoubleExponentialSmoothing d(0.2,0.5); cout<<(d = 3)<<endl; cout<<(d = 3.2)<<endl; cout<<(d = 1.3)<<endl; cout<<(d = 2.9)<<endl;
However, using the assignment operator for setting time series data is a little counter-intuitive, so please use next() instead when possible.
Filter::Filter | ( | ) |
Constructor.
Definition at line 37 of file Filter.cpp.
double alvar::Filter::get | ( | ) | const [inline] |
virtual double alvar::Filter::next | ( | double | y | ) | [pure virtual] |
Update the value. All inherited classes need to update value in next().
Implemented in alvar::FilterDoubleExponentialSmoothing, alvar::FilterRunningAverage, alvar::FilterMedian, and alvar::FilterAverage.
alvar::Filter::operator double | ( | ) | [inline] |
virtual void alvar::Filter::reset | ( | ) | [pure virtual] |
Reset the filter state.
Implemented in alvar::FilterRunningAverage, and alvar::FilterAverage.
double alvar::Filter::value [protected] |