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 "MantidKernel/System.h"
16#include <cmath>
17
18namespace Mantid {
19
20//----------------------------------------------------------------------
21// Forward declaration
22//----------------------------------------------------------------------
23namespace API {
24class MatrixWorkspace;
25}
26
27namespace CurveFitting {
28namespace Functions {
56class MANTID_CURVEFITTING_DLL TabulatedFunction : public API::ParamFunction, public API::IFunction1D {
57public:
60
62 std::string name() const override { return "TabulatedFunction"; }
63 const std::string category() const override { return "General"; }
64 void function1D(double *out, const double *xValues, const size_t nData) const override;
66 void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override;
67
69 size_t nAttributes() const override;
71 std::vector<std::string> getAttributeNames() const override;
73 Attribute getAttribute(const std::string &attName) const override;
75 void setAttribute(const std::string &attName, const IFunction::Attribute &value) override;
76
77private:
79 void load(const std::string &fname);
80
82 void loadWorkspace(const std::string &wsName) const;
83
85 void loadWorkspace(std::shared_ptr<API::MatrixWorkspace> ws) const;
86
88 size_t size() const { return m_yData.size(); }
89
91 void clear() const;
92
94 void eval(double scaling, double xshift, double xscale, double *out, const double *xValues, const size_t nData) const;
95
97 void setupData() const;
98
100 static const int defaultIndexValue;
101
103 mutable std::shared_ptr<API::MatrixWorkspace> m_workspace;
104
106 mutable std::vector<double> m_xData;
107
109 mutable std::vector<double> m_yData;
110
112 mutable bool m_setupFinished;
113
115 mutable bool m_explicitXY;
116};
117
118} // namespace Functions
119} // namespace CurveFitting
120} // 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:282
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
Implements the part of IFunction interface dealing with parameters.
Definition: ParamFunction.h:33
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.