Larus glider flight sensor system
3.9.2024
Software-In-The-Loop test and validation system
Loading...
Searching...
No Matches
accumulating_averager.h
Go to the documentation of this file.
1
#ifndef GENERIC_ALGORITHMS_ACCUMULATING_AVERAGER_H_
2
#define GENERIC_ALGORITHMS_ACCUMULATING_AVERAGER_H_
3
5
template
<
typename
type>
class
accumulating_averager
6
{
7
public
:
8
accumulating_averager
(
void
)
9
: sum(0), samples(0)
10
{}
11
void
update
( type input)
12
{
13
sum += input;
14
++samples;
15
}
16
type
get_average
(
void
)
const
17
{
18
if
( samples == 0)
19
return
{ 0};
20
21
float
tmp = 1.0f / samples;
22
return
sum * tmp;
23
}
24
void
reset
( type set_this_value,
unsigned
set_this_count)
25
{
26
sum = set_this_value * set_this_count;
27
samples = set_this_count;
28
}
29
private
:
30
type sum;
31
unsigned
samples;
32
};
33
34
#endif
/* GENERIC_ALGORITHMS_ACCUMULATING_AVERAGER_H_ */
accumulating_averager
simple average mechanism using the sum of input values
Definition
accumulating_averager.h:6
accumulating_averager::get_average
type get_average(void) const
Definition
accumulating_averager.h:16
accumulating_averager::reset
void reset(type set_this_value, unsigned set_this_count)
Definition
accumulating_averager.h:24
accumulating_averager::update
void update(type input)
Definition
accumulating_averager.h:11
accumulating_averager::accumulating_averager
accumulating_averager(void)
Definition
accumulating_averager.h:8
lib
Generic_Algorithms
accumulating_averager.h
Generated by
1.9.8