Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Static Private Member Functions | List of all members
Mantid::API::ParameterTie Class Referencefinal

Ties fitting parameters. More...

#include <ParameterTie.h>

Inheritance diagram for Mantid::API::ParameterTie:
Mantid::API::ParameterReference

Public Member Functions

virtual std::string asString (const IFunction *fun=nullptr) const
 Return the string that can be used to recreate this tie. More...
 
virtual double eval (bool setParameterValue=true)
 Evaluate the expression. More...
 
bool findParametersOf (const IFunction *fun) const
 Check if the tie has any references to certain parameters. More...
 
std::vector< ParameterReferencegetRHSParameters () const
 Get a list of parameters on the right-hand side of the equation. More...
 
bool isConstant () const
 Check if the tie is a constant. More...
 
 ParameterTie (IFunction *funct, const std::string &parName, const std::string &expr="", bool isDefault=false)
 Constructor. More...
 
virtual void set (const std::string &expr)
 Set the tie expression. More...
 
 ~ParameterTie () override
 Destructor. More...
 
- Public Member Functions inherited from Mantid::API::ParameterReference
IFunctiongetLocalFunction () const
 Return pointer to the local function. More...
 
std::size_t getLocalIndex () const
 Return parameter index in the local function. More...
 
double getParameter () const
 Get the value of the parameter. More...
 
bool isDefault () const
 Returns the default value flag. More...
 
bool isParameterOf (const IFunction *fun) const
 Find out if this refers to a parameter of a function: direct or via composite function member. More...
 
IFunctionownerFunction () const
 
std::size_t parameterIndex () const
 Return parameter index in the owning function. More...
 
std::string parameterName () const
 Return parameter name in the owning function. More...
 
 ParameterReference ()
 Default constructor. More...
 
 ParameterReference (IFunction *fun, std::size_t index, bool isDefault=false)
 Constructor. More...
 
void setParameter (const double &value, bool isExplicitlySet=true)
 Set the parameter. More...
 
virtual ~ParameterReference ()=default
 

Protected Attributes

std::string m_expression
 Keep the template for the input string passed to this->set(...) In the template CompositeFunction prefixes are replaced with placeholders. More...
 
IFunctionm_function1
 Keep the function that was passed to the constructor. More...
 
std::unique_ptr< mu::Parser > m_parser
 math parser More...
 
std::map< double *, ParameterReferencem_varMap
 Store for parameters used in the tie. More...
 

Static Private Member Functions

static double * AddVariable (const char *varName, void *palg)
 MuParser callback function. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Mantid::API::ParameterReference
void reset (IFunction *fun, std::size_t index, bool isDefault=false)
 Reset the reference. More...
 

Detailed Description

Ties fitting parameters.

A tie is a formula that is used to calculate the value of a function parameter based on the values of other parameters. A tied parameter is not considered independent and doesn't take part in fitting. Its value is always calculated with its tie's formula.

Author
Roman Tolchenov, Tessella Support Services plc
Date
28/10/2009

Definition at line 35 of file ParameterTie.h.

Constructor & Destructor Documentation

◆ ParameterTie()

Mantid::API::ParameterTie::ParameterTie ( IFunction funct,
const std::string &  parName,
const std::string &  expr = "",
bool  isDefault = false 
)

Constructor.

Parameters
funct:: A pointer to the function which parameter will be tied
parName:: The name of the parameter to be tied
expr:: A mathematical expression for the tie
isDefault:: Flag to mark as default the value of an object associated with this reference: a tie or a constraint.

Definition at line 23 of file ParameterTie.cpp.

References AddVariable(), m_parser, and set().

◆ ~ParameterTie()

Mantid::API::ParameterTie::~ParameterTie ( )
override

Destructor.

Definition at line 36 of file ParameterTie.cpp.

References m_varMap.

Member Function Documentation

◆ AddVariable()

double * Mantid::API::ParameterTie::AddVariable ( const char *  varName,
void *  palg 
)
staticprivate

MuParser callback function.

Static callback function used by MuParser to initialize variables implicitly.

Parameters
varName:: The name of a new variable
palg:: Pointer to this ParameterTie
Returns
pointer to added variable

Definition at line 47 of file ParameterTie.cpp.

References m_function1, m_varMap, and Mantid::API::IFunction::parameterIndex().

Referenced by ParameterTie().

◆ asString()

std::string Mantid::API::ParameterTie::asString ( const IFunction fun = nullptr) const
virtual

Return the string that can be used to recreate this tie.

All parameters in the tie must be parameters of fun.

Parameters
fun:: Function that can re-create the tie from the output string.
Returns
string representation of function

Definition at line 125 of file ParameterTie.cpp.

References Mantid::API::ParameterReference::getLocalFunction(), Mantid::API::IFunction::getParameterIndex(), m_expression, m_function1, m_varMap, and Mantid::API::IFunction::parameterName().

Referenced by MantidQt::MantidWidgets::PropertyHandler::initTies(), MantidQt::MantidWidgets::PropertyHandler::renameChildren(), and Mantid::API::IFunction::sortTies().

◆ eval()

double Mantid::API::ParameterTie::eval ( bool  setParameterValue = true)
virtual

◆ findParametersOf()

bool Mantid::API::ParameterTie::findParametersOf ( const IFunction fun) const

Check if the tie has any references to certain parameters.

This method checks if any of the parameters of a function is used in the tie.

Parameters
fun:: A function
Returns
True if any of the parameters is used as a variable in the mu::Parser or it is the tied parameter.

Definition at line 171 of file ParameterTie.cpp.

References Mantid::API::ParameterReference::getLocalFunction(), and m_varMap.

◆ getRHSParameters()

std::vector< ParameterReference > Mantid::API::ParameterTie::getRHSParameters ( ) const

Get a list of parameters on the right-hand side of the equation.

Definition at line 186 of file ParameterTie.cpp.

References m_varMap.

◆ isConstant()

bool Mantid::API::ParameterTie::isConstant ( ) const

Check if the tie is a constant.

Definition at line 182 of file ParameterTie.cpp.

References m_varMap.

◆ set()

void Mantid::API::ParameterTie::set ( const std::string &  expr)
virtual

Set the tie expression.

Set tie expression.

Parameters
expr:: A math expression

Definition at line 62 of file ParameterTie.cpp.

References Mantid::API::IFunction::getParameterIndex(), m_expression, m_function1, m_parser, m_varMap, Mantid::API::IFunction::parameterName(), and std::to_string().

Referenced by ParameterTie(), and MantidQt::MantidWidgets::FitPropertyBrowser::stringChanged().

Member Data Documentation

◆ m_expression

std::string Mantid::API::ParameterTie::m_expression
protected

Keep the template for the input string passed to this->set(...) In the template CompositeFunction prefixes are replaced with placeholders.

Definition at line 64 of file ParameterTie.h.

Referenced by asString(), and set().

◆ m_function1

IFunction* Mantid::API::ParameterTie::m_function1
protected

Keep the function that was passed to the constructor.

Definition at line 61 of file ParameterTie.h.

Referenced by AddVariable(), asString(), and set().

◆ m_parser

std::unique_ptr<mu::Parser> Mantid::API::ParameterTie::m_parser
protected

math parser

Definition at line 56 of file ParameterTie.h.

Referenced by eval(), ParameterTie(), and set().

◆ m_varMap

std::map<double *, ParameterReference> Mantid::API::ParameterTie::m_varMap
protected

Store for parameters used in the tie.

The map's key is address used by the mu::Parser

Definition at line 59 of file ParameterTie.h.

Referenced by AddVariable(), asString(), eval(), findParametersOf(), getRHSParameters(), isConstant(), set(), and ~ParameterTie().


The documentation for this class was generated from the following files: