lib/time_data.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <cmath>
14 #include "../../include/ecl/time/time_data.hpp"
15 
16 /*****************************************************************************
17 ** Namespaces
18 *****************************************************************************/
19 
20 namespace ecl {
21 
22 /*****************************************************************************
23 ** Implementation [TimeData]
24 *****************************************************************************/
25 
27  double sum = 0.0;
28  for ( unsigned int i = 0; i < durations.size(); ++i ) {
29  sum += durations[i];
30  }
31  return ecl::Duration(sum/static_cast<double>(durations.size()));
32 };
33 
35  ecl::Duration avg = average();
36  double sum = 0.0;
37  for ( unsigned int i = 0; i < durations.size(); ++i ) {
38  sum += (static_cast<double>(durations[i]) - static_cast<double>(avg))*
39  (static_cast<double>(durations[i]) - static_cast<double>(avg));
40  }
41  return ecl::Duration(sqrt(sum/static_cast<double>(durations.size())));
42 };
43 
45  ecl::Duration avg = average();
46  double sum = 0.0;
47  for ( unsigned int i = 0; i < durations.size(); ++i ) {
48  sum += (static_cast<double>(durations[i]) - static_cast<double>(avg))*
49  (static_cast<double>(durations[i]) - static_cast<double>(avg));
50  }
51  return ecl::Duration(sum/static_cast<double>(durations.size()));
52 };
53 
54 } // namespace ecl
55 
ecl::TimeData::durations
std::vector< ecl::Duration > durations
Definition: time_data.hpp:89
ecl::TimeData::average
ecl::Duration average() const
Return the average of the elements currently stored.
Definition: lib/time_data.cpp:30
ecl::Duration
TimeStamp Duration
Convenience typedef to associate timestamps with the concept of durations.
Definition: duration.hpp:47
ecl::TimeData::stdDev
ecl::Duration stdDev() const
Return the standard deviation of the elements currently stored.
Definition: lib/time_data.cpp:38
ecl
Embedded control libraries.
ecl::TimeData::variance
ecl::Duration variance() const
Return the variance of the elements currently stored.
Definition: lib/time_data.cpp:48


ecl_time
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:19