Mantid
Loading...
Searching...
No Matches
ParamFunction.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2009 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//----------------------------------------------------------------------
12#include "MantidAPI/DllConfig.h"
14#include "MantidAPI/IFunction.h"
16#include <string>
17#include <vector>
18
19namespace Mantid {
20namespace API {
21//----------------------------------------------------------------------
22// Forward declaration
23//----------------------------------------------------------------------
24class Jacobian;
33class MANTID_API_DLL ParamFunction : public virtual IFunction {
34public:
37
39 void setParameter(size_t, const double &value, bool explicitlySet = true) override;
41 void setParameterDescription(size_t, const std::string &description) override;
43 double getParameter(size_t i) const override;
45 void setParameter(const std::string &name, const double &value, bool explicitlySet = true) override;
47 void setParameterDescription(const std::string &name, const std::string &description) override;
49 double getParameter(const std::string &name) const override;
51 bool hasParameter(const std::string &name) const override;
53 size_t nParams() const override { return m_parameters.size(); }
55 size_t parameterIndex(const std::string &name) const override;
57 std::string parameterName(size_t i) const override;
59 std::string parameterDescription(size_t i) const override;
61 bool isExplicitlySet(size_t i) const override;
63 double getError(size_t i) const override;
65 double getError(const std::string &name) const override;
67 void setError(size_t i, double err) override;
69 void setError(const std::string &name, double err) override;
70
73 size_t getParameterIndex(const ParameterReference &ref) const override;
78
79protected:
81 void declareParameter(const std::string &name, double initValue = 0, const std::string &description = "") override;
83 virtual double *getParameterAddress(size_t i);
85 void clearAllParameters();
87 void setParameterStatus(size_t i, ParameterStatus status) override;
89 ParameterStatus getParameterStatus(size_t i) const override;
90
91private:
94 inline void checkParameterIndex(size_t i) const {
95 if (i >= nParams()) {
96 throw std::out_of_range("ParamFunction parameter index " + std::to_string(i) + " out of range " +
97 std::to_string(nParams()));
98 }
99 }
101 std::vector<ParameterStatus> m_parameterStatus;
103 std::vector<std::string> m_parameterNames;
105 std::vector<double> m_parameters;
107 std::vector<double> m_errors;
109 std::vector<bool> m_explicitlySet;
111 std::vector<std::string> m_parameterDescriptions;
112};
113
114} // namespace API
115} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
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
Implements the part of IFunction interface dealing with parameters.
Definition: ParamFunction.h:33
std::vector< std::string > m_parameterDescriptions
parameter descriptions
std::vector< double > m_parameters
Keeps parameter values.
std::vector< std::string > m_parameterNames
Keeps parameter names.
std::vector< double > m_errors
Keeps parameter errors.
ParamFunction()
Default constructor.
Definition: ParamFunction.h:36
std::vector< ParameterStatus > m_parameterStatus
Keeps status for each parameter.
IFunction_sptr getContainingFunction(const ParameterReference &ref) const
Get the containing function.
std::vector< bool > m_explicitlySet
Flags of explicitly set parameters.
size_t nParams() const override
Total number of parameters.
Definition: ParamFunction.h:53
void checkParameterIndex(size_t i) const
Check that a parameter index is in a valid range.
Definition: ParamFunction.h:94
IFunction_sptr getContainingFunction(IFunction_sptr fun)
Get the containing function.
A reference to a parameter in a function.
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.
std::string to_string(const wide_integer< Bits, Signed > &n)