/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
#ifndef GMX_ANALYSISDATA_MODULES_HISTOGRAM_H
#define GMX_ANALYSISDATA_MODULES_HISTOGRAM_H
-#include "../abstractdata.h"
-#include "../arraydata.h"
-#include "../datamodule.h"
-#include "../../utility/uniqueptr.h"
+#include <boost/shared_ptr.hpp>
+
+#include "gromacs/analysisdata/abstractdata.h"
+#include "gromacs/analysisdata/arraydata.h"
+#include "gromacs/analysisdata/datamodule.h"
namespace gmx
{
};
-namespace internal
-{
-
-class BasicHistogramImpl;
-
-} // namespace internal
-
class AbstractAverageHistogram;
//! Smart pointer to manage an AbstractAverageHistogram object.
-typedef gmx_unique_ptr<AbstractAverageHistogram>::type
+typedef boost::shared_ptr<AbstractAverageHistogram>
AverageHistogramPointer;
/*! \brief
* the main use of the object is to postprocess the histogram once the
* calculation is finished.
*
+ * This class can represent multiple histograms in one object: each column in
+ * the data is an independent histogram.
+ *
* \inpublicapi
* \ingroup module_analysisdata
*/
AverageHistogramPointer clone() const;
//! Normalizes the histogram such that the integral over it is one.
void normalizeProbability();
- //! Scales the value of each bin by an uniform scaling factor.
- void scale(real norm);
+ //! Scales a single histogram by a uniform scaling factor.
+ void scaleSingle(int index, real factor);
+ //! Scales all histograms by a uniform scaling factor.
+ void scaleAll(real factor);
//! Scales the value of each bin by a different scaling factor.
- void scaleVector(real norm[]);
+ void scaleAllByVector(real factor[]);
/*! \brief
* Notifies attached modules of the histogram data.
*
/*! \brief
* Data module for per-frame histograms.
*
- * Output data contains the same number of frames as the input data.
- * Each frame contains the histogram for the points in that frame.
- * All input columns are averaged into the same histogram.
- * The number of columns equals the number of bins in the histogram.
+ * Output data contains the same number of frames and data sets as the input
+ * data. Each frame contains the histogram(s) for the points in that frame.
+ * Each input data set is processed independently into the corresponding output
+ * data set. Missing values are ignored.
+ * All input columns for a data set are averaged into the same histogram.
+ * The number of columns for all data sets equals the number of bins in the
+ * histogram.
+ *
+ * The histograms are accumulated as 64-bit integers within a frame and summed
+ * in double precision across frames, even if the output data is in single
+ * precision.
*
* \inpublicapi
* \ingroup module_analysisdata
*/
class AnalysisDataSimpleHistogramModule : public AbstractAnalysisData,
- public AnalysisDataModuleInterface
+ public AnalysisDataModuleParallel
{
public:
/*! \brief
//! Returns bin properties for the histogram.
const AnalysisHistogramSettings &settings() const;
+ virtual int frameCount() const;
+
virtual int flags() const;
- virtual void dataStarted(AbstractAnalysisData *data);
+ virtual bool parallelDataStarted(
+ AbstractAnalysisData *data,
+ const AnalysisDataParallelOptions &options);
virtual void frameStarted(const AnalysisDataFrameHeader &header);
virtual void pointsAdded(const AnalysisDataPointSetRef &points);
virtual void frameFinished(const AnalysisDataFrameHeader &header);
virtual AnalysisDataFrameRef tryGetDataFrameInternal(int index) const;
virtual bool requestStorageInternal(int nframes);
- PrivateImplPointer<internal::BasicHistogramImpl> impl_;
+ class Impl;
+
+ PrivateImplPointer<Impl> impl_;
// Copy and assign disallowed by base.
};
/*! \brief
* Data module for per-frame weighted histograms.
*
- * Output data contains the same number of frames as the input data.
- * Each frame contains the histogram for the points in that frame, interpreted
- * such that the first column passed to pointsAdded() determines the bin and
- * the rest give weights to be added to that bin (input data should have at
- * least two colums, and at least two columns should be added at the same time).
- * All input columns are averaged into the same histogram.
- * The number of columns equals the number of bins in the histogram.
+ * Output data contains the same number of frames and data sets as the input
+ * data. Each frame contains the histogram(s) for the points in that frame,
+ * interpreted such that the first column passed to pointsAdded() determines
+ * the bin and the rest give weights to be added to that bin (input data should
+ * have at least two colums, and at least two columns should be added at the
+ * same time).
+ * Each input data set is processed independently into the corresponding output
+ * data set.
+ * All input columns for a data set are averaged into the same histogram.
+ * The number of columns for all data sets equals the number of bins in the
+ * histogram.
+ *
+ * The histograms are accumulated in double precision, even if the output data
+ * is in single precision.
*
* \inpublicapi
* \ingroup module_analysisdata
*/
class AnalysisDataWeightedHistogramModule : public AbstractAnalysisData,
- public AnalysisDataModuleInterface
+ public AnalysisDataModuleParallel
{
public:
//! \copydoc AnalysisDataSimpleHistogramModule::AnalysisDataSimpleHistogramModule()
//! \copydoc AnalysisDataSimpleHistogramModule::settings()
const AnalysisHistogramSettings &settings() const;
+ virtual int frameCount() const;
+
virtual int flags() const;
- virtual void dataStarted(AbstractAnalysisData *data);
+ virtual bool parallelDataStarted(
+ AbstractAnalysisData *data,
+ const AnalysisDataParallelOptions &options);
virtual void frameStarted(const AnalysisDataFrameHeader &header);
virtual void pointsAdded(const AnalysisDataPointSetRef &points);
virtual void frameFinished(const AnalysisDataFrameHeader &header);
virtual AnalysisDataFrameRef tryGetDataFrameInternal(int index) const;
virtual bool requestStorageInternal(int nframes);
- PrivateImplPointer<internal::BasicHistogramImpl> impl_;
+ class Impl;
+
+ PrivateImplPointer<Impl> impl_;
// Copy and assign disallowed by base.
};
* Data module for bin averages.
*
* Output data contains one row for each bin; see AbstractAverageHistogram.
- * Output data contains three columns: the first is the average over all frames
- * for that bin, the second is the standard deviation of the values, and the
- * third is the number of samples in that bin.
+ * Output data contains one column for each input data set.
+ * The value in a column is the average over all frames of that data set for
+ * that bin.
* The input data is interpreted such that the first column passed to
* pointsAdded() determines the bin and the rest give values to be added to
* that bin (input data should have at least two colums, and at least two
* columns should be added at the same time).
- * All input columns are averaged into the same histogram.
+ * All input columns for a data set are averaged into the same histogram.
*
* \inpublicapi
* \ingroup module_analysisdata
*/
class AnalysisDataBinAverageModule : public AbstractAnalysisArrayData,
- public AnalysisDataModuleInterface
+ public AnalysisDataModuleSerial
{
public:
//! \copydoc AnalysisDataSimpleHistogramModule::AnalysisDataSimpleHistogramModule()