13 : m_allowEmpty(allowEmpty), m_allowRange(allowRange) {}
27 std::string
error =
"";
28 size_t numParams =
value.size();
32 error =
"Enter values for this property";
36 if (
value[0] == 0.0) {
37 error =
"Cannot have a zero bin width";
43 error =
"When giving a range the second value must be larger than the first";
46 error =
"The number of bin boundary parameters provided must be odd";
51 if (
value.size() % 2 == 0) {
52 error =
"The number of bin boundary parameters provided must be odd";
57 double previousBoundary =
value[0];
58 for (
size_t i = 1; i <
value.size() - 1; i += 2) {
59 double binWidth =
value[i];
60 double nextBoundary =
value[i + 1];
62 if (binWidth == 0.0) {
63 error =
"Cannot have a zero bin width";
66 if (nextBoundary <= previousBoundary) {
67 error =
"Bin boundary values must be given in order of increasing value";
69 }
else if (binWidth < 0.0 &&
72 error =
"Bin boundaries must be positive for logarithmic binning";
79 numBins +=
static_cast<size_t>(std::log(nextBoundary / previousBoundary) / std::log(1. - binWidth));
82 numBins +=
static_cast<size_t>((nextBoundary - previousBoundary) / binWidth);
84 previousBoundary = nextBoundary;
87 double binSpaceInBytes =
static_cast<double>(numBins *
sizeof(double));
88 if (binSpaceInBytes > memInBytes) {
89 double bytesInGB = 1e9;
90 error =
"The number of bins requested is expected to exceed available memory. "
91 "This binning requires approximately " +
92 std::to_string(binSpaceInBytes / bytesInGB) +
" GB of memory, but only " +
double value
The value of the point.
This class is responsible for memory statistics.
std::size_t availMem() const
Returns the available memory of the system in kiB.
IValidator_sptr clone() const override
std::string checkValidity(const std::vector< double > &value) const override
Check on the inputed bin boundaries and widths.
RebinParamsValidator(bool allowEmpty=false, bool allowRange=false)
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
std::string to_string(const wide_integer< Bits, Signed > &n)