3#include <dsplib/math.h>
4#include <dsplib/array.h>
43 , buf_((1 << (d_ + 1)) - 1, T{0}) {
44 DSPLIB_ASSERT(len >= 1,
"window len must be positive");
61 DSPLIB_ASSERT(init.size() == w_,
"init size mismatch");
62 for (
int i = 0; i < w_; i++) {
79 int k = (1 << d_) - 1 + pos_;
83 buf_[k] = buf_[2 * k + 1] + buf_[2 * k + 2];
85 pos_ = (pos_ + 1) % w_;
102 const int n = in.size();
104 for (
int i = 0; i < n; i++) {
143using MAFilterR = MAFilter<real_t>;
149using MAFilterC = MAFilter<cmplx_t>;
Moving Average Filter implementation using binary tree summation.
Definition ma-filter.h:29
MAFilter(int len)
Construct a MAFilter with specified window length.
Definition ma-filter.h:40
T process(const T &in) noexcept
Process single input sample.
Definition ma-filter.h:74
base_array< T > operator()(span_t< T > x) noexcept
Process array of input samples (operator form)
Definition ma-filter.h:128
MAFilter(int len, const base_array< T > &init)
Construct a MAFilter with initial state.
Definition ma-filter.h:59
T operator()(const T &x) noexcept
Process single input sample (operator form)
Definition ma-filter.h:117
base_array< T > process(span_t< T > in) noexcept
Process array of input samples.
Definition ma-filter.h:97
base dsplib array type
Definition array.h:25