Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
lar::util::details::DataTracker< PWR, T, W > Class Template Reference

Class tracking sums of variables up to a specified power. More...

#include <StatCollector.h>

Inheritance diagram for lar::util::details::DataTracker< PWR, T, W >:
lar::util::details::DataTracker2< T, W, PWR > lar::util::details::DataTracker3< T, W, PWR >

Public Types

using Data_t = T
 type of data More...
 
using Weight_t = T
 type of weight More...
 

Public Member Functions

 DataTracker ()
 Default constructor. More...
 
void add (Data_t v, Weight_t w)
 Adds the specified weight to the statistics. More...
 
void clear ()
 Resets the count. More...
 
template<unsigned int N>
Weight_t SumN () const
 Returns the sum of the values to the power N (1 <= N <= 2) More...
 
Weight_t Sum (unsigned int n) const
 Returns the sum of the values to the power n (1 <= n <= 2, no check) More...
 
Weight_t Sum () const
 Returns the weighted sum of the entries. More...
 

Static Public Attributes

static constexpr unsigned int Power = PWR
 

Protected Attributes

std::array< Weight_t, Powersums
 

Detailed Description

template<unsigned int PWR, typename T, typename W = T>
class lar::util::details::DataTracker< PWR, T, W >

Class tracking sums of variables up to a specified power.

Template Parameters
Powerpower up to which to collect statistics
Ttype of the quantity
Wtype of the weight (as T by default)

Note that statistics of order 0 (that is, pertaining only weights) are not collected.

Definition at line 93 of file StatCollector.h.

Member Typedef Documentation

template<unsigned int PWR, typename T, typename W = T>
using lar::util::details::DataTracker< PWR, T, W >::Data_t = T

type of data

Definition at line 98 of file StatCollector.h.

template<unsigned int PWR, typename T, typename W = T>
using lar::util::details::DataTracker< PWR, T, W >::Weight_t = T

type of weight

Definition at line 99 of file StatCollector.h.

Constructor & Destructor Documentation

template<unsigned int PWR, typename T, typename W = T>
lar::util::details::DataTracker< PWR, T, W >::DataTracker ( )
inline

Default constructor.

Definition at line 102 of file StatCollector.h.

102 { clear(); }
void clear()
Resets the count.

Member Function Documentation

template<unsigned int PWR, typename T, typename W = T>
void lar::util::details::DataTracker< PWR, T, W >::add ( Data_t  v,
Weight_t  w 
)
inline

Adds the specified weight to the statistics.

Definition at line 105 of file StatCollector.h.

106  {
107  Weight_t x = w;
108  for (size_t i = 0; i < Power; ++i) sums[i] += (x *= v);
109  }
static constexpr unsigned int Power
Definition: StatCollector.h:95
list x
Definition: train.py:276
std::array< Weight_t, Power > sums
template<unsigned int PWR, typename T, typename W = T>
void lar::util::details::DataTracker< PWR, T, W >::clear ( )
inline

Resets the count.

Definition at line 112 of file StatCollector.h.

112 { sums.fill(Data_t(0)); }
std::array< Weight_t, Power > sums
template<unsigned int PWR, typename T, typename W = T>
Weight_t lar::util::details::DataTracker< PWR, T, W >::Sum ( unsigned int  n) const
inline

Returns the sum of the values to the power n (1 <= n <= 2, no check)

Definition at line 124 of file StatCollector.h.

124 { return sums[n - 1]; }
std::void_t< T > n
std::array< Weight_t, Power > sums
template<unsigned int PWR, typename T, typename W = T>
Weight_t lar::util::details::DataTracker< PWR, T, W >::Sum ( ) const
inline

Returns the weighted sum of the entries.

Definition at line 127 of file StatCollector.h.

127 { return SumN<1>(); }
template<unsigned int PWR, typename T, typename W = T>
template<unsigned int N>
Weight_t lar::util::details::DataTracker< PWR, T, W >::SumN ( ) const
inline

Returns the sum of the values to the power N (1 <= N <= 2)

Definition at line 116 of file StatCollector.h.

117  {
118  static_assert
119  ((N > 0) && (N <= Power), "Invalid sum of power requested");
120  return sums[N - 1];
121  } // SumN()
static constexpr unsigned int Power
Definition: StatCollector.h:95
std::array< Weight_t, Power > sums

Member Data Documentation

template<unsigned int PWR, typename T, typename W = T>
constexpr unsigned int lar::util::details::DataTracker< PWR, T, W >::Power = PWR
static

Definition at line 95 of file StatCollector.h.

template<unsigned int PWR, typename T, typename W = T>
std::array<Weight_t, Power> lar::util::details::DataTracker< PWR, T, W >::sums
protected

Definition at line 130 of file StatCollector.h.


The documentation for this class was generated from the following file: