|
dsplib 1.1.0
C++ DSP library for MATLAB-like coding
|
Moving Average Filter implementation using binary tree summation. More...
#include <ma-filter.h>
Public Member Functions | |
| MAFilter (int len) | |
| Construct a MAFilter with specified window length. | |
| MAFilter (int len, const base_array< T > &init) | |
| Construct a MAFilter with initial state. | |
| T | process (const T &in) noexcept |
| Process single input sample. | |
| base_array< T > | process (span_t< T > in) noexcept |
| Process array of input samples. | |
| T | operator() (const T &x) noexcept |
| Process single input sample (operator form) | |
| base_array< T > | operator() (span_t< T > x) noexcept |
| Process array of input samples (operator form) | |
Moving Average Filter implementation using binary tree summation.
| T | Data type for filter processing (real_t or cmplx_t recommended) |
This class implements a computationally efficient moving average (MA) filter using a binary tree structure for O(log N) per-sample processing complexity.
Key features:
The filter computes the average over a sliding window of length N:
\[ y[n] = \frac{1}{N} \sum_{k=0}^{N-1} x[n - k] \]
|
inlineexplicit |
Construct a MAFilter with specified window length.
| len | Window length (number of samples in moving average) |
| DSPLIB_ASSERT | Throws if len < 1 |
Initializes all filter states to zero.
|
inlineexplicit |
Construct a MAFilter with initial state.
| len | Window length |
| init | Initial window values |
| DSPLIB_ASSERT | Throws if init size doesn't match window length |
Initializes the filter with predefined window values. Equivalent to:
|
inlinenoexcept |
Process single input sample (operator form)
| x | Input sample |
|
inlinenoexcept |
Process array of input samples (operator form)
| x | Input array |
|
inlinenoexcept |
Process single input sample.
| in | Input sample |
Computational complexity: O(log N)
|
inlinenoexcept |
Process array of input samples.
| in | Input array |
Equivalent to sequential processing of each sample. For better performance on large arrays, consider block processing optimization.