15#include <boost/format.hpp>
23class EqualWithinTolerance {
31 bool operator()(
double a,
double b) {
32 if (std::isnan(a) && std::isnan(b))
34 if (std::isinf(a) && std::isinf(b))
82 newAxis->m_values.clear();
83 newAxis->m_values.resize(
length);
137 const auto *spec2 =
dynamic_cast<const NumericAxis *
>(&axis2);
142 EqualWithinTolerance comparison(
tolerance);
143 return std::equal(
m_values.begin(),
m_values.end(), spec2->m_values.begin(), comparison);
158 std::string numberLabel = boost::str(boost::format(
"%.13f") %
value);
161 auto it = numberLabel.end() - 1;
162 for (; it != numberLabel.begin(); --it) {
164 it = numberLabel.erase(it);
165 }
else if (*it ==
'.') {
166 numberLabel.erase(it);
181 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.
bool operator==(const NumericAxis &) const
Check if two NumericAxis are equivalent.
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.
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("DetermineSpinStateOrder")
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.
MANTID_KERNEL_DLL bool withinAbsoluteDifference(T const x, T const y, S const tolerance)
Test whether x, y are within absolute tolerance tol.