Mantid
Loading...
Searching...
No Matches
Interpolation.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidKernel/DllConfig.h"
13#include "MantidKernel/Unit.h"
14#include <cstdlib>
15#include <sstream>
16#include <string>
17#include <vector>
18
19namespace Mantid {
20namespace Kernel {
21
22using DataXY = std::pair<double, double>;
29class MANTID_KERNEL_DLL Interpolation {
30private:
32 std::vector<DataXY> m_data;
33
35 std::string m_method;
36
39
42
43protected:
44 std::vector<DataXY>::const_iterator findIndexOfNextLargerValue(double key) const;
45 std::vector<DataXY>::const_iterator cbegin() const;
46 std::vector<DataXY>::const_iterator cend() const;
47
48public:
51 virtual ~Interpolation() = default;
52
54 void addPoint(const double &xx, const double &yy);
55
57 double value(const double &at) const;
58
60 void setMethod(const std::string &method) { m_method = method; }
61
63 std::string getMethod() const { return m_method; };
64
66 void setXUnit(const std::string &unit);
67
69 void setYUnit(const std::string &unit);
70
72 Unit_sptr getXUnit() const { return m_xUnit; };
73
75 Unit_sptr getYUnit() const { return m_yUnit; };
76
78 bool containData() const { return !m_data.empty(); }
79
81 void printSelf(std::ostream &os) const;
82
84 void resetData();
85};
86
87// defining operator << and >>
88MANTID_KERNEL_DLL std::ostream &operator<<(std::ostream &, const Interpolation &);
89MANTID_KERNEL_DLL std::istream &operator>>(std::istream &, Interpolation &);
90
91} // namespace Kernel
92} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
BuilderMethod< ArgType > m_method
const std::vector< Type > & m_data
Definition: TableColumn.h:417
Provide interpolation over a series of points.
Definition: Interpolation.h:29
void setMethod(const std::string &method)
set interpolation method
Definition: Interpolation.h:60
std::vector< DataXY > m_data
internal storage of x and y values
Definition: Interpolation.h:32
std::string getMethod() const
get interpolation method
Definition: Interpolation.h:63
virtual ~Interpolation()=default
bool containData() const
return false if no data has been added
Definition: Interpolation.h:78
std::string m_method
method used for doing the interpolation
Definition: Interpolation.h:35
Unit_sptr getYUnit() const
get y-axis unit
Definition: Interpolation.h:75
Unit_sptr getXUnit() const
get x-axis unit
Definition: Interpolation.h:72
Unit_sptr m_yUnit
unit of y-axis
Definition: Interpolation.h:41
Unit_sptr m_xUnit
unit of x-axis
Definition: Interpolation.h:38
MANTID_KERNEL_DLL std::ostream & operator<<(std::ostream &, CPUTimer &)
Convenience function to provide for easier debug printing.
Definition: CPUTimer.cpp:86
MANTID_KERNEL_DLL std::istream & operator>>(std::istream &, Interpolation &)
Reads in parameter value.
std::shared_ptr< Unit > Unit_sptr
Shared pointer to the Unit base class.
Definition: Unit.h:229
std::pair< double, double > DataXY
Definition: Interpolation.h:22
Helper class which provides the Collimation Length for SANS instruments.