tfel
Loading...
Searching...
No Matches
tfel::math::Evaluator Struct Reference

class in charge of handling a function defined by a string. More...

#include </home/runner/work/tfel/tfel/include/TFEL/Math/Evaluator.hxx>

Inheritance diagram for tfel::math::Evaluator:
tfel::math::parser::EvaluatorBase tfel::math::parser::ExternalFunction

Classes

struct  TLogicalOperation
struct  TLogicalBinaryOperation
struct  TExpr
struct  TNegation
struct  TOperator
struct  TBinaryOperation
struct  TLogicalExpr
struct  TNegLogicalExpr
struct  TConditionalExpr
struct  TVariable
struct  TGroup
struct  TFunction
struct  TBinaryFunction
struct  TExternalOperator
struct  TNumber
struct  TExternalFunctionExpr
struct  TDifferentiatedFunctionExpr

Public Types

using ExprPtr = std::shared_ptr<tfel::math::parser::Expr>
using FunctionGenerator = std::function<ExprPtr(const ExprPtr)>
using BinaryFunctionGenerator
typedef ExprPtr(* ExternalFunctionGenerator) (const std::vector< std::string > &, std::vector< ExprPtr > &)

Public Member Functions

 Evaluator (const std::string &)
 Evaluator (const std::vector< std::string > &, const std::string &)
 Evaluator (const std::string &, std::shared_ptr< tfel::math::parser::ExternalFunctionManager >)
 Evaluator (const std::vector< std::string > &, const std::string &, std::shared_ptr< tfel::math::parser::ExternalFunctionManager >)
 Evaluator (const double)
 build an evaluator from a value.
 Evaluator ()
 default constructor
 Evaluator (const Evaluator &)
 copy constructor
Evaluator & operator= (const Evaluator &)
 assignment operator
void setFunction (const std::string &)
void setFunction (const std::vector< std::string > &, const std::string &)
void setFunction (const std::string &, std::shared_ptr< tfel::math::parser::ExternalFunctionManager > &)
void setFunction (const std::vector< std::string > &, const std::string &, std::shared_ptr< tfel::math::parser::ExternalFunctionManager > &)
double getValue () const override
 evaluate the formula
double getValue (const std::map< std::string, double > &)
 evaluate the formula
double operator() () const
 evaluate the formula
double operator() (const std::map< std::string, double > &)
 evaluate the formula
std::vector< double >::size_type getNumberOfVariables () const override
void checkCyclicDependency (const std::string &) const override
void checkCyclicDependency (std::vector< std::string > &) const override
std::shared_ptr< tfel::math::parser::ExternalFunction > differentiate (const std::vector< double >::size_type) const override
std::shared_ptr< tfel::math::parser::ExternalFunction > differentiate (const std::string &) const override
std::shared_ptr< tfel::math::parser::ExternalFunction > resolveDependencies () const override
void setVariableValue (const std::vector< double >::size_type, const double) override
std::shared_ptr< ExternalFunction > createFunctionByChangingParametersIntoVariables (const std::vector< std::string > &) const override
std::shared_ptr< ExternalFunction > createFunctionByChangingParametersIntoVariables (std::vector< std::string > &, const std::vector< double > &, const std::vector< std::string > &, const std::map< std::string, std::vector< double >::size_type > &) const override
void getParametersNames (std::set< std::string > &) const override
virtual std::string getCxxFormula (const std::map< std::string, std::string > &={}) const
virtual std::vector< std::string > getVariablesNames () const
virtual void checkCyclicDependency () const
virtual void removeDependencies ()
virtual void setVariableValue (const std::string &, const double)
virtual void setVariableValue (const char *const, const double)

Static Public Member Functions

static FunctionGeneratorManager & getFunctionGeneratorManager ()
static double max (const double, const double)
static double min (const double, const double)
static double Heavyside (const double)
static bool isValidIdentifier (const std::string &)
static void checkParameterNumber (const std::vector< double >::size_type, const std::vector< double >::size_type)
static void checkVariableNumber (const std::vector< double >::size_type, const std::vector< double >::size_type)
static void checkNotEndOfExpression (const std::string &, const std::string &, const std::vector< std::string >::const_iterator, const std::vector< std::string >::const_iterator)
static void checkNotEndOfExpression (const std::string &, const std::vector< std::string >::const_iterator, const std::vector< std::string >::const_iterator)
static void readSpecifiedToken (const std::string &, const std::string &, std::vector< std::string >::const_iterator &, const std::vector< std::string >::const_iterator)
static unsigned short readUnsignedShortValue (const std::string &, std::vector< std::string >::const_iterator &, const std::vector< std::string >::const_iterator)
static unsigned short convertToUnsignedShort (const std::string &, const std::string &)
static unsigned int convertToUnsignedInt (const std::string &, const std::string &)
static bool isInteger (const std::string &)
static int convertToInt (const std::string &, const std::string &)
static std::shared_ptr< tfel::math::parser::Expr > makePowerFunctionExpression (std::shared_ptr< tfel::math::parser::Expr >, const int)
 return an expression representing the power of the given argument with an integer exponent.

Additional Inherited Members

Protected Member Functions inherited from tfel::math::parser::EvaluatorBase
 EvaluatorBase (const EvaluatorBase &)=default
 EvaluatorBase (EvaluatorBase &&)=default
EvaluatorBase & operator= (const EvaluatorBase &)=default
EvaluatorBase & operator= (EvaluatorBase &&)=default
void analyse (const std::string &)
Protected Attributes inherited from tfel::math::parser::EvaluatorBase
std::vector< std::string > tokens

Detailed Description

class in charge of handling a function defined by a string.

Member Typedef Documentation

◆ BinaryFunctionGenerator

using tfel::math::Evaluator::BinaryFunctionGenerator
Initial value:
std::function<ExprPtr(const ExprPtr, const ExprPtr)>

Constructor & Destructor Documentation

◆ Evaluator() [1/5]

tfel::math::Evaluator::Evaluator ( const std::string & )
explicit
Parameters
conststd::string&, function definition

◆ Evaluator() [2/5]

tfel::math::Evaluator::Evaluator ( const std::vector< std::string > & ,
const std::string &  )
explicit
Parameters
constvector<std::string>&, variable names
conststd::string&, function definition

◆ Evaluator() [3/5]

tfel::math::Evaluator::Evaluator ( const std::string & ,
std::shared_ptr< tfel::math::parser::ExternalFunctionManager >  )
explicit
Parameters
conststd::string&, function definition
externalfunction definition

◆ Evaluator() [4/5]

tfel::math::Evaluator::Evaluator ( const std::vector< std::string > & ,
const std::string & ,
std::shared_ptr< tfel::math::parser::ExternalFunctionManager >  )
explicit
Parameters
[in]constvector<std::string>&, variable name
[in]conststd::string&, function definition
[in]externalfunction definition

◆ Evaluator() [5/5]

tfel::math::Evaluator::Evaluator ( const double )
explicit

build an evaluator from a value.

Parameters
[in]vvalue

Member Function Documentation

◆ checkCyclicDependency() [1/2]

void tfel::math::Evaluator::checkCyclicDependency ( const std::string & ) const
overridevirtual

◆ checkCyclicDependency() [2/2]

void tfel::math::Evaluator::checkCyclicDependency ( std::vector< std::string > & ) const
overridevirtual

◆ createFunctionByChangingParametersIntoVariables() [1/2]

std::shared_ptr< ExternalFunction > tfel::math::Evaluator::createFunctionByChangingParametersIntoVariables ( const std::vector< std::string > & ) const
nodiscardoverridevirtual

◆ createFunctionByChangingParametersIntoVariables() [2/2]

std::shared_ptr< ExternalFunction > tfel::math::Evaluator::createFunctionByChangingParametersIntoVariables ( std::vector< std::string > & ,
const std::vector< double > & ,
const std::vector< std::string > & ,
const std::map< std::string, std::vector< double >::size_type > &  ) const
nodiscardoverridevirtual

◆ differentiate() [1/2]

std::shared_ptr< tfel::math::parser::ExternalFunction > tfel::math::Evaluator::differentiate ( const std::string & ) const
nodiscardoverridevirtual

◆ differentiate() [2/2]

std::shared_ptr< tfel::math::parser::ExternalFunction > tfel::math::Evaluator::differentiate ( const std::vector< double >::size_type ) const
nodiscardoverridevirtual

◆ getCxxFormula()

virtual std::string tfel::math::Evaluator::getCxxFormula ( const std::map< std::string, std::string > & = {}) const
nodiscardvirtual
Returns
a string representation of the evaluator suitable to be integrated in a C++ code.
Parameters
[in]ma map used to change the names of the variables

◆ getNumberOfVariables()

std::vector< double >::size_type tfel::math::Evaluator::getNumberOfVariables ( ) const
nodiscardoverridevirtual

◆ getParametersNames()

void tfel::math::Evaluator::getParametersNames ( std::set< std::string > & ) const
overridevirtual

◆ getValue() [1/2]

double tfel::math::Evaluator::getValue ( ) const
nodiscardoverridevirtual

evaluate the formula

Returns
the result of the evaluation
Note
variables values shall have been set with the setVariableValue method.

Implements tfel::math::parser::ExternalFunction.

◆ getValue() [2/2]

double tfel::math::Evaluator::getValue ( const std::map< std::string, double > & )
nodiscard

evaluate the formula

Parameters
[in]vsa map giving the values of some of the variables recquired to evaluate the formula.
Returns
the result of the evaluation
Note
the values of the variables not given in argument shall have been set with the setVariableValue method.

◆ getVariablesNames()

virtual std::vector< std::string > tfel::math::Evaluator::getVariablesNames ( ) const
nodiscardvirtual
Returns
the names of the variables, ordered by their positions: the index of a name in the returned vector is the position of the variable, i.e. the order of the variables given to the constructor, or the order of their first appearance in the expression otherwise

◆ makePowerFunctionExpression()

std::shared_ptr< tfel::math::parser::Expr > tfel::math::Evaluator::makePowerFunctionExpression ( std::shared_ptr< tfel::math::parser::Expr > ,
const int  )
static

return an expression representing the power of the given argument with an integer exponent.

Parameters
[in]eargument
[in]nexponent

◆ operator()() [1/2]

double tfel::math::Evaluator::operator() ( ) const
nodiscard

evaluate the formula

Returns
the result of the evaluation
Note
variables values shall have been set with the setVariableValue method.

◆ operator()() [2/2]

double tfel::math::Evaluator::operator() ( const std::map< std::string, double > & )
nodiscard

evaluate the formula

Parameters
[in]vsa map giving the values of some of the variables recquired to evaluate the formula.
Returns
the result of the evaluation
Note
the values of the variables not given in argument shall have been set with the setVariableValue method.

◆ resolveDependencies()

std::shared_ptr< tfel::math::parser::ExternalFunction > tfel::math::Evaluator::resolveDependencies ( ) const
nodiscardoverridevirtual

◆ setFunction() [1/4]

void tfel::math::Evaluator::setFunction ( const std::string & )
Parameters
conststd::string&, function definition

◆ setFunction() [2/4]

void tfel::math::Evaluator::setFunction ( const std::string & ,
std::shared_ptr< tfel::math::parser::ExternalFunctionManager > &  )
Parameters
conststd::string&, function definition
std::shared_ptr<ExternalFunctionManager>&,externalfunction definition

◆ setFunction() [3/4]

void tfel::math::Evaluator::setFunction ( const std::vector< std::string > & ,
const std::string &  )
Parameters
constvector<std::string>&, variable names
conststd::string&, function definition

◆ setFunction() [4/4]

void tfel::math::Evaluator::setFunction ( const std::vector< std::string > & ,
const std::string & ,
std::shared_ptr< tfel::math::parser::ExternalFunctionManager > &  )
Parameters
constvector<std::string>&, variable name
conststd::string&, function definition
std::shared_ptr<ExternalFunctionManager>&,externalfunction definition

◆ setVariableValue()

void tfel::math::Evaluator::setVariableValue ( const std::vector< double >::size_type ,
const double  )
overridevirtual

The documentation for this struct was generated from the following file: