57 auto result = std::lower_bound(begin,
m_coordinates.end(), value);
58 size_t index =
static_cast<size_t>(std::distance(begin, result));
64 std::vector<double> result;
66 result.reserve(v_size + 1);
67 for (
size_t i = 0; i < v_size; ++i)
76 throw std::runtime_error(
"Error in PointwiseAxis::createClippedAxis: "
77 "'left' should be smaller than 'right'");
79 using diff_t = std::vector<double>::iterator::difference_type;
88 auto precision = std::setprecision(std::numeric_limits<double>::digits10 + 2);
89 ostr <<
"PointwiseAxis(\"" <<
getName() <<
"\", "
91 for (
size_t i = 0, fin =
m_coordinates.size() - 1; i < fin; ++i)
123 std::string message =
"Error in PointwiseAxis::binCenter: passed index ";
124 message += std::to_string(index) +
" exceeds the size ";
125 message += std::to_string(
m_coordinates.size()) +
" of the axis";
126 throw std::runtime_error(message);
132 throw std::runtime_error(
133 "Error in PointwiseAxis::PointwiseAxis: the size of passed coordinate array is "
134 "less than minimum acceptable value");
139 if (!std::is_sorted(begin, end))
140 throw std::runtime_error(
"Error in PointwiseAxis::PointwiseAxis: passed coordinates are "
141 "not sorted in ascending order");
143 if (std::adjacent_find(begin, end) != end)
144 throw std::runtime_error(
"Error in PointwiseAxis::PointwiseAxis: passed coordinate vector "
145 "contains repeating values");
const size_t min_axis_size
Defines class PointwiseAxis.
Interface for one-dimensional axes.
virtual bool equals(const IAxis &other) const
std::string getName() const
retrieve the label of the axis
Axis containing arbitrary (non-equidistant) coordinate values.
double upperBoundary(size_t index) const
double lowerBoundary(size_t index) const
PointwiseAxis(String &&name, Vector &&coordinate_values)
PointwiseAxis * clone() const override
clone function
double upperBound() const override
Returns value of last on-axis point.
double binCenter(size_t index) const override
Returns the coordinate corresponding to the given index.
Bin1D bin(size_t index) const override
retrieve a 1d bin for the given index
void checkIndex(size_t index) const
double lowerBound() const override
Returns value of first on-axis point.
std::vector< double > m_coordinates
PointwiseAxis * createClippedAxis(double left, double right) const override
Creates a new clipped axis.
size_t findClosestIndex(double value) const override
find index of the coordinate closest to the given value
std::vector< double > binBoundaries() const override
bool equals(const IAxis &other) const override
void print(std::ostream &ostr) const override