1#ifndef UTIL_DISTRIBUTION_H
2#define UTIL_DISTRIBUTION_H
11#include <util/param/ParamComposite.h>
12#include <util/containers/DArray.h>
13#include <util/math/feq.h>
91 template <
class Archive>
92 void serialize(Archive& ar,
const unsigned int version);
104 virtual void clear();
111 void output(std::ostream& out);
147 void reduce(MPI::Intracomm& communicator,
int root);
197 template <
class Archive>
210 UTIL_THROW(
"Inconsistent histogram capacity");
int capacity() const
Return allocated size.
Saving archive for binary istream.
Saving / output archive for binary ostream.
Dynamically allocatable contiguous array template.
A distribution (or histogram) of values for a real variable.
int nBin() const
Get the number of bins.
void sample(double value)
Sample a value.
double binWidth_
width of bin = (max_-min_)/nBin_ .
double min_
minimum value.
double binWidth() const
Get binWidth, the width of each bin.
DArray< long > histogram_
Histogram of occurences, one element per bin.
double min() const
Get minimum value in range of histogram.
void setParam(double min, double max, int nBin)
Set parameters and initialize.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
void reduce(MPI::Intracomm &communicator, int root)
Reduce (add) distributions from multiple MPI processors.
double max_
maximum value.
virtual void readParameters(std::istream &in)
Read parameters from file and initialize.
void output(std::ostream &out)
Output the distribution to file.
int binIndex(double value) const
Return the index of the bin for a value.
Distribution & operator=(const Distribution &other)
Assignment operator.
virtual ~Distribution()
Destructor.
void serialize(Archive &ar, const unsigned int version)
Serialize this Distribution to/from an archive.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Distribution()
Default constructor.
int nSample_
Number of sampled values in Histogram.
int nReject_
Number of sampled values that were out of range.
virtual void clear()
Clear (i.e., zero) previously allocated histogram.
double max() const
Get maximum value in range of histogram.
An object that can read multiple parameters from file.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
bool feq(double x, double y, double eps=1.0E-10)
Are two floating point numbers equal to within round-off error?
Utility classes for scientific computation.