-
Notifications
You must be signed in to change notification settings - Fork 122
/
Interpolation.h
111 lines (83 loc) · 3.04 KB
/
Interpolation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef MANTID_KERNEL_INTERPOLATION_H_
#define MANTID_KERNEL_INTERPOLATION_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/Property.h"
#include "MantidKernel/Exception.h"
#include "MantidKernel/DllConfig.h"
#include "MantidKernel/DateAndTime.h"
#include "MantidKernel/Unit.h"
#include <map>
#include <vector>
#include <sstream>
#include <stdlib.h>
#include <cctype>
namespace Mantid
{
namespace Kernel
{
/**
Provide interpolation over a series of points.
@author Anders Markvardsen, ISIS, RAL
@date 9/3/2010
Copyright © 2007-2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class MANTID_KERNEL_DLL Interpolation
{
private:
///internal storage of x values
std::vector<double> m_x;
///internal storage of y values
std::vector<double> m_y;
/// method used for doing the interpolation
std::string m_method;
/// unit of x-axis
Unit_sptr m_xUnit;
/// unit of y-axis
Unit_sptr m_yUnit;
public:
/// Constructor default to linear interpolation and x-unit set to TOF
Interpolation();
/// add data point
void addPoint(const double& xx, const double& yy);
/// get interpolated value at location at
double value(const double& at) const;
/// set interpolation method
void setMethod(const std::string& method) { m_method=method; }
/// get interpolation method
std::string getMethod() const { return m_method; };
/// set x-axis unit
void setXUnit(const std::string& unit);
/// set y-axis unit
void setYUnit(const std::string& unit);
/// get x-axis unit
Unit_sptr getXUnit() const { return m_xUnit; };
/// get y-axis unit
Unit_sptr getYUnit() const { return m_yUnit; };
/// return false if no data has been added
bool containData() const { return m_x.size() ? true : false;}
/// Prints object to stream
void printSelf(std::ostream& os) const;
/// Clear interpolation values
void resetData();
};
// defining operator << and >>
MANTID_KERNEL_DLL std::ostream& operator<<(std::ostream&, const Interpolation& );
MANTID_KERNEL_DLL std::istream& operator>>(std::istream&, Interpolation&);
} // namespace Kernel
} // namespace Mantid
#endif /*MANTID_KERNEL_INTERPOLATION_H_*/