/* A moving average window. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University * SPDX-License-Identifier: Apache-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