28 throw std::runtime_error(
29 "ConstKBinAxis::ConstKBinAxis() -> Error. start >= end is not allowed.");
31 double start_sin = std::sin(
m_start);
32 double end_sin = std::sin(
m_end);
33 double step = (end_sin - start_sin) / (
m_nbins);
35 std::vector<double> bin_boundaries;
36 bin_boundaries.resize(
m_nbins + 1, 0.0);
37 for (
size_t i = 0; i < bin_boundaries.size(); ++i) {
38 bin_boundaries[i] = std::asin(start_sin + step * i);
51 throw std::runtime_error(
52 "ConstKBinAxis::createClippedAxis() -> Error. 'left'' should be smaller than 'right'");
62 size_t new_nbins = nbin2 - nbin1 + 1;
63 std::vector<double> new_boundaries;
65 for (
size_t i = 0; i < new_nbins + 1; ++i) {
66 new_boundaries.push_back(old_boundaries[nbin1 + i]);
70 result->
m_start = new_boundaries.front();
71 result->
m_end = new_boundaries.back();
81 if (
size() != otherAxis->size())
94 ostr <<
"ConstKBinAxis(\"" <<
getName() <<
"\", " <<
size() <<
", "
95 << std::setprecision(std::numeric_limits<double>::digits10 + 2) <<
m_start <<
", " <<
m_end
Defines and implements namespace algo with some algorithms.
Defines class ConstKBinAxis.
Axis with fixed bin size in sin(angle) space.
void print(std::ostream &ostr) const override
ConstKBinAxis * createClippedAxis(double left, double right) const override
Creates a new clipped axis.
bool equals(const IAxis &other) const override
ConstKBinAxis(const std::string &name, size_t nbins, double start, double end)
ConstKBinAxis constructor.
ConstKBinAxis * clone() const override
clone function
Interface for one-dimensional axes.
virtual bool equals(const IAxis &other) const
std::string getName() const
retrieve the label of the axis
Axis with variable bin size.
double upperBound() const
Returns value of last point of axis.
size_t size() const
retrieve the number of bins
void setBinBoundaries(const std::vector< double > &bin_boundaries)
std::vector< double > binBoundaries() const
Bin1D bin(size_t index) const
retrieve a 1d bin for the given index
double lowerBound() const
Returns value of first point of axis.
size_t findClosestIndex(double value) const
find bin index which is best match for given value
QString const & name(EShape k)
bool almostEqual(double a, double b)
Returns true if two doubles agree within machine epsilon.