VuoMathExpressionParser interface.
Definition in file VuoMathExpressionParser.h.
Go to the source code of this file.
Typedefs | |
typedef void * | VuoMathExpressionParser |
Parses and performs calculations with mathematical expressions. More... | |
typedef void * | VuoMathExpressionError |
Error caused by invalid expression given to VuoMathExpressionParser. More... | |
typedef void* VuoMathExpressionError |
Error caused by invalid expression given to VuoMathExpressionParser.
Definition at line 26 of file VuoMathExpressionParser.h.
typedef void* VuoMathExpressionParser |
Parses and performs calculations with mathematical expressions.
Definition at line 25 of file VuoMathExpressionParser.h.
void VuoMathExpressionError_free | ( | VuoMathExpressionError | error | ) |
Destructor.
Definition at line 107 of file VuoMathExpressionParser.cc.
VuoList_VuoInteger VuoMathExpressionError_getExpressionIndices | ( | VuoMathExpressionError | error | ) |
Returns a sorted list of the indices of the math expressions causing the error.
The indices refer to the VuoList_VuoText passed to VuoMathExpressionParser_makeFromMultipleExpressions().
Definition at line 93 of file VuoMathExpressionParser.cc.
const char* VuoMathExpressionError_getMessage | ( | VuoMathExpressionError | error | ) |
Returns a description of the error.
The returned pointer is owned by error and should not be freed by the caller.
Definition at line 82 of file VuoMathExpressionParser.cc.
VuoDictionary_VuoText_VuoReal VuoMathExpressionParser_calculate | ( | VuoMathExpressionParser | m, |
VuoDictionary_VuoText_VuoReal | inputValues | ||
) |
Evaluates the parsed expression(s).
The value of each input variable is set from inputValues (a mapping of variable names to values). Any variables not in inputValues are set to 0.
Returns a mapping of output variable names to values.
Definition at line 644 of file VuoMathExpressionParser.cc.
VuoList_VuoReal VuoMathExpressionParser_calculateList | ( | VuoMathExpressionParser | m, |
VuoList_VuoReal | xValues, | ||
VuoDictionary_VuoText_VuoReal | constants | ||
) |
Evaluates the expression for each of xValues
.
Definition at line 686 of file VuoMathExpressionParser.cc.
void VuoMathExpressionParser_defineStandardLibrary | ( | void * | muparser | ) |
Given a pointer to a mu::Parser
instance, adds Vuo's standard operators, constants, and functions.
Definition at line 215 of file VuoMathExpressionParser.cc.
VuoList_VuoText VuoMathExpressionParser_getInputVariables | ( | VuoMathExpressionParser | m | ) |
Returns the unique input variable names from the parsed expression(s), in alphabetical order.
Definition at line 609 of file VuoMathExpressionParser.cc.
VuoList_VuoText VuoMathExpressionParser_getOutputVariables | ( | VuoMathExpressionParser | m | ) |
Returns the output variable names from the parsed expression(s), in the order they appeared.
For a non-assignment expression (e.g. "x + 1", as opposed to "y = x + 1"), a unique name is automatically assigned.
Definition at line 625 of file VuoMathExpressionParser.cc.
VuoMathExpressionParser VuoMathExpressionParser_makeFromMultipleExpressions | ( | VuoList_VuoText | expressions, |
VuoMathExpressionError * | error | ||
) |
Parses expressions (e.g.
["sum=n1+n2", "product=n1*n2", "n1-n2+5"]).
If parsing fails, returns null and sets error.
Definition at line 577 of file VuoMathExpressionParser.cc.
VuoMathExpressionParser VuoMathExpressionParser_makeFromSingleExpression | ( | VuoText | expression, |
VuoMathExpressionError * | error | ||
) |
Parses expression (e.g.
"a + b" or "y = x + 1").
If parsing fails, returns null and sets error.
Definition at line 553 of file VuoMathExpressionParser.cc.