LinearSystemJaM.mesa
Written by Michael Plass, 8-Oct-81
Last edit by Michael Plass, December 2, 1982 11:05 am
DIRECTORY
LinearSystem,
Real USING [RealException],
JaMFnsDefs USING [PushReal, GetReal, PushString, Register];
LinearSystemJaM: PROGRAM IMPORTS LinearSystem, Real, JaMFnsDefs =
BEGIN OPEN JaMFnsDefs;
Solve2: PROCEDURE =
BEGIN
singular:BOOLEANFALSE;
A: LinearSystem.Matrix2; b,x:LinearSystem.Column2;
FOR i:NAT DECREASING IN [1..2] DO b[i] ← GetReal[] ENDLOOP;
FOR i:NAT DECREASING IN [1..2] DO
FOR j:NAT DECREASING IN [1..2] DO
A[i][j] ← GetReal[];
ENDLOOP
ENDLOOP;
x ← LinearSystem.Solve2[A,b!
Real.RealException => CHECKED {singular←TRUE; CONTINUE}];
IF NOT singular THEN
FOR i:NAT IN [1..2] DO PushReal[x[i]] ENDLOOP
ELSE PushString["Singular!"L];
END;
Solve3: PROCEDURE =
BEGIN
singular:BOOLEANFALSE;
A: LinearSystem.Matrix3; b,x:LinearSystem.Column3;
FOR i:NAT DECREASING IN [1..3] DO b[i] ← GetReal[] ENDLOOP;
FOR i:NAT DECREASING IN [1..3] DO
FOR j:NAT DECREASING IN [1..3] DO
A[i][j] ← GetReal[];
ENDLOOP
ENDLOOP;
x ← LinearSystem.Solve3[A,b!
Real.RealException => CHECKED {singular←TRUE; CONTINUE}];
IF NOT singular THEN
FOR i:NAT IN [1..3] DO PushReal[x[i]] ENDLOOP
ELSE PushString["Singular!"L];
END;
Solve4: PROCEDURE =
BEGIN
singular:BOOLEANFALSE;
A: LinearSystem.Matrix4; b,x:LinearSystem.Column4;
FOR i:NAT DECREASING IN [1..4] DO b[i] ← GetReal[] ENDLOOP;
FOR i:NAT DECREASING IN [1..4] DO
FOR j:NAT DECREASING IN [1..4] DO
A[i][j] ← GetReal[];
ENDLOOP
ENDLOOP;
x ← LinearSystem.Solve4[A,b!
Real.RealException => CHECKED {singular←TRUE; CONTINUE}];
IF NOT singular THEN
FOR i:NAT IN [1..4] DO PushReal[x[i]] ENDLOOP
ELSE PushString["Singular!"L];
END;
Solve5: PROCEDURE =
BEGIN
singular:BOOLEANFALSE;
A: LinearSystem.Matrix5; b,x:LinearSystem.Column5;
FOR i:NAT DECREASING IN [1..5] DO b[i] ← GetReal[] ENDLOOP;
FOR i:NAT DECREASING IN [1..5] DO
FOR j:NAT DECREASING IN [1..5] DO
A[i][j] ← GetReal[];
ENDLOOP
ENDLOOP;
x ← LinearSystem.Solve5[A,b!
Real.RealException => CHECKED {singular←TRUE; CONTINUE}];
IF NOT singular THEN
FOR i:NAT IN [1..5] DO PushReal[x[i]] ENDLOOP
ELSE PushString["Singular!"L];
END;
Solve6: PROCEDURE =
BEGIN
singular:BOOLEANFALSE;
A: LinearSystem.Matrix6; b,x:LinearSystem.Column6;
FOR i:NAT DECREASING IN [1..6] DO b[i] ← GetReal[] ENDLOOP;
FOR i:NAT DECREASING IN [1..6] DO
FOR j:NAT DECREASING IN [1..6] DO
A[i][j] ← GetReal[];
ENDLOOP
ENDLOOP;
x ← LinearSystem.Solve6[A,b!
Real.RealException => CHECKED {singular←TRUE; CONTINUE}];
IF NOT singular THEN
FOR i:NAT IN [1..6] DO PushReal[x[i]] ENDLOOP
ELSE PushString["Singular!"L];
END;
Register["LinearSystem.Solve2"L,Solve2];
Register["LinearSystem.Solve3"L,Solve3];
Register["LinearSystem.Solve4"L,Solve4];
Register["LinearSystem.Solve5"L,Solve5];
Register["LinearSystem.Solve6"L,Solve6];
END.