This Appendix describes the form and syntax of transformation functions and the way in which they are used to define transformations.
A transformation is defined by specifying two ordered sets of transformation functions which define its forward and inverse mappings. These functions are stored as character data (typically in the elements of two CHARACTER arrays) and have the general form:
variable [= expression]
where variable is a valid variable name and expression is an arithmetic expression. Transformation functions therefore resemble Fortran 77 assignment statements, except that the contents of the square brackets [...] may be omitted in appropriate circumstances (see below). Variables and data coordinates. Variables are used in transformation functions to represent the coordinates of data points which will be transformed. Their names may be chosen freely to make the definition as comprehensible as possible; they may be of any length and may contain any alphanumeric character (including underscore) although they must start with an alphabetic character. A variable becomes defined when it appears on the left hand side of a transformation function and the name of each variable must appear on the left hand side of one (and only one) such function. Variables which appear on the left hand side of forward transformation functions are termed output variables, while those appearing on the left hand side of inverse transformation functions are termed input variables. Variables act only as “dummy arguments” and their names have no significance outside the transformation being defined. The correspondence between variables and the coordinates of external data points is established by the order in which the variables are defined. In the following, for instance, the first coordinate of an input data point would correspond with the variable ‘ALPHA’ and the second coordinate with ‘OMEGA’, while the two coordinates of an output data point would correspond with the variables ‘p’ and ‘q’ respectively:
|
|
Forward | Inverse |
The right hand sides of transformation functions closely follow the syntax of Fortran 77 arithmetic expressions. The main differences (in addition to the less restrictive naming rules for variables) are:
The following describes particular features of the expression syntax in more detail. Constants. Numerical constants may be written using any of the standard Fortran 77 forms (integer, real or double precision). For positive constants, a preceding sign is optional. Thus, all the following are valid constants:
0 | 1 | 57 | 666 | 1.0 | 3. | 0.5438 |
.303 | .5 | 1.234d6 | 4.6e3 | 9E4 | .44D19 | 3e0 |
At present there is no distinction between the data types of constants, so the form in which they are
written does not matter and their interpretation depends only on the type of arithmetic in use when
the expression is evaluated. This, in turn, may depend on the type of data being transformed
(Section 5.2) so constant values are converted automatically to the data type required. For instance, a
constant written as ‘2.1
’ might be interpreted as
integer (2), real (2.1E0), or double precision (2.1D0) according to the type of arithmetic being used. N.B. Handling of data types may change in future to allow implicit type conversion and “mixed mode” arithmetic. To avoid possible problems, floating-point to integer conversion of constants should currently be avoided if the constant has a fractional part. In practice such cases are rare.
Arithmetic operations. The standard arithmetic operators , , , and are available and their use is identical to Fortran 77, thus:
‘Q + 3.0 ’ | … | add 3.0 to Q |
‘-6.7 - DATA ’ | … | subtract DATA from 6.7 |
‘INPUT * 14 ’ | … | multiply INPUT by 14 |
‘4 / V2 ’ | … | divide 4 by V2 |
‘NUMBER ** INDEX ’ | … | raise NUMBER to the power INDEX |
The normal rules of operator precedence apply. Matching pairs of parentheses may also be used (and are recommended) to explicitly define the order of expression evaluation; they may be nested arbitrarily deeply. Note that the precision with which arithmetic is performed is not determined until an expression is actually evaluated (Section 5.2).6
Boolean operations. The standard logical/boolean operators .EQ., .NE., .GT., .LT., .GE., .LE., .OR., .AND. and .NOT. are available and their use is identical to Fortran 77, except that there is no distinct logical data type. These boolean operators have numerical operands and return numerical values. A numerical value is considered “true” if it is non-zero and “false” if it is zero.7 The above operators return a value of 1 for “true” and zero for “false”.
These operators may also be specified within an expression using the equivalent C forms: ==, !=, >, <, >=, <=, ||, && and !.
These operators can be used with the built-in function “QIF”. This function has 3 arguments. It returns the value of its second argument if its first argument is non-zero (i.e. “true”), and returns the value of its third argument otherwise. It can be used like the “?” operator in the C programming language.
Standard functions. A set of standard built-in functions is available and corresponds closely with the Fortran 77 set of intrinsic functions (Table 2). Function invocations take the same form as in Fortran and may be nested arbitrarily deeply.
These built-in functions are all generic and will adapt to the type of arithmetic being used. Some, however, do not support integer arithmetic and a bad value will be returned if this is in use (see Table 2). There are no data type conversion functions at present.
Function |
| Description | ||
SQRT | 1 | square root: | ||
LOG | 1 | natural logarithm: | ||
LOG10 | 1 | common logarithm: | ||
EXP | 1 | exponential: | ||
ABS | 1 | absolute (positive) value: | ||
NINT | 1 | nearest integer value to arg | ||
MAX | 2 or more | maximum of arguments | ||
MIN | 2 or more | minimum of arguments | ||
DIM | 2 | Fortran DIM (positive difference) function | ||
MOD | 2 | Fortran MOD (remainder) function | ||
SIGN | 2 | Fortran SIGN (transfer of sign) function | ||
SIN* | 1 | sine function: | ||
COS* | 1 | cosine function: | ||
TAN* | 1 | tangent function: | ||
ASIN* | 1 | inverse sine function: | ||
ACOS* | 1 | inverse cosine function: | ||
ATAN* | 1 | inverse tangent function: | ||
ATAN2* | 2 | Fortran ATAN2 (inverse tangent) function | ||
SINH* | 1 | hyperbolic sine function: | ||
COSH* | 1 | hyperbolic cosine function: | ||
TANH* | 1 | hyperbolic tangent function: | ||
*Function does not support integer arithmetic.
| ||||
Function |
| Description | ||
SIND | 1 | sine function: | ||
COSD | 1 | cosine function: | ||
TAND | 1 | tangent function: | ||
ASIND | 1 | inverse sine function: | ||
ACOSD | 1 | inverse cosine function: | ||
ATAND | 1 | inverse tangent function: | ||
ATAN2D | 2 | VAX Fortran ATAN2D (inverse tangent) function | ||
6Expressions such as ‘X2.0’ and ‘X2’ cannot currently be distinguished, whereas in Fortran they are different and the latter will evaluate more efficiently. Consequently (unless integer arithmetic is being used) the exponentiation operator ‘’ is an inefficient way of squaring a number and the equivalent expression ‘XX’ is preferred. This deficiency will be removed in future.
7This is the same convention used in the C programming language.