carl
24.04
Computer ARithmetic Library
Series.h
Go to the documentation of this file.
1
#pragma once
2
3
namespace
carl::statistics
{
4
5
class
Series
{
6
std::size_t
m_count
= 0;
7
std::size_t
m_sum
= 0;
8
std::size_t
m_min
= 0;
9
std::size_t
m_max
= 0;
10
11
public
:
12
void
add
(std::size_t n) {
13
m_sum
+= n;
14
m_min
=
m_count
== 0 ? n : std::min(
m_min
, n);
15
m_max
=
m_count
== 0 ? n : std::max(
m_max
, n);
16
m_count
++;
17
}
18
19
void
collect
(std::map<std::string, std::string>& data,
const
std::string& key)
const
{
20
data.emplace(key+
".count"
, std::to_string(
m_count
));
21
data.emplace(key+
".sum"
, std::to_string(
m_sum
));
22
data.emplace(key+
".min"
, std::to_string(
m_min
));
23
data.emplace(key+
".max"
, std::to_string(
m_max
));
24
data.emplace(key+
".avg"
, std::to_string((
float
)
m_sum
/(
float
)
m_count
));
25
}
26
};
27
28
}
carl::statistics
Definition:
carl-statistics.h:19
carl::statistics::Series
Definition:
Series.h:5
carl::statistics::Series::m_min
std::size_t m_min
Definition:
Series.h:8
carl::statistics::Series::m_count
std::size_t m_count
Definition:
Series.h:6
carl::statistics::Series::m_sum
std::size_t m_sum
Definition:
Series.h:7
carl::statistics::Series::m_max
std::size_t m_max
Definition:
Series.h:9
carl::statistics::Series::collect
void collect(std::map< std::string, std::string > &data, const std::string &key) const
Definition:
Series.h:19
carl::statistics::Series::add
void add(std::size_t n)
Definition:
Series.h:12
carl-statistics
Series.h
Generated by
1.9.1