MAT statements ☆☆
Full BASIC provides MAT statements, which perform matrix operations.
Let A, B and C be arrays, m, n and p be numeric expressions below.
MAT A = B
substitutes B for A, where A and B have the same dimension.
MAT A = ZER
substitutes 0 for all elements of A.
|when A is 1-dimensional|
|when A is 2-dimensional|
|when A is 3-dimensional|
MAT A = CON
MAT A = CON(m)
MAT A = CON(m, n)
MAT A = CON(m, n, p)
If numeric_expression is a constant, a function reference or a variable, parentheses can be omitted.
Example. Let x be a numeric variable.
The value of numeric_expression is assigned to all elements of A.
Let A and B be 2-dimensional arrays.
MAT A = IDN
substitutes the identity matrix for A.
If A is not square, an exception of 6004 shall be raised.
MAT A = IDN(n)
substitutes n×n identity matrix for A.
substitutes the transposed matrix of B for A.
Cross Product (Original Enhancement)
Let A, B and C be 1-dimensional arrays.
Substitutes the outer product of B and C for A.
If the size of B and C are not 3, an exception of extype 6001 shall be raised.
Although a MAT statement may change the size of an array, the lower bounds of an array does not change, and only the upper bounds are adjusted for the new size.
For example, when an array such as A(1)=1，A(2)=2，A(3)=3 is substituted for an array B with the lower bound 0, B becomes as B(0)=1，B(1)=2，B(2)=3.
MAT B=A means
MAT A=ZER(m TO n) does not make the lower bound of A into m.
This statement keeps the lower bound of A and changes only the size of A to n
If you want to change the lower bound of an array, use a MAT READ statement or an original enhancement MAT REDIM.
If a MAT statement yields that the number of elements of an array exceeds the number of elements first declared, an exception of extye 5001 shall be raised.
Addition, subtraction, or multiplication of only two matrices can be performed.
MAT A=B*C*D can be compiled when A, B, C and D are all 2-dimensional, this MAT statement is a transform-assignment and an exception shall be raised unless the size of every matrix is 4× 4. Moreover, even if the size of every matrix is 4×4, the precision of result shall be that of the graphics subsystem (currently binary double precision).