10 Matrix Operations
MAT result array = operand array
The two arrays must have the same number of dimensions. The number of elements in the result array must be greater than or equal to the number of elements in the operand array. For example:
10 INTEGER C(4,4),D(3,3),E(4,2) 20 MAT D=(2.5) 30 MAT C=DEach element of array D is set to 2.5, then the values of array D are copied into the elements of array C, then the working size of array C is redimensioned to be a 3 by 3 array.
40 MAT E=CIf the above statement was included, an error would occur because the array E has only 2 elements in the second dimension while the operand array, C, has 3 elements.
Example for string array:
50 DIM A$(5),B$(5) .... 100 MAT A$=B$
MAT result array = operand array operator (scalar)
MAT result array = (scalar) operand array operator
For example, the following program line multiplies each element in array C by 4 and stores the result in the corresponding elements of array B:
30 MAT B=C*(4)To further explain, take the following program line:
150 MAT B=C>(100)If any elements of array C have a value greater than 100, a value of 1 is entered in the corresponding elements of array B. A 0 is entered if the value of the element in array C is less than or equal to 100.
The following operators are allowed:
+, -, *, / =, < > or #, >, <, >=, <=The two arrays must have the same number of dimensions. The number of elements in the result array must be greater than or equal to the number of dimensions in the operand array. The result array is redimensioned to the working size of the operand array after the operation.
MAT result array = operand array1 operator operand array2
For example, the following program line multiplies corresponding elements of arrays Hours and Rate and stores them in array Pay:
200 MAT Pay=Hours.RateNote that a period (.) is used for multiplication, not an asterisk ($\ast$).
To further explain, take the following example:
30 MAT A=B>CIf the value in the element of array B is greater than the corresponding element of array C, a value of 1 is stored in array A.
The following operators are allowed:
+, -, / =, < > or #, >, <, >=, <=The result and operand arrays must have the same number of dimensions. The operand arrays must have the same number of elements in each dimension; the result array cannot have less.