#include <MathExternalExpression.h>
The MathExternalExpression allows to manage an external math expression.
- Since
- 4.2
◆ ~MathExternalExpression()
| virtual myscript::iink::MathExternalExpression::~MathExternalExpression |
( |
| ) |
|
|
virtualdefault |
◆ getString()
| virtual String myscript::iink::MathExternalExpression::getString |
( |
| ) |
|
|
pure virtual |
Returns the expression original string.
- Returns
- the original string.
◆ getDiagnostic()
| virtual MathDiagnostic myscript::iink::MathExternalExpression::getDiagnostic |
( |
const String & |
task, |
|
|
std::shared_ptr< ParameterSet > |
overrideConfiguration = nullptr |
|
) |
| |
|
pure virtual |
Returns the diagnostic info for the given task.
- Parameters
-
| task | the task to diagnose. Only "evaluation" is currently supported. |
| overrideConfiguration | the extra configuration used. |
- Returns
- a diagnostic code.
- Exceptions
-
| std::invalid_argument | when task is invalid. |
| std::invalid_argument | when overrideConfiguration is invalid. |
◆ getEvaluables()
Returns the list of variable names that can be evaluated. An expression with no syntax error can be evaluated when it contains:
- a variable definition
- a single (multi-occurrence) undefined variable and no equal sign
- an equal sign and two undefined variables, with at least one being a single-occurrence Returns an empty list if expression cannot be evaluated.
Example: see MathSolverController::getEvaluables.
Note: in case both variables can be evaluated interchangeably, the first returned MathEvaluationVariables will use the (leftmost) isolated variable as output if any. Example: "y = cos(x) + 1" will always return: {{ in:"x", out:"y" }, { in:"y", out:"x" }} in that order.
- Returns
- a list of MathEvaluationVariables that can be evaluated.
◆ evaluate()
Returns the list of points resulting from evaluating the given variables.
Example: for "y = 2x", evaluate({ in:"x", out:"y" }, -1, 1, 3) returns { {-1, -2}, {0, 0}, {1, 2} }
- Parameters
-
| variables | the variables to evaluate. |
| from | the start of the range to evaluate. |
| to | the end of the range to evaluate. |
| pointCount | the number of values to evaluate between [from, to]. |
| overrideConfiguration | the extra configuration used. |
- Returns
- a list of evaluated points, representing continuous parts of a curve. With
point.x being the input value and point.y the evaluated variable output.
- Exceptions
-
| std::invalid_argument | when variables are not evaluables. |
| std::invalid_argument | when from or to is not a number. |
| std::invalid_argument | when from is greater than to. |
| std::invalid_argument | when pointCount is not in [1, 10000]. |
| std::invalid_argument | when overrideConfiguration is invalid. |
◆ asVariableDefinition()
Checks if expression represents a variable definition and returns the associated information. An expression represents a variable definition if it is an equation with a single variable on the left of the equal sign and at least one constant expression on the right (first value is used). Example: "a = 1/2" or "b = 1/3 = 0.33"
- Returns
- the name and value of the defined variable if any, otherwise an invalid definition.
◆ getVariables()
| virtual std::vector< MathVariableInfo > myscript::iink::MathExternalExpression::getVariables |
( |
| ) |
|
|
pure virtual |
Retrieves information about all variables associated with the expression.
- Returns
- a vector containing the information of all variables.
◆ getVariableValue()
| virtual double myscript::iink::MathExternalExpression::getVariableValue |
( |
const String & |
name | ) |
|
|
pure virtual |
Returns the value associated with the given variable name.
- Parameters
-
- Returns
- a variable value.
- Exceptions
-
| std::invalid_argument | if name is not an existing variable name. |
◆ setVariableValue()
| virtual void myscript::iink::MathExternalExpression::setVariableValue |
( |
const String & |
name, |
|
|
double |
value |
|
) |
| |
|
pure virtual |
Sets the value associated with the given variable name.
- Parameters
-
| name | the variable name. |
| value | the variable value. |
- Exceptions
-
| std::invalid_argument | when name is an invalid variable name. |
| std::invalid_argument | when value is an invalid variable value. |
◆ removeVariableValue()
| virtual bool myscript::iink::MathExternalExpression::removeVariableValue |
( |
const String & |
name | ) |
|
|
pure virtual |
Removes the definition of the given variable name.
- Parameters
-
- Returns
true if the variable existed, otherwise false.
The documentation for this class was generated from the following file: