MAT INDEX

MAT _ _ _ _ _ _ _ _ _ _ _ _ operator

The mat operator is used to represent a two-dimensional matrix.

syntax:

mat((<expr>{,<expr>}*) {(<expr>{,<expr >}*)}*)

<expr> may be any valid REDUCE scalar expression.

examples:


mat((1,2),(3,4)); 

  MAT(1,1) := 1
  MAT(2,3) := 2
  MAT(2,1) := 3
  MAT(2,2) := 4


mat(2,1); 

  ***** Matrix mismatch
  Cont? (Y or N) 


matrix qt; 

qt := ws; 

  QT(1,1) := 1
  QT(1,2) := 2
  QT(2,1) := 3
  QT(2,2) := 4 


matrix a,b; 

a := mat((x),(y),(z)); 

  A(1,1) := X
  A(2,1) := Y
  A(3,1) := Z 


b := mat((sin x,cos x,1)); 

  B(1,1) := SIN(X)
  B(1,2) := COS(X)
  B(1,3) := 1

Matrices need not have a size declared (unlike arrays). mat redimensions a matrix variable as needed. It is necessary, of course, that all rows be the same length. An anonymous matrix, as shown in the first example, must be named before it can be referenced (note error message). When using mat to fill a 1 x n matrix, the row of values must be inside a second set of parentheses, to eliminate ambiguity.