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:
parent
ec9daf8d62
commit
0e3e43005f
1 changed files with 6 additions and 10 deletions
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue