Operators
Function expressions consist of scalar or vector measures and functions, combined with a set of arithmetic and grouping operators. The operators closely resemble those of the FORTRAN programming language, with extensions for vector expressions.
Accepted Combinations
The following combinations are accepted. The symbol s represents a scalar subexpression and v represents a vector subexpression.
Parentheses grouping to override operator precedence (vector and scalar):
(v), (s)
Vector construction from scalar expressions:
[s,s,s]
Simple scalar arithmetic, including unary plus and unary minus:
s+s, s-s, s*s, s/s, -s, +s
Power (scalars only):
s**s
Vector summation, subtraction, unary minus and unary plus:
v+v, v-v, +v, -v
Scaling of a vector by a scalar:
s*v, v*s, v/s
Note that division by a vector is not supported.
Inner product (dot product):
v*v
Cross product:
v%v
Operators Precedence
Furthermore, in evaluating the arithmetic expressions, the following order of precedence is used:
**, - (unary), + (unary) | Highest precedence, tightest binding |
*, /, % | Intermediate precedence |
+, - | Lowest precedence, loosest binding |
Operators of equal precedence are applied from left to right, with the following exceptions for the power and unary operators:
A**B**C is interpreted as A**(B**C), not (A**B)**C
** binds tighter than unary operators to its left and looser than unary operators to its right. For example:
-A**-B = -(A**(-B))
and
-A**-B**-C = -(A**(-(B**(-C))))
In some cases parentheses must be used to group scalar and vector quantities such that the expression is not nonsensical. For example, v*v%v may need to be written as v*(v%v).
Vector subexpressions can appear in expressions where the final value is a scalar, and vice versa, for example:
VARIABLE/1, FUN=DXYZ(1,2)*VXYZ(1,2) + TIME
where a dot product of two vector measures results in a scalar quantity.
There are only two contexts in the current Adams language where a vector quantity is expected. These are the recently added FXYZ and TXYZ arguments of the VFORCE, VTORQUE and GFORCE statement which can be used instead of the FX, FY, FZ, TX, TY and TZ arguments to specify force and torque laws. In all other contexts, the expression must evaluate to a scalar quantity.