HyperFun: Types, Variables and Declarations

There are two fundamental types for variables ('real' and 'array') and an additional one ('string').
  • Real

'Real' is the only elementary numeric type that is floating-point type and is equivalent to a 'double' type in C. Note that one can use integer constants but they are treated as a subclass of the same floating-point type; there is no explicit Boolean type but in the relational operators the floating-point value '0.' is treated as 'false', and other values are treated as 'true'.

Examples:

6.5
0
0.
-9.0
18
25e-3
-1.15E4

No declarations for floating-point variables are needed.

  • Array.
Array consisting of elements of numerical real (floating-point) type is the only structured type in the HyperFun. The declarations for arrays are necessary and have the following general form:

'array' <arrayName> '['<size>']' ';'

where 'size' is a constant representing a number of elements of the array. The array's elements are indexed from 1 to size. So one can access the i-th element as

<arrayName>[i]

Examples of declarations of arrays with names 'xx' and 'pz':

array xx[3], pz[8];

The first element of 'xx' will be xx[1], and the forth element of 'pz' will be pz[4].

There are two special arrays with reserved names:

- 'x' – represents an array of coordinate variables for any given point of modeling space;
- 'a' – represents an array of 'external' numerical parameters;

So, expressions inside a program can contain the elements of these arrays (for example: x[2], a[1]). It is supposed that the actual values for both arrays' elements are given from outside the program. The declarations for these arrays must be given in the head of a program (see below).

  • String

This type has a limited usage only as a constant being substituted instead of a corresponding function's argument. A string is represented as a sequence of characters surrounded by double quotation marks. The most typical usage of this type is to reference to a file name.
Example:

"teapot.dat"