The Arithmetic operators contain both unary and binary operations:
Unary Operators
|
Unary operators have two parameters: src and answer. Both of these parameters follow the syntax based upon the equation below:
{op}(src) = answer
where:
op - is the unary operation: Inverse (inv), SquareRoot (sqrt),
Power (^), etc.
src - is the input table to the operator op.
answer - contains the result if the operation is successful.
|
Binary Operators
|
Binary operators follow a syntax based upon the following equation:
lhs {op} rhs = answer
where:
op - is the binary operator: Add (+), Subtract(-), Multiply(*),
Divide (/).
lhs - is the left-hand side of the binary operator op.
rhs - is the right-hand side of the operator.
answer - contains the result if the operation is successful.
|
The Math library contains the following Arithmetic operators:
Adds records in lhs to rhs and stores the result in answer.
Inputs
|
lhs: a value table.
rhs: a value table.
|
Outputs
|
answer: a value table.
|
Notes
|
• | lhs, rhs, and answer must be of the same binding. |
• | lhs, rhs, and answer must be of the same format (after promotion). |
• | If lhs and rhs are both constant value tables (created by the Constant operator), no records will be added to the answer table. |
• | When adding directional values such as vector and tensor, no checks are made to verify they are relative to the same system. |
|
Expression Builder
|
lhs + rhs
|
XML Example
|
<call name="Add" lhs="lhs_tab" rhs="rhs_tab"
answer="ans_tab" />
|
|
Subtracts records in rhs from lhs and stores the result in answer.
Inputs
|
lhs: a value table.
rhs: a value table.
|
Outputs
|
answer: a value table.
|
Notes
|
• | lhs, rhs, and answer must be of the same binding. |
• | lhs, rhs, and answer must be of the same format (after promotion). |
• | If lhs and rhs are both constant value tables (created by the Constant operator), no records will be added to the answer table. |
• | When subtracting directional values such as vector and tensor, no checks are made to verify they are relative to the same system. |
|
Expression Builder
|
lhs - rhs
|
XML Example
|
<call name="Subtract" lhs="lhs_tab" rhs="rhs_tab"
answer="ans_tab" />
|
|
Multiplies records in lhs with rhs and stores the result in answer.
Inputs
|
lhs: a value table.
rhs: a value table.
|
Outputs
|
answer: a value table.
|
Notes
|
• | lhs, rhs, and answer must be of the same binding. |
• | lhs, rhs, and answer must be of the same format (after promotion). |
• | If lhs and rhs are both constant value tables (created by the Constant operator), no records will be added to the answer table. |
• | If lhs and rhs are vectors or tensors, a component-wise multiplication is performed, functioning as a scale operation). |
|
Expression Builder
|
lhs * rhs
|
XML Example
|
<call name="Multiply" lhs="lhs_tab" rhs="rhs_tab"
answer="ans_tab" />
|
|
Divides records in lhs by rhs and stores the result in answer.
Inputs
|
lhs: a value table.
rhs: a value table.
|
Outputs
|
answer: a value table.
|
Notes
|
• | lhs, rhs, and answer must be of the same binding. |
• | lhs, rhs, and answer must be of the same format (after promotion). |
• | If lhs and rhs are both constant value tables (created by the Constant operator), no records will be added to the answer table. |
• | If lhs and rhs are vectors or tensors, a component-wise division is performed, functioning as an inverse-scale operation). |
• | If a record in rhs contains any zeros, no value will be placed in the answer table. |
|
Expression Builder
|
lhs / rhs
|
XML Example
|
<call name="Divide" lhs="lhs_tab" rhs="rhs_tab"
answer="ans_tab" />
|
|
Stores the absolute value of src in answer.
Inputs
|
src: a value table.
|
Outputs
|
answer: a value table.
|
Notes
|
• | src and answer must be of the same binding and format. |
• | If src is a constant value table (created by the Constant operator), no records will be added to the answer table. |
|
Expression Builder
|
abs(src)
|
XML Example
|
<call name="Absolute" src="src_tab" answer="ans_tab" />
|
|
Stores the reciprocal of src in answer.
Inputs
|
src: a value table.
|
Outputs
|
answer: a value table.
|
Notes
|
• | src and answer must be of the same binding and format. |
• | If src is a constant value table (created by the Constant operator), no records will be added to the answer table. |
• | If a record in src contains any zeros, no value will be placed in the answer table. |
• | If src contains multiple components (a vector or tensor value), answer will contain the same number of components with each being the reciprocal of src (for example, if src is a vector, answer will contain components of 1/x, 1/y, and 1/z). |
|
Expression Builder
|
recip(src)
|
XML Example
|
<call name="Reciprocal" src="src_tab" answer="ans_tab" />
|
|
See also
Binary Operation Argument Promotion