1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

moving_average_window: innherit from window class

This commit is contained in:
Steffen Vogel 2019-04-17 18:08:31 +02:00
parent ec9daf8d62
commit 0e3e43005f

View file

@ -23,36 +23,32 @@
#pragma once
#include <stddef.h>
#include <villas/dsp/window.hpp>
namespace villas {
namespace dsp {
template<typename T>
class MovingAverageWindow {
public:
typedef typename Window<T>::size_type size_type;
class MovingAverageWindow : public Window<T> {
protected:
Window<T> window;
T state;
public:
MovingAverageWindow(size_type len, T i = 0) :
window(len, i),
MovingAverageWindow(size_t len, T i = 0) :
Window<T>(len, i),
state(i)
{ }
T update(T in)
{
T out = window.update(in);
T out = Window<T>::update(in);
state += in;
state -= out;
return state / window.getSteps();
return state / (double) Window<T>::getLength();
}
};