Antkeeper
0.0.1
|
Calculates a moving average. More...
#include <moving-average.hpp>
Public Types | |
using | sample_type = T |
Type of value to average. More... | |
Public Member Functions | |
sample_type | operator() (sample_type value) noexcept |
Adds a sample to the moving average. More... | |
void | reset () noexcept |
Resets the moving average. More... | |
void | reserve (std::size_t capacity) |
Changes the sample capacity of the moving average. More... | |
void | resize (std::size_t size) |
Changes the current number of samples of the moving average. More... | |
constexpr sample_type * | data () const noexcept |
Returns a pointer to the sample data. More... | |
sample_type | average () const noexcept |
Returns the current moving average value. More... | |
sample_type | sum () const noexcept |
Returns the sum of all current samples. More... | |
std::size_t | size () const noexcept |
Returns the current number of samples. More... | |
constexpr std::size_t | capacity () const noexcept |
Returns the maximum number of samples. More... | |
constexpr bool | empty () const noexcept |
Return true if there are currently no samples in the average, false otherwise. More... | |
constexpr bool | full () const noexcept |
Return true if the number of samples in the average has reached its capacity, false otherwise. More... | |
moving_average (std::size_t capacity) | |
Constructs a moving average. More... | |
moving_average () noexcept=default | |
Constructs a moving average. More... | |
Calculates a moving average.
T | Sample value type. |
Definition at line 35 of file moving-average.hpp.
using math::moving_average< T >::sample_type = T |
Type of value to average.
Definition at line 39 of file moving-average.hpp.
|
inlineexplicit |
Constructs a moving average.
capacity | Sample capacity. |
Definition at line 47 of file moving-average.hpp.
|
defaultnoexcept |
Constructs a moving average.
capacity | Sample capacity. |
|
inlinenoexcept |
Returns the current moving average value.
Definition at line 122 of file moving-average.hpp.
|
inlineconstexprnoexcept |
Returns the maximum number of samples.
Definition at line 140 of file moving-average.hpp.
|
inlineconstexprnoexcept |
Returns a pointer to the sample data.
Definition at line 116 of file moving-average.hpp.
|
inlineconstexprnoexcept |
Return true
if there are currently no samples in the average, false
otherwise.
Definition at line 146 of file moving-average.hpp.
|
inlineconstexprnoexcept |
Return true
if the number of samples in the average has reached its capacity, false
otherwise.
Definition at line 152 of file moving-average.hpp.
|
inlinenoexcept |
Adds a sample to the moving average.
If the moving average has reached its sample capacity, the oldest sample will be discarded.
value | Sample value. |
Definition at line 60 of file moving-average.hpp.
|
inline |
Changes the sample capacity of the moving average.
capacity | Sample capacity. |
Definition at line 96 of file moving-average.hpp.
|
inlinenoexcept |
Resets the moving average.
Definition at line 84 of file moving-average.hpp.
|
inline |
Changes the current number of samples of the moving average.
size | Number of samples |
Definition at line 106 of file moving-average.hpp.
|
inlinenoexcept |
Returns the current number of samples.
Definition at line 134 of file moving-average.hpp.
|
inlinenoexcept |
Returns the sum of all current samples.
Definition at line 128 of file moving-average.hpp.