Vuo  1.2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Typedefs | Functions
VuoMathExpressionParser.h File Reference

Description

VuoMathExpressionParser interface.

Typedefs

typedef void * VuoMathExpressionParser
 Parses and performs calculations with mathematical expressions.
 
typedef void * VuoMathExpressionError
 Error caused by invalid expression given to VuoMathExpressionParser.
 

Functions

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

Typedef Documentation

typedef void* VuoMathExpressionError

Error caused by invalid expression given to VuoMathExpressionParser.

typedef void* VuoMathExpressionParser

Parses and performs calculations with mathematical expressions.

Function Documentation

void VuoMathExpressionError_free ( VuoMathExpressionError  error)

Destructor.

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

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.

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.

VuoList_VuoReal VuoMathExpressionParser_calculateList ( VuoMathExpressionParser  m,
VuoList_VuoReal  xValues,
VuoDictionary_VuoText_VuoReal  constants 
)

Evaluates the expression for each of xValues.

void VuoMathExpressionParser_defineStandardLibrary ( void *  muparser)

Given a pointer to a mu::Parser instance, adds Vuo's standard operators, constants, and functions.

VuoList_VuoText VuoMathExpressionParser_getInputVariables ( VuoMathExpressionParser  m)

Returns the unique input variable names from the parsed expression(s), in alphabetical order.

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.

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.

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.