MAT

Top  Previous  Next

 

The MAT statement assigns a value to all elements of a matrix or copies one matrix to another.

 

 

Format

 

MAT matrix = expr

MAT matrix = MAT src.matrix

 

where

 

matrixis the name of a previously dimensioned matrix to which values are to be assigned

 

exprevaluates to the value to be stored in each matrix element.

 

src.matrixis the name of a previously dimensioned matrix which is to be copied to matrix.

 

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 src.matrix to matrix 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.

 

 

Examples

 

DIM A(25)

MAT A = 0

 

This 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.