Lodestar
An integrated real-time control package in C++
|
|
5 #ifndef LODESTAR_SIMPLEMOVINGAVERAGE_HPP
6 #define LODESTAR_SIMPLEMOVINGAVERAGE_HPP
8 #include "Lodestar/aux/ArrayStack.hpp"
33 template<
typename TType =
double,
size_t TWindowSize = 1>
45 void push(
const TType &value)
66 for (
int i = 0; i < window_.
size(); i++)
69 return ret / window_.
size();
85 inline size_t size() const noexcept
87 return window_.
size();
95 inline constexpr
size_t max_size() const noexcept
106 #endif //LODESTAR_SIMPLEMOVINGAVERAGE_HPP
A statically sized simple moving average filter.
Definition: SimpleMovingAverage.hpp:34
void clear() noexcept
Clears the stack.
Definition: ArrayStack.hpp:68
size_t size() const noexcept
Returns the current window size.
Definition: SimpleMovingAverage.hpp:85
TType average() const
Compute unweighted average of elements in window.
Definition: SimpleMovingAverage.hpp:58
void clear() noexcept
Clears the window.
Definition: SimpleMovingAverage.hpp:75
void push(const TType &value)
Push value to moving average window.
Definition: SimpleMovingAverage.hpp:45
Main Lodestar code.
Definition: BilinearTransformation.hpp:12
bool empty() const noexcept
Returns true if stack is empty.
Definition: ArrayStack.hpp:131
constexpr size_t max_size() const noexcept
Returns the maximum window size.
Definition: SimpleMovingAverage.hpp:95
A statically sized stack with full member access.
Definition: ArrayStack.hpp:21
size_t size() const noexcept
Gives current stack size.
Definition: ArrayStack.hpp:47
void push(const TType &value)
Pushes value to front of ArrayStack.
Definition: ArrayStack.hpp:144