47 if (__builtin_popcount(v) == 1) {
return __builtin_ctz(v) - 1; }
49 uint8_t next_pow_of_2{ 0 };
57 return --next_pow_of_2;
78template< u
int8_t A = 10 >
Implements an Exponentially Weighted Moving Average (EWMA).
void addValue(int32_t input)
Add a new value and update the EMA, DEMA, and TEMA.
auto getAverageD() const
Get the Double Exponentially Weighted Moving Average (DEMA).
auto getAverageT() const
Get the Triple Exponentially Weighted Moving Average (TEMA).
auto getAverageS() const
Get the Exponentially Weighted Moving Average (EMA).
constexpr uint8_t round_up_to_power_of_2(uint16_t v)
Helper compile-time function to retrieve the previous power of 2 of the given number (120 => 64 => 6)
Some useful but missing stl functions templates.