<< Click to Display Table of Contents >> MATRIX Definitions 
Names may be defined as representing matrices or tables of values. MATRIX definition can take several forms:
name = MATRIX ( ( value_11 , value_12 ... value_1m ) ,
... ( value_n1 , value_n2 ... value_nm) )
defines name to be a matrix of values with n rows and m columns.
name = MATRIX [ rows , columns ]
defines name to be an matrix of elements with the stated dimensions. Values are as yet undefined, and must be supplied later in the script.
name = MATRIX [ n , m ] ( ( value_11 , value_12 ... value_1m ) ,
... ( value_n1 , value_n2 ... value_nm) )
defines name to be an array of number elements, whose values are as listed.
name = MATRIX FOR param1 (initial1 BY step1 TO final1 )
FOR param2 (initial2 BY step2 TO final2 ) : expression
defines name to be a matrix of values generated by evaluating expression with param1 and param2 set to the indicated range of values. param2 is cycled to create columns, and param1 is cycled to create rows.
name = MATRIX FOR param1 ( P11 , P12 { , P13 ...} )
FOR param2 ( P21 , P22 { , P23 ...} ) : expression
defines name to be a matrix of values generated by evaluating expression with param1 and param2 set to the indicated range of values. param2 is cycled to create columns, and param1 is cycled to create rows.
The values assigned to MATRIX elements must evaluate to scalar numbers. They may contain coordinate or variable dependencies, but must not be VECTOR, COMPLEX or TENSOR quantities.
Examples:
m1 = matrix((1,2,3),(4,5,6),(7,8,9))
m2 = matrix for x(0.1 by 0.1 to 5*pi/2) { a 79x79 diagonal matrix of amplitude 10 }
for y(0.1 by 0.1 to 5*pi/2) : if(x=y) then 10 else 0
m3 = matrix for x(0.1 by 0.1 to 5*pi/2) { a 79x79 matrix of sin products }
for y(0.1 by 0.1 to 5*pi/2) : sin(x)*sin(y) +1
Referencing MATRIX values
Within the body of the descriptor, MATRIX values may be referenced by the form
name [ row_index , column_index ]
The value of the selected MATRIX element is computed and used as though it were entered literally in the text.
MATRIX elements that have not been previously assigned may be given values individually by conventional assignment syntax:
name [ row_index , column_index ] = expression
Arithmetic Operations on MATRICES
Arithmetic operations may be performed on MATRICES. Names defined as the result of MATRIX arithmetic will be implicitly defined as MATRICES or ARRAYS, as appropriate to the operation.
•Standard arithmetic operations and functions on MATRICES are applied elementbyelement.
•The special operator ** is defined for conventional matrix multiplication
Examples:
N = M1 * M2 
{ N is a MATRIX, each element of which is the product of corresponding elements in M1 and M2 } 
S = sin(M) 
{ S is a MATRIX, each element of which is the sine of the corresponding element of M } 
N = M1 ** M2 
{ N is a MATRIX, each element of which is the dot product of corresponding row in M1 and column in M2 (ie, conventional matrix multiplication) } 


Arithmetic Operations of MATRICES on ARRAYS
Arithmetic operations may be performed by MATRICES on ARRAYS. Names defined as the result of these operations will be implicitly defined as ARRAYS, as appropriate to the operation. The MATRIX and ARRAY appearing in such operations must agree in dimensions or the operation will be rejected.
•The special operator ** is defined for conventional (matrix x vector) multiplication, in which each element of the result vector is the dot product of the corresponding matrix row with the argument vector.
•The special operator // is defined for (vector / matrix) division. This operation is defined as multiplication of the vector by the inverse of the argument matrix.
Examples:
V2 = M ** V1 
{ V2 is an ARRAY, each element of which is the dot product of the corresponding row of M with the ARRAY V1 } 
V2 = V1 // M 
{ V2 is an ARRAY that satisfies the equation M**V2 = V1 } 
The operator TRANSPOSE may be used to retrieve the transpose of a MATRIX.
The operator SIZEOF may be used to retrieve the allocated size of a MATRIX.
n = SIZEOF(v) { returns 11, the allocates size of the example array "v" above }
Normally, MATRICES 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 MATRIX 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 MATRIX ( ( value_11 , value_12 ... value_1m ) ,
... ( value_n1 , value_n2 ... value_nm) )
See Also: "Using ARRAYS and MATRICES"