10 : underflows(0), overflows(0)
12 const unsigned int binCount = conf.
read<
unsigned int>(
"instrumentation."+name+
".binCount");
13 bins.resize(binCount, 0);
15 conf.
read(
"instrumentation."+name+
".low", &lowEnd);
16 conf.
read(
"instrumentation."+name+
".high", &highEnd);
18 binSize = (highEnd-lowEnd)/binCount;
35 const unsigned int binID=
static_cast<unsigned int>((val-lowEnd)/binSize);
38 if(binID>=bins.size())
49 for(Container::size_type i=0; i<bins.size(); ++i)
57 if(binPoint<0 || binPoint>1)
62 const FP integral=getIntegral();
64 for(Container::size_type i=0; i<bins.size(); ++i)
66 const FP binPosition=lowEnd+i*binSize+binPoint*binSize;
67 const FP binValue=bins[i]/integral;
79 std::ofstream file(filename.c_str(), std::ios::trunc);
80 file.precision(std::numeric_limits<FP>::digits10 + 2);
82 file<<
"#underflows = "<<underflows<<
"\n";
83 file<<
"#overflows =" <<overflows <<
"\n";
85 for(Container::size_type i=0; i<bins.size(); ++i)
87 const FP binPosition=lowEnd+i*binSize+binPoint*binSize;
88 const FP binValue=bins[i];
90 file<<binPosition<<
"\t"<<binValue<<
"\n";
FP getIntegral() const
Returns the integral of the histogram.
Represents the configuration of the simulation.
#define OPENMPCD_THROW(ExceptionType, message)
Throws the given ExceptionType, passing the given message along with file and line number information...
void read(const std::pair< const char *, ValueType * >(&settingsAndValues)[settingsCount]) const
Reads the specified settings from the given configuration file and stores them in the given location.
const Graph getNormalizedGraph(const FP binPoint=0.5) const
Returns the graph corresponding to this histogram, with the area normalized to 1.
static void ensureParentDirectory(const std::string &path)
Ensures that the parent directory of the path given exists.
void save(const std::string &filename, const FP binPoint=0.5) const
Saves the histogram at the given path.
double FP
Default floating point type.
void fill(const FP val)
Adds an entry to the histogram.
Histogram(const std::string &name, const Configuration &conf)
The constructor.
Exception for out-of-bounds access.
void addPoint(const FP x, const FP y)
Adds a data point.
Invalid argument exception.