Mantid
Loading...
Searching...
No Matches
FunctionGenerator.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
10
11namespace Mantid {
12namespace API {
31class MANTID_API_DLL FunctionGenerator : public IFunction {
32public:
34 FunctionGenerator(const IFunction_sptr &source);
35
38
39
40 void setParameter(size_t, const double &value, bool explicitlySet = true) override;
42 void setParameterDescription(size_t, const std::string &description) override;
44 double getParameter(size_t i) const override;
46 void setParameter(const std::string &name, const double &value, bool explicitlySet = true) override;
48 void setParameterDescription(const std::string &name, const std::string &description) override;
50 double getParameter(const std::string &name) const override;
52 bool hasParameter(const std::string &name) const override;
54 size_t nParams() const override;
56 size_t parameterIndex(const std::string &name) const override;
58 std::string parameterName(size_t i) const override;
60 std::string parameterDescription(size_t i) const override;
62 bool isExplicitlySet(size_t i) const override;
64 double getError(size_t i) const override;
66 double getError(const std::string &name) const override;
68 void setError(size_t i, double err) override;
70 void setError(const std::string &name, double err) override;
71
73 size_t getParameterIndex(const ParameterReference &ref) const override;
75 void setUpForFit() override;
77 ParameterTie *getTie(size_t i) const override;
79 IConstraint *getConstraint(size_t i) const override;
80
82 virtual void buildTargetFunction() const = 0;
83
84protected:
86 void declareParameter(const std::string &name, double initValue = 0, const std::string &description = "") override;
88 void setParameterStatus(size_t i, ParameterStatus status) override;
90 ParameterStatus getParameterStatus(size_t i) const override;
92
93public:
97 size_t nAttributes() const override;
99 std::vector<std::string> getAttributeNames() const override;
101 Attribute getAttribute(const std::string &name) const override;
103 void setAttribute(const std::string &name, const Attribute &) override;
105 bool hasAttribute(const std::string &name) const override;
106 // Get ith attribute name
107 std::string attributeName(size_t i) const override;
108
110
112 void function(const FunctionDomain &domain, FunctionValues &values) const override;
113
114protected:
116 void init() override;
118 void setSource(IFunction_sptr source) const;
119
121 virtual bool isSourceName(const std::string &aName) const;
123 virtual void updateTargetFunction() const = 0;
125 void checkTargetFunction() const;
131 mutable size_t m_nOwnParams;
133 mutable bool m_dirty;
134};
135
136} // namespace API
137} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
Base class that represents the domain of a function.
FunctionGenerator is a partial implementation of IFunction that defines a function consisting of two ...
IFunction_sptr m_source
Function that calculates parameters of the target function.
virtual void buildTargetFunction() const =0
Build target function.
IFunction_sptr m_target
Function that actually calculates the output.
virtual void updateTargetFunction() const =0
Update target function.
bool m_dirty
Flag indicating that updateTargetFunction() is required.
size_t m_nOwnParams
Cached number of parameters in m_source.
A class to store values calculated by a function.
An interface to a constraint.
Definition: IConstraint.h:26
Attribute is a non-fitting parameter.
Definition: IFunction.h:282
This is an interface to a fitting function - a semi-abstarct class.
Definition: IFunction.h:163
ParameterStatus
Describe parameter status in relation to fitting: Active: Fit varies such parameter directly.
Definition: IFunction.h:649
A reference to a parameter in a function.
Ties fitting parameters.
Definition: ParameterTie.h:35
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732
Helper class which provides the Collimation Length for SANS instruments.