/** A moving average window. * * @file * @author Steffen Vogel * @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC * @license Apache License 2.0 *********************************************************************************/ #pragma once #include #include namespace villas { namespace dsp { template class MovingAverageWindow : public Window { protected: T state; public: MovingAverageWindow(size_t len, T i = 0) : Window(len, i), state(i) { } T update(T in) { T out = Window::update(in); state += in; state -= out; return state / (double) Window::getLength(); } }; } /* namespace dsp */ } /* namespace villas */