Performs mathematical calculations using C language-style mathematical operations. Operates on inputs that are lists rather than collections of single values.
Like its companion expr object, the vexpr object evaluates expressions that use the "variables" $i1-$i9 (the first to ninth inlets, taken as integers), $f1-$f9 (the inlets as floats) and $s1-$s9 (the inlets as symbols), and/or constants of the same types. The vexpr object also has a scalar mode of operation that lets you use the object's inlet value as a single-item list for evaluation with all items in an input list.
The argument to the vexpr object is a mathematical expression composed of numbers, arithmetic operators such as + or *, comparisons such as or , C functions such as or , names of table objects, and changeable arguments ( , , and ) for ints, floats, and symbols received in the inlets.
Numbers can be used as constants in the mathematical expression.
Changeable arguments that specify data formats associated with an inlet are described using a combination of a data type (or ) and an inlet number (example: ). The argument will be replaced by numbers received in the specified inlet.
Changeable arguments that specify accessing data from a table are described using the argument table to be accessed. The argument should be immediately followed by a number in brackets specifying an address in the table. (Examples: or .)and an inlet number which is replaced by the name of a
The vexpr object understands the following arithmetic operators: , , , , %. Other operators are (one's complement), (bitwise exclusive or), , , , , and (not).
Many C language math functions can be understood by vexpr. A function must be followed immediately by parentheses containing any arguments necessary to the function. If the function requires a comma between arguments, the comma must be preceded by a backslash ( ) so that Max will not be confused by it. For example: .
C language functions understood by vexpr are: abs, min, max, sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh, int (convert to integer), float (convert to float), pow, sqrt, fact (factorial), exp (power of e to x), log10 (log), ln or log (natural log), and random. Additional functions can be added by means of external code resources placed in Max's startup folder.
The word, followed by a non-zero number, sets the scalar mode of operation. In scalar mode, sending a list of length 1 (i.e., a single value) will cause that value to be applied to each element of the other list. The message disables scalar mode.
Common Box Attributes
If the input in one of the inlets was a single number rather than a list, and the expression is evaluated as a float value, then a single result is sent out as a float rather than a list.
If the input in one of the inlets was a single number rather than a list, and the expression is evaluated as an integer value, then a single result is sent out as an int rather than a list.
When a list is received in the left inlet, vexpr uses the first item of the lists it has received in each of its different inlets, puts those items in place of the changeable arguments in the expression, and evaluates the expression. It then does the same with the second item in each list, and so on until it has used the last item of the shortest list. It then sends out all of the different results as a single list.
|Max Data Tutorial 5: List Processing||Max Data Tutorial 5: List Processing|