60 auto result = std::lower_bound(begin,
m_coordinates.end(), value);
61 auto index =
static_cast<size_t>(std::distance(begin, result));
62 return value <
minary(index) ? index - 1 : index;
67 std::vector<double> result;
69 result.reserve(v_size + 1);
70 for (
size_t i = 0; i < v_size; ++i)
71 result.push_back(
minary(i));
72 result.push_back(
maxary(v_size - 1));
79 throw std::runtime_error(
80 "PointwiseAxis::clip() -> Error. 'lower' should be smaller than 'upper'");
82 using diff_t = std::vector<double>::iterator::difference_type;
92 auto precision = std::setprecision(std::numeric_limits<double>::digits10 + 2);
93 ostr <<
"PointwiseAxis(\"" <<
axisName() <<
"\", "
95 for (
size_t i = 0, fin =
m_coordinates.size() - 1; i < fin; ++i)
104 if (
const auto* otherAxis =
dynamic_cast<const PointwiseAxis*
>(&other))
127 std::string message =
"Error in PointwiseAxis::binCenter: passed index ";
128 message += std::to_string(index) +
" exceeds the size ";
129 message += std::to_string(
m_coordinates.size()) +
" of the axis";
130 throw std::runtime_error(message);
136 throw std::runtime_error(
137 "Error in PointwiseAxis::PointwiseAxis: the size of passed coordinate array is "
138 "less than minimum acceptable value");
143 if (!std::is_sorted(begin, end))
144 throw std::runtime_error(
"Error in PointwiseAxis::PointwiseAxis: passed coordinates are "
145 "not sorted in ascending order");
147 if (std::adjacent_find(begin, end) != end)
148 throw std::runtime_error(
"Error in PointwiseAxis::PointwiseAxis: passed coordinate vector "
149 "contains repeating values");
Defines structs Bin1D, Bin1DCVector.
const size_t min_axis_size
Defines class PointwiseAxis.
Abstract base class for one-dimensional axes.
virtual bool equals(const IAxis &other) const
std::string axisName() const
Returns the label of the axis.
Axis containing arbitrary (non-equidistant) coordinate values. Lower boundary of the first bin and up...
~PointwiseAxis() override
PointwiseAxis(String &&name, Vector &&coordinate_values)
PointwiseAxis * clone() const override
clone function
double min() const override
Returns value of first on-axis point.
double binCenter(size_t index) const override
Returns the coordinate corresponding to the given index. For this type of axis ("pointwise") this equ...
Bin1D bin(size_t index) const override
retrieve a 1d bin for the given index
void checkIndex(size_t index) const
std::vector< double > m_coordinates
size_t findClosestIndex(double value) const override
find index of the coordinate closest to the given value
std::vector< double > binBoundaries() const override
void clip(double lower, double upper) override
Clips this axis to the given values.
double maxary(size_t index) const
double minary(size_t index) const
bool equals(const IAxis &other) const override
void print(std::ostream &ostr) const override
double max() const override
Returns value of last on-axis point.