19Logger
g_log(
"Interpolation");
58 g_log.
error() <<
"Need at least one value for interpolation. Return "
59 "interpolation value zero.";
69 if (at <
m_data[0].first) {
74 if (at >
m_data[N - 1].first) {
84 auto posBefore = std::prev(pos);
85 if (posBefore->first == at) {
86 return posBefore->second;
88 double interpolatedY = posBefore->second + (at - posBefore->first) * (pos->second - posBefore->second) /
89 (pos->first - posBefore->first);
92 }
catch (
const std::range_error &) {
104 std::vector<DataXY>::const_iterator it;
108 m_data.emplace_back(newpair);
114 if (xx <
m_data[0].first) {
120 if (xx >
m_data[N - 1].first) {
121 m_data.emplace_back(xx, yy);
129 auto posBefore = std::prev(it);
130 if (posBefore->first != xx) {
142 for (
unsigned int i = 0; i <
m_data.size(); i++) {
143 os <<
" ; " <<
m_data[i].first <<
" " <<
m_data[i].second;
181 for (
unsigned int i = 3; i < values.
count(); i++) {
182 std::stringstream strstream(values[i]);
const std::vector< double > & rhs
BuilderMethod< ArgType > m_method
Provide interpolation over a series of points.
void setMethod(const std::string &method)
set interpolation method
std::vector< DataXY > m_data
internal storage of x and y values
void resetData()
Clear interpolation values.
std::vector< DataXY >::const_iterator cbegin() const
std::vector< DataXY >::const_iterator cend() const
std::string m_method
method used for doing the interpolation
void setXUnit(const std::string &unit)
set x-axis unit
double value(const double &at) const
get interpolated value at location at
std::vector< DataXY >::const_iterator findIndexOfNextLargerValue(double key) const
Get iterator of item that is next larger than the supplied x value.
void setYUnit(const std::string &unit)
set y-axis unit
void printSelf(std::ostream &os) const
Prints object to stream.
void addPoint(const double &xx, const double &yy)
add data point
Interpolation()
Constructor default to linear interpolation and x-unit set to TOF.
Unit_sptr m_yUnit
unit of y-axis
Unit_sptr m_xUnit
unit of x-axis
void error(const std::string &msg)
Logs at error level.
Manage the lifetime of a class intended to be a singleton.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
@ TOK_TRIM
remove leading and trailing whitespace from tokens
std::size_t count() const
Get the total number of tokens.
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
Logger g_log("DateAndTime")
MANTID_KERNEL_DLL std::ostream & operator<<(std::ostream &, CPUTimer &)
Convenience function to provide for easier debug printing.
MANTID_KERNEL_DLL std::istream & operator>>(std::istream &, Interpolation &)
Reads in parameter value.
std::pair< double, double > DataXY
bool operator()(const DataXY &lhs, const DataXY &rhs)