
10 Matrix Operations
MAT INPUT array1 [(redim subscripts)] [,array2] [(redim subscripts)]
When MAT INPUT is executed, a question mark (?) appears in the display line. Values in the form of numeric expressions can be assigned individually or in groups (separate each value with a comma). Values are stored by pressing RETURN. The ? is redisplayed after RETURN is pressed until all values are input.
Pressing RETURN without entering a value causes execution to continue with the next element in the array. Elements not assigned values retain their previous value. For example:
10 OPTION BASE 1 20 INTEGER A(2,2) 30 MAT INPUT AResponding to the MAT INPUT statement by typing 2, typing 4, pressing RETURN, and typing 8, assigns the following values:
A(1,1)=2 A(1,2)=4 A(2,1)=0 Note that the initial value, 0, is kept A(2,2)=8The following statements are equivalent:
MAT INPUT A INPUT A(*)The MAT INPUT statement is programmable only; it cannot be executed from the keyboard.
MAT array = CON [(redim subscripts)]
Since 1 has a logical value of "true", the constant matrix is useful for logical initialization.
The following two sequences are equivalent:
10 DINTEGER A(10,10) 10 OPTION BASE 1
20 MAT A=CON 20 DINTEGER A(10,10)
30 FOR I=1 TO 10
40 FOR J=1 TO 10
50 A(I,J)=1
60 NEXT I
70 NEXT J
MAT array = ZER [(redim subscripts)]
Since 0 has a logical value of "false", the zero matrix is useful for logic initialization.
The following two sequences are equivalent:
10 REAL A(12,12,12) 10 REAL A(12,12,12)
20 MAT A=ZER 20 FOR I=1 TO 12
30 FOR J=1 TO 12
40 FOR K=1 TO 12
50 A(I,J,K)=0
60 NEXT K
70 NEXT J
80 NEXT I
MAT array = (numeric expression or string expression)
The numeric expression is evaluated once; it is converted to the numeric type of the array, if necessary. For example:
150 INTEGER X(4,4) 150 DIM A$(4)
160 MAT X=(PI) 160 MAT A$=("TEST")
170 MAT PRINT X; 170 MAT PRINT A$;
3 3 3 3 TEST
3 3 3 3 TEST
3 3 3 3 TEST
3 3 3 3 TEST