/
SplineInterpolation.h
99 lines (77 loc) · 3.61 KB
/
SplineInterpolation.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
#ifndef MANTID_CURVEFITTING_SPLINEINTERPOLATION_H_
#define MANTID_CURVEFITTING_SPLINEINTERPOLATION_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidCurveFitting/Functions/CubicSpline.h"
namespace Mantid {
namespace CurveFitting {
namespace Algorithms {
/** Takes two workspaces as input. One contain a set of points which define a
spline,
and one which contains a number of spectra to be interpolated against spline.
Produces an output workspace containing the interpolated points
Optionally the algorithm will also produce a grouped workspace of derivatives
of up to order 2
for each of the interpolated points.
@author Samuel Jackson, STFC
@date 25/07/2013
Copyright © 2013 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
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 DLLExport SplineInterpolation : public API::Algorithm {
public:
SplineInterpolation();
~SplineInterpolation() override;
const std::string name() const override;
int version() const override;
const std::string category() const override;
/// Summary of algorithms purpose
const std::string summary() const override {
return "Interpolates a set of spectra onto a spline defined by a second "
"input workspace. Optionally, this algorithm can also calculate "
"derivatives up to order 2 as a side product";
}
private:
void init() override;
void exec() override;
/// CubicSpline member used to perform interpolation
boost::shared_ptr<Functions::CubicSpline> m_cspline;
/// setup an output workspace using meta data from inws and taking a number of
/// spectra
API::MatrixWorkspace_sptr
setupOutputWorkspace(API::MatrixWorkspace_sptr mws,
API::MatrixWorkspace_sptr iws) const;
/// convert a binned workspace to point data. Uses mean of the bins as point
API::MatrixWorkspace_sptr
convertBinnedData(API::MatrixWorkspace_sptr workspace) const;
/// set the points that define the spline used for interpolation of a
/// workspace
void setInterpolationPoints(API::MatrixWorkspace_const_sptr inputWorkspace,
const int row) const;
/// Calculate the interpolation of the input workspace against the spline and
/// store it in outputWorkspace
void calculateSpline(API::MatrixWorkspace_const_sptr inputWorkspace,
API::MatrixWorkspace_sptr outputWorkspace,
int row) const;
/// Calculate the derivatives of the input workspace from the spline.
void calculateDerivatives(API::MatrixWorkspace_const_sptr inputWorkspace,
API::MatrixWorkspace_sptr outputWorkspace,
int order) const;
};
} // namespace Algorithms
} // namespace CurveFitting
} // namespace Mantid
#endif /* MANTID_CURVEFITTING_SPLINEINTERPOLATION_H_ */