ARRAY Definitions

<< Click to Display Table of Contents >>

Navigation:  Problem Descriptor Reference > The Sections of a Descriptor > Definitions >

ARRAY Definitions

Previous pageReturn to chapter overviewNext page

Names may be defined as representing arrays or lists of values. ARRAY definition can take several forms:


name = ARRAY ( value_1 , value_2 ... value_n )

defines name to be an n-element array of values value_1 ... value_n.

name = ARRAY [ number ]

defines name to be an array of number elements.  Values are as yet undefined, and must be supplied later in the script.

name = ARRAY [ number ] ( value_1 , value_2 ... value_number )

defines name to be an array of number elements, whose values are value_1, value_2, etc.

name = ARRAY FOR param (initial BY step TO final)  :  expression

defines name to be an array of values generated by evaluating expression with param set to initial, initial + step, initial + 2*step, and so forth up to param = final.

name = ARRAY FOR param ( P1 , P2 { , P3 ...} )  :  expression

defines name to be an array of values generated by evaluating expression with param set to P1, P2, and so forth up to the end of the listed parameters.

The values assigned to ARRAY elements must evaluate to scalar numbers.  They may contain coordinate or variable dependencies, but must not be VECTOR, COMPLEX or TENSOR quantities.


v = array(0,1,2,3,4,5,6,7,8,9,10)
w = array(0 by 0.1 to 10)
alpha =array for x(0 by 0.1 to 10)  : sin(x)+1.

Referencing ARRAY values

Within the body of the descriptor, ARRAY values may be referenced by the form

name [ index ]

The value of the selected ARRAY element is computed and used as though it were entered literally in the text.

ARRAY elements that have not been previously assigned may be given values individually by conventional assignment syntax:

name [ index ] = expression


Arithmetic Operations on ARRAYS

Arithmetic operations may be performed on ARRAYS as with scalar values.  Names defined as the result of ARRAY arithmetic will be implicitly defined as ARRAYS.  Arithmetic operations and functions on ARRAYS are applied element-by-element.

ARRAYS may also be operated on by MATRICES (q.v.)



beta = sin(w)+1.1        { beta is an ARRAY with the same data as alpha }
gamma = sin(v)+0.1        { gamma is an ARRAY with the dimension of v }


The SIZEOF operator


The operator SIZEOF may be used to retrieve the allocated size of an ARRAY.


n = SIZEOF(v)                { returns 11, the allocates size of the example array "v" above }


ARRAYS of Constant Values

Normally, ARRAYS are stored as the defining formulas for the elements, and are recomputed as needed.  In rare cases (as with RANDOM elements), this is inappropriate.  The qualifier CONST can be prepended to the ARRAY definition to force the storage of numeric values instead of defining formulas.  Elements will be computed when the script is parsed, and will not be recomputed.  For example:

name = CONST ARRAY ( value_1 , value_2 ... value_n )


Note: Scripts with staged geometry will reparse the script file and regenerate any CONST values.


See Also: "Using ARRAYS and MATRICES"