mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
dsp: simplified moving average window
This commit is contained in:
parent
16a09548ae
commit
3de52ec60f
1 changed files with 5 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
/** A moving average filter.
|
/** A moving average window.
|
||||||
*
|
*
|
||||||
* @file
|
* @file
|
||||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||||
|
@ -23,13 +23,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <villas/window.hpp>
|
#include <villas/dsp/window.hpp>
|
||||||
|
|
||||||
namespace villas {
|
namespace villas {
|
||||||
namespace dsp {
|
namespace dsp {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class MovingAverage {
|
class MovingAverageWindow {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename Window<T>::size_type size_type;
|
typedef typename Window<T>::size_type size_type;
|
||||||
|
@ -37,14 +37,11 @@ public:
|
||||||
protected:
|
protected:
|
||||||
Window<T> window;
|
Window<T> window;
|
||||||
|
|
||||||
size_type length;
|
|
||||||
|
|
||||||
T state;
|
T state;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MovingAverage(size_type len, T i) :
|
MovingAverageWindow(size_type len, T i = 0) :
|
||||||
window(len, i),
|
window(len, i),
|
||||||
length(len),
|
|
||||||
state(i)
|
state(i)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -55,7 +52,7 @@ public:
|
||||||
state += in;
|
state += in;
|
||||||
state -= out;
|
state -= out;
|
||||||
|
|
||||||
return state / len;
|
return state / window.getSteps();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue