﻿ MAT

# MAT

The MAT statement assigns a value to all elements of a matrix, copies one matrix to another, or tests for equivalent matrices.

Format

MAT matrix = expr

MAT matrix2 = MAT matrix1

IF MAT matrix1 = MAT matrix2 THEN ...

where

 matrix is the name of a previously dimensioned matrix.

 expr evaluates to the value to be stored in each matrix element.

The first format of this statement copies the value of expr into all elements of matrix. The zero element is set to a null string.

The second format copies elements from matrix1 to matrix2 row by row. If the number of columns differs, the copy behaves as depicted below.

 Source: Target: 1 2 1 2 3 1 A B 1 A B C 2 C D 2 D E F 3 E F

The zero element of src.matrix is copied to the zero element of matrix.

If src.matrix has more elements than matrix, the excess elements are ignored. If src.matrix has fewer elements than matrix, the remaining elements of matrix are unchanged.

A single dimensional matrix can be copied to a two dimensional matrix and vice versa.

The third syntax tests whether the content of matrix1 is the same as the content of matrix2. Although most likely to be used as part of an IF statement as shown above, the

MAT matrix1 = MAT matrix2

component of this statement may be used anywhere that a Boolean value is appropriate.

Examples

DIM A(25)

MAT A = 0

The above program fragment dimensions matrix A to have 25 elements and sets them all to zero.

DIM A(5,5), B(25)

... statements that set values in matrix A...

MAT B = MAT A

This program fragment dimensions two matrices, sets values into matrix A and then creates a single dimensional copy of A in matrix B.