14#include <boost/format.hpp>
22class EqualWithinTolerance {
25 bool operator()(
double a,
double b) {
26 if (std::isnan(a) && std::isnan(b))
28 if (std::isinf(a) && std::isinf(b))
30 return std::abs(a - b) <= m_tolerance;
76 newAxis->m_values.clear();
77 newAxis->m_values.resize(
length);
125 const auto *spec2 =
dynamic_cast<const NumericAxis *
>(&axis2);
130 EqualWithinTolerance comparison(
tolerance);
131 return std::equal(
m_values.begin(),
m_values.end(), spec2->m_values.begin(), comparison);
146 std::string numberLabel = boost::str(boost::format(
"%.13f") %
value);
149 auto it = numberLabel.end() - 1;
150 for (; it != numberLabel.begin(); --it) {
152 it = numberLabel.erase(it);
153 }
else if (*it ==
'.') {
154 it = numberLabel.erase(it);
169 std::vector<double> result;
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Class to represent the axis of a workspace.
virtual std::size_t length() const =0
Get the length of the axis.
Base MatrixWorkspace Abstract Class.
Class to represent a numeric axis of a workspace.
virtual bool equalWithinTolerance(const Axis &axis2, const double tolerance) const
Check if two numeric axis are equivalent to a given tolerance.
void setValue(const std::size_t &index, const double &value) override
Set the value at a specific index.
std::string label(const std::size_t &index) const override
Returns a text label which shows the value corresponding to a bin index.
std::string formatLabel(const double value) const
Get number label.
virtual std::vector< double > createBinBoundaries() const
Create bin boundaries from the point values.
virtual const std::vector< double > & getValues() const
Return a const reference to the values.
std::size_t length() const override
Get the length of the axis.
std::vector< double > m_values
A vector holding the centre values.
NumericAxis()
Default constructor.
bool operator==(const Axis &) const override
Check if two axis defined as spectra or numeric axis are equivalent.
double operator()(const std::size_t &index, const std::size_t &verticalIndex=0) const override
Get a value at the specified index.
Axis * clone(const MatrixWorkspace *const parentWorkspace) override
Virtual constructor.
size_t indexOfValue(const double value) const override
Returns the index of the value wrt bin edge representation of the axis.
Exception for index errors.
The Logger class is in charge of the publishing messages from the framework through various channels.
Kernel::Logger g_log("ExperimentInfo")
static logger object
size_t MANTID_KERNEL_DLL indexOfValueFromCenters(const std::vector< double > &bin_centers, const double value)
Gets the bin of a value from a vector of bin centers and throws exception if out of range.
void MANTID_KERNEL_DLL convertToBinBoundary(const std::vector< double > &bin_centers, std::vector< double > &bin_edges)
Convert an array of bin centers to bin boundary values.