/*
* 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
*
* This class can represent multiple histograms in one object: each column in
* the data is an independent histogram.
+ * The X values correspond to center of the bins, except for a cumulative
+ * histogram made with makeCumulative().
*
* \inpublicapi
* \ingroup module_analysisdata
/*! \brief
* Creates a copy of the histogram with double the bin width.
*
+ * \param[in] bIntegerBins If `true`, the first bin in the result will
+ * cover the first bin from the source. Otherwise, the first bin
+ * will cover first two bins from the source.
* \throws std::bad_alloc if out of memory.
*
* The caller is responsible of deleting the returned object.
AverageHistogramPointer clone() const;
//! Normalizes the histogram such that the integral over it is one.
void normalizeProbability();
+ /*! \brief
+ * Makes the histograms cumulative by summing up each bin to all bins
+ * after it.
+ *
+ * The X values in the data are adjusted such that they match the right
+ * edges of bins instead of bin centers.
+ */
+ void makeCumulative();
//! Scales a single histogram by a uniform scaling factor.
void scaleSingle(int index, real factor);
//! Scales all histograms by a uniform scaling factor.
* 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.
};
* 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.
};
* \ingroup module_analysisdata
*/
class AnalysisDataBinAverageModule : public AbstractAnalysisArrayData,
- public AnalysisDataModuleInterface
+ public AnalysisDataModuleSerial
{
public:
//! \copydoc AnalysisDataSimpleHistogramModule::AnalysisDataSimpleHistogramModule()