Gromacs  2024.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::AnalysisDataFrameAverager Class Reference

#include <gromacs/analysisdata/modules/frameaverager.h>

Description

Helper class for modules that average values over frames.

This class implements common functionality for analysis data modules that need to average a set of values over frames. Currently, it is designed for computing averages for each input column independently, but should be relatively easy to make more general if required.

This class takes care of accumulating the values and computing their variance. It allows different number of samples for each input column. Accumulation is always in double precision and uses a formula that is relatively stable numerically. For now, does nothing fancy, but provides ground for other implementation (e.g., related to parallelization) that would benefit all such modules.

Methods in this class do not throw unless otherwise indicated.

Public Member Functions

int columnCount () const
 Returns the number of columns in this averager.
 
void setColumnCount (int columnCount)
 Sets the number of columns in the input data. More...
 
void addValue (int index, real value)
 Adds a single value to the average for a given column. More...
 
void addPoints (const AnalysisDataPointSetRef &points)
 Accumulates data from a given point set into the average. More...
 
void finish ()
 Finalizes the calculation of the averages and variances. More...
 
real average (int index) const
 Returns the computed average for a given column. More...
 
real variance (int index) const
 Returns the computed (sample) variance for a given column. More...
 
int sampleCount (int index) const
 Returns the number of samples for a given column. More...
 

Member Function Documentation

void gmx::AnalysisDataFrameAverager::addPoints ( const AnalysisDataPointSetRef points)

Accumulates data from a given point set into the average.

Typically called from IAnalysisDataModule::pointsAdded().

Each call accumulates the values for those columns that are present in the point set. Can be called multiple times for a frame, and does not need to be called for every frame.

void gmx::AnalysisDataFrameAverager::addValue ( int  index,
real  value 
)

Adds a single value to the average for a given column.

Parameters
[in]indexIndex of the column to add the value to.
[in]valueValue to add to the sample.
real gmx::AnalysisDataFrameAverager::average ( int  index) const
inline

Returns the computed average for a given column.

If called before finish(), the results are undefined.

void gmx::AnalysisDataFrameAverager::finish ( )

Finalizes the calculation of the averages and variances.

Does any computation that is not done during the accumulation in addPoints(). Currently, does nothing, but provided as a placeholder for more complex implementation.

Typically called from IAnalysisDataModule::dataFinished().

int gmx::AnalysisDataFrameAverager::sampleCount ( int  index) const
inline

Returns the number of samples for a given column.

If called before finish(), the results are undefined.

void gmx::AnalysisDataFrameAverager::setColumnCount ( int  columnCount)

Sets the number of columns in the input data.

Exceptions
std::bad_allocif out of memory.

Typically called from IAnalysisDataModule::dataStarted().

Must be called exactly once, before setting calling any other method in the class.

real gmx::AnalysisDataFrameAverager::variance ( int  index) const
inline

Returns the computed (sample) variance for a given column.

If called before finish(), the results are undefined.


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