Mantid
Loading...
Searching...
No Matches
TabulatedFunction.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//----------------------------------------------------------------------
14#include "MantidCurveFitting/DllConfig.h"
15#include <cmath>
16
17namespace Mantid {
18
19//----------------------------------------------------------------------
20// Forward declaration
21//----------------------------------------------------------------------
22namespace API {
23class MatrixWorkspace;
24}
25
26namespace CurveFitting {
27namespace Functions {
55class MANTID_CURVEFITTING_DLL TabulatedFunction : public API::ParamFunction, public API::IFunction1D {
56public:
59
61 std::string name() const override { return "TabulatedFunction"; }
62 const std::string category() const override { return "General"; }
63 void function1D(double *out, const double *xValues, const size_t nData) const override;
65 void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override;
66
68 size_t nAttributes() const override;
70 std::vector<std::string> getAttributeNames() const override;
72 Attribute getAttribute(const std::string &attName) const override;
74 void setAttribute(const std::string &attName, const IFunction::Attribute &value) override;
75
76private:
78 void load(const std::string &fname);
79
81 void loadWorkspace(const std::string &wsName) const;
82
84 void loadWorkspace(std::shared_ptr<API::MatrixWorkspace> ws) const;
85
87 size_t size() const { return m_yData.size(); }
88
90 void clear() const;
91
93 void eval(double scaling, double xshift, double xscale, double *out, const double *xValues, const size_t nData) const;
94
96 void setupData() const;
97
99 static const int defaultIndexValue;
100
102 mutable std::shared_ptr<API::MatrixWorkspace> m_workspace;
103
105 mutable std::vector<double> m_xData;
106
108 mutable std::vector<double> m_yData;
109
111 mutable bool m_setupFinished;
112
114 mutable bool m_explicitXY;
115};
116
117} // namespace Functions
118} // namespace CurveFitting
119} // namespace Mantid
double value
The value of the point.
Definition FitMW.cpp:51
This is a specialization of IFunction for functions of one real argument.
Definition IFunction1D.h:43
Attribute is a non-fitting parameter.
Definition IFunction.h:285
Represents the Jacobian in IFitFunction::functionDeriv.
Definition Jacobian.h:22
Implements the part of IFunction interface dealing with parameters.
A function which takes its values from a file or a workspace.
static const int defaultIndexValue
The default value for the workspace index.
std::shared_ptr< API::MatrixWorkspace > m_workspace
Temporary workspace holder.
std::vector< double > m_yData
Stores y-values.
bool m_explicitXY
Flag of explicit x-y data setup.
bool m_setupFinished
Flag of completing data setup.
const std::string category() const override
The categories the Fit function belong to.
std::string name() const override
overwrite IFunction base class methods
std::vector< double > m_xData
Stores x-values.
Helper class which provides the Collimation Length for SANS instruments.