Matrix.mesa
--Written by Maureen Stone July 8, 1983 3:46 pm
--TYPEs identical to Linear System types
Matrix: CEDAR DEFINITIONS = BEGIN
Real0: TYPE = REAL ← 0;
Catch the signal Real.RealException to detect singular or unstable systems, e.g.,
singular: BOOLEAN ← FALSE;
x ← Matrix.Invert[A!
Real.RealException => {singular←TRUE; CONTINUE}];
IF NOT singular THEN ...
InvalidMatrix, InvalidOperation: SIGNAL;
VecSeq: TYPE = RECORD[SEQUENCE ncols: INTEGER OF Real0];
RowN: TYPE = REF VecSeq;
MatrixSeq: TYPE = RECORD[SEQUENCE nrows: INTEGER OF RowN];
MatrixN: TYPE = REF MatrixSeq;
ColumnN: TYPE = REF VecSeq;
Invert: PROCEDURE [a: MatrixN] RETURNS [ai: MatrixN];
Determinant: PROC[a: MatrixN] RETURNS [det: REAL];
Transpose: PROCEDURE [a: MatrixN] RETURNS [transpose: MatrixN];
Multipy: PROCEDURE [a: MatrixN, b: MatrixN] RETURNS [c: MatrixN];
MultipyVec: PROC[a: MatrixN, v: ColumnN] RETURNS [c: RowN];
Create: PROC [nrows, ncols: INTEGER] RETURNS [a: MatrixN];
Matrix2: TYPE = ARRAY [1..2] OF Row2;
Row2: TYPE = ARRAY [1..2] OF REAL;
Column2: TYPE = ARRAY [1..2] OF Real0;
Invert2: PROCEDURE [a: Matrix2] RETURNS [ai: Matrix2];
Matrix3: TYPE = ARRAY [1..3] OF Row3;
Row3: TYPE = ARRAY [1..3] OF REAL;
Column3: TYPE = ARRAY [1..3] OF Real0;
Invert3: PROCEDURE [a: Matrix3] RETURNS [ai: Matrix3];
Matrix4: TYPE = ARRAY [1..4] OF Row4;
Row4: TYPE = ARRAY [1..4] OF REAL;
Column4: TYPE = ARRAY [1..4] OF Real0;
Invert4: PROCEDURE [a: Matrix4] RETURNS [ai: Matrix4];
END.