8 #ifndef UFO_UTILS_TRUNCATINGEQUISPACEDBINSELECTOR_H_
9 #define UFO_UTILS_TRUNCATINGEQUISPACEDBINSELECTOR_H_
13 #include "eckit/exception/Exceptions.h"
37 ASSERT_MSG(upperBound > lowerBound,
"Upper bound must be larger than lower bound");
38 ASSERT_MSG(
numBins > 0,
"Number of bins must be positive");
43 binIndex = std::max(
IndexType(0), binIndex);
44 binIndex = std::min(
numBins_ - 1, binIndex);
48 boost::optional<IndexType>
numBins()
const override {
A finite or infinite collection of non-overlapping intervals (bins) of the same width.
Represents a finite set of consecutive intervals (bins) of the same width, each closed from the left ...
ValueType binWidth() const override
Return the width of each bin.
ValueType binCenter(IndexType bin) const override
Return the value lying at the center of the bin with index bin.
boost::optional< IndexType > numBins() const override
Return the number of bins or boost::none if the bin collection is infinite.
ValueType inverseBinWidth() const override
Return the inverse of the width of each bin.
ValueType inverseBinWidth_
TruncatingEquispacedBinSelector(ValueType lowerBound, ValueType upperBound, IndexType numBins)
Partition the interval [lowerBound, upperBound) into numBins bins of the same width.
IndexType bin(ValueType value) const override
Return the index of the bin containing value, or the nearest bin if value lies outside all bins.