#ifndef _EWMA_H #define _EWMA_H #include #include /* Exponentially weighted moving average (EWMA) */ /* For more documentation see ewma.c */ struct ewma { long double internal; long double weight; long double weight_recip; }; extern bool ewma_init(struct ewma *avg, long double weight); extern struct ewma *ewma_add(struct ewma *avg, long double val); /** * ewma_read() - Get average value * @avg: Average structure * * Returns the average value held in @avg. */ static inline long long int ewma_read_ll(const struct ewma *avg) { return llrintl(avg->internal); } static inline long double ewma_read_ld(const struct ewma *avg) { return avg->internal; } #endif