template<std::size_t n>
okapi::MedianFilter class

A filter which returns the median value of list of values.

Template parameters
n number of taps in the filter

Base classes

class Filter

Constructors, destructors, conversion operators

MedianFilter()

Public functions

auto filter(const double ireading) -> double override
Filters a value, like a sensor reading.
auto getOutput() const -> double override
Returns the previous output from filter.

Protected functions

auto kth_smallset() -> double
Algorithm from N.

Protected variables

std::array<double, n> data
std::size_t index
double output
const size_t middleIndex

Function documentation

template<std::size_t n>
double okapi::MedianFilter<n>::filter(const double ireading) override

Filters a value, like a sensor reading.

Parameters
ireading new measurement
Returns filtered result

template<std::size_t n>
double okapi::MedianFilter<n>::getOutput() const override

Returns the previous output from filter.

Returns the previous output from filter

template<std::size_t n>
double okapi::MedianFilter<n>::kth_smallset() protected

Algorithm from N.

Wirth’s book, implementation by N. Devillard.