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];
Multiply: PROCEDURE [a: MatrixN, b: MatrixN] RETURNS [c: MatrixN];
MultiplyVec: PROC[a: MatrixN, v: ColumnN] RETURNS [c: RowN];
Create: PROC [nrows, ncols: INTEGER] RETURNS [a: MatrixN];
END.