Vuo  2.0.0
Typedefs | Functions
VuoMathExpressionParser.h File Reference

Description

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...
 

Functions

void VuoMathExpressionParser_defineStandardLibrary (void *muparser)
 Given a pointer to a mu::Parser instance, adds Vuo's standard operators, constants, and functions. More...
 
VuoMathExpressionParser VuoMathExpressionParser_makeFromSingleExpression (VuoText expression, VuoMathExpressionError *error)
 Parses expression (e.g. More...
 
VuoMathExpressionParser VuoMathExpressionParser_makeFromMultipleExpressions (VuoList_VuoText expressions, VuoMathExpressionError *error)
 Parses expressions (e.g. More...
 
VuoList_VuoText VuoMathExpressionParser_getInputVariables (VuoMathExpressionParser m)
 Returns the unique input variable names from the parsed expression(s), in alphabetical order. More...
 
VuoList_VuoText VuoMathExpressionParser_getOutputVariables (VuoMathExpressionParser m)
 Returns the output variable names from the parsed expression(s), in the order they appeared. More...
 
VuoDictionary_VuoText_VuoReal VuoMathExpressionParser_calculate (VuoMathExpressionParser m, VuoDictionary_VuoText_VuoReal inputValues)
 Evaluates the parsed expression(s). More...
 
VuoList_VuoReal VuoMathExpressionParser_calculateList (VuoMathExpressionParser m, VuoList_VuoReal xValues, VuoDictionary_VuoText_VuoReal constants)
 Evaluates the expression for each of xValues. More...
 
const char * VuoMathExpressionError_getMessage (VuoMathExpressionError error)
 Returns a description of the error. More...
 
VuoList_VuoInteger VuoMathExpressionError_getExpressionIndices (VuoMathExpressionError error)
 Returns a sorted list of the indices of the math expressions causing the error. More...
 
void VuoMathExpressionError_free (VuoMathExpressionError error)
 Destructor. More...
 

Typedef Documentation

◆ VuoMathExpressionError

typedef void* VuoMathExpressionError

Error caused by invalid expression given to VuoMathExpressionParser.

Definition at line 26 of file VuoMathExpressionParser.h.

◆ VuoMathExpressionParser

typedef void* VuoMathExpressionParser

Parses and performs calculations with mathematical expressions.

Definition at line 25 of file VuoMathExpressionParser.h.

Function Documentation

◆ VuoMathExpressionError_free()

void VuoMathExpressionError_free ( VuoMathExpressionError  error)

Destructor.

Definition at line 107 of file VuoMathExpressionParser.cc.

◆ VuoMathExpressionError_getExpressionIndices()

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.

◆ VuoMathExpressionError_getMessage()

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.

◆ VuoMathExpressionParser_calculate()

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.

◆ VuoMathExpressionParser_calculateList()

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.

◆ VuoMathExpressionParser_defineStandardLibrary()

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.

◆ VuoMathExpressionParser_getInputVariables()

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.

◆ VuoMathExpressionParser_getOutputVariables()

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_makeFromMultipleExpressions()

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_makeFromSingleExpression()

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.