DiSMEC++
|
Helper class for implementing Statistics
classes.
More...
#include <stats_base.h>
Public Member Functions | |
void | merge (const Statistics &other) override |
Merges this statistics of another one of the same type and settings. More... | |
void | record_vec (const DenseRealVector &vector) override |
![]() | |
virtual | ~Statistics ()=default |
void | record (int integer) |
void | record (long integer) |
void | record (real_t real) |
void | record (const DenseRealVector &vector) |
virtual std::unique_ptr< Statistics > | clone () const =0 |
virtual void | setup (const StatisticsCollection &source) |
This function has to be called before the Statistics is used to collect data for the first time. More... | |
virtual nlohmann::json | to_json () const =0 |
Converts the statistics current value into a json object. More... | |
Helper class for implementing Statistics
classes.
Derived | CRTP parameter. Needs to be a final class. |
This class provides two default implementations to ease writing derived classes. The merge()
function checks that the other given statistics is of the same type, and then calls an overload of merge()
that expects a Derived
reference. The record()
function for vector parameters is implemented so that it called the scalar record()
for each vector component. Note that we cannot efficiently implement this default behaviour in Statistics
, because then each record call would be virtual. Since we do know the Derived
type here, no virtual call is necessary.
For this to work, we require that Derived
be a final class.
Definition at line 127 of file stats_base.h.
|
inlineoverridevirtual |
Merges this statistics of another one of the same type and settings.
This operation is used to perform the reduction of the thread-local statistics into a single global statistics. For this to be possible, the merged statistics need to have not only the same type, but also the same settings (e.g. number of bins in a histogram). This is true for the thread local copies, which are clones of one another.
other | The statistics object to be merged into this. Must be of same type and have the same settings, e.g. a clone of this. |
Implements dismec::stats::Statistics.
Definition at line 129 of file stats_base.h.
|
inlineoverridevirtual |
Reimplemented from dismec::stats::Statistics.
Definition at line 134 of file stats_base.h.
References dismec::stats::Statistics::record().