LinearSystem.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Last edited by Maureen Stone 19-Oct-81 16:42:28
Written by Michael Plass, 8-Oct-81
Tim Diebert May 21, 1985 5:50:50 pm PDT
Stone, October 16, 1985 10:35:34 am PDT
Maureen Stone, March 24, 1987 10:58:50 am PST
Real0: TYPE = REAL ¬ 0;
Catch the signal Real.RealException to detect singular or unstable systems, e.g.,
singular:BOOLEAN ← FALSE;
x ← LinearSystem.Solve3[A,b!
Real.RealException => {singular←TRUE;CONTINUE}];
IF NOT singular THEN ...
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;
SolveN destroys A. Use SolveN[Copy[A],b,n] if this is a problem;
SolveN: PROCEDURE [A:MatrixN, b:ColumnN, n: INTEGER] RETURNS [x:ColumnN] ; -- solves Ax=b
Invert and Determinant are very simple-minded. Not recommended for large matrices.
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];
Copy: PROC [a: MatrixN] RETURNS[MatrixN];
Matrix2: TYPE = ARRAY [0..2) OF Row2;
Row2: TYPE = ARRAY [0..2) OF REAL;
Column2: TYPE = ARRAY [0..2) OF Real0;
Solve2: PROCEDURE [A:Matrix2, b:Column2] RETURNS [x:Column2] ; -- solves Ax=b
Matrix3: TYPE = ARRAY [0..3) OF Row3;
Row3: TYPE = ARRAY [0..3) OF REAL;
Column3: TYPE = ARRAY [0..3) OF Real0;
Solve3: PROCEDURE [A:Matrix3, b:Column3] RETURNS [x:Column3] ; -- solves Ax=b
Matrix4: TYPE = ARRAY [0..4) OF Row4;
Row4: TYPE = ARRAY [0..4) OF REAL;
Column4: TYPE = ARRAY [0..4) OF Real0;
Solve4: PROCEDURE [A:Matrix4, b:Column4] RETURNS [x:Column4] ; -- solves Ax=b
Matrix5: TYPE = ARRAY [0..5) OF Row5;
Row5: TYPE = ARRAY [0..5) OF REAL;
Column5: TYPE = ARRAY [0..5) OF Real0;
Solve5: PROCEDURE [A:Matrix5, b:Column5] RETURNS [x:Column5] ; -- solves Ax=b
Matrix6: TYPE = ARRAY [0..6) OF Row6;
Row6: TYPE = ARRAY [0..6) OF REAL;
Column6: TYPE = ARRAY [0..6) OF Real0;
Solve6: PROCEDURE [A:Matrix6, b:Column6] RETURNS [x:Column6] ; -- solves Ax=b
END.