A statically sized simple moving average filter. More...
#include <SimpleMovingAverage.hpp>
Public Types | |
typedef ls::aux::ArrayStack< TType, TWindowSize > | TDWindow |
Public Member Functions | |
void | push (const TType &value) |
Push value to moving average window. More... | |
TType | average () const |
Compute unweighted average of elements in window. More... | |
void | clear () noexcept |
Clears the window. | |
size_t | size () const noexcept |
Returns the current window size. More... | |
constexpr size_t | max_size () const noexcept |
Returns the maximum window size. More... | |
Protected Attributes | |
TDWindow | window_ |
A statically sized simple moving average filter.
A simple moving average is the unweighted average of the elements that are currently in the buffer, of which there are at most TWindowSize
; the buffer is also known as the 'window':
TType | Type of element; must be addable with itself, and divisible by an unsigned integer. |
TWindowSize | Maximum size of the window. |
|
inline |
Compute unweighted average of elements in window.
If there are no elements in the window, the value produced by the default constructor of TType
is returned.
|
inlineconstexprnoexcept |
Returns the maximum window size.
|
inline |
Push value to moving average window.
value | Value to be included in moving average. |
|
inlinenoexcept |
Returns the current window size.