111 lines
3 KiB
Groff
111 lines
3 KiB
Groff
.PR POINT,NOLIST .PR
|
|
.CO THE WICHMAN BENCHMARK .CO
|
|
.BEGIN
|
|
.MODE .ARR = [1 : 4] .REAL;
|
|
.REAL X1,X2,X3,X4,X,Y,Z,T1,T2,T,
|
|
.INT I,J,K,L,N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,
|
|
.ARR E1;
|
|
.PROC PA = (.REF .ARR E) .VOID:
|
|
.BEGIN
|
|
.INT J;
|
|
J := 0;
|
|
.WHILE J < 6 .DO
|
|
E[1] := (E[1] + E[2] + E[3] - E[4]) * T;
|
|
E[2] := (E[1] + E[2] - E[3] + E[4]) * T;
|
|
E[3] := (E[1] - E[2] + E[3] + E[4]) * T;
|
|
E[4] := ( - E[1] + E[2] + E[3] + E[4]) / T2;
|
|
J := J + 1
|
|
.OD
|
|
.END; # OF PA #
|
|
.PROC P0 = .VOID:
|
|
.BEGIN
|
|
E1[J] := E1[K];
|
|
E1[K]:= E1[L];
|
|
E1[L] := E1[J]
|
|
.END; # OF P0#
|
|
.PROC P3 = (.REAL X,Y, .REF .REAL Z) .VOID :
|
|
.BEGIN
|
|
.REAL X1 := X, Y1 := Y;
|
|
X1 := T*(X1+Y1);
|
|
Y1 := T*(X1+Y1);
|
|
Z := (X1+Y1) / T2
|
|
.END; # OF P3#
|
|
T := 0.499975; T1 := 0.50025; T2 := 2.0;
|
|
.CO READ(I); .CO I := 2;
|
|
N1 := 0; N2 := 12*I; N3 := 14*I; N4 :=345*I;N5 :=0;
|
|
N6 := 210*I;N7 := 32*I; N8 :=899*I;N9 :=616*I;
|
|
N10 := 0; N11 := 93*I;
|
|
# MODULE 1: SIMPLE IDENTIFIERS#
|
|
X1 := 1.0;
|
|
X2 := X3 := X4 := -1.0;
|
|
.FOR I .TO N1 .DO
|
|
X1 := (X1 + X2 + X3 - X4)*T;
|
|
X2 := (X1 + X2 - X3 + X4)*T;
|
|
X3 := (X1 - X2 + X3 + X4)*T;
|
|
X4 := ( - X1 + X2 + X3 + X4)*T
|
|
.OD;
|
|
PRINT ((N1,N1,N1,X1,X2,X3,X4, NEWLINE));
|
|
# MODULE 2: ARRAY ELEMENTS#
|
|
E1[1] := 1.0;
|
|
E1[2] := E1[3] := E1[4] := -1.0;
|
|
.FOR I .TO N2 .DO
|
|
E1[1] := (E1[1] + E1[2] + E1[3] - E1[4])*T;
|
|
E1[2] := (E1[1] + E1[2] - E1[3] + E1[4])*T;
|
|
E1[3] := (E1[1] - E1[2] + E1[3] + E1[4])*T;
|
|
E1[4] := ( - E1[1] + E1[2] + E1[3] + E1[4])*T
|
|
.OD;
|
|
PRINT ((N2,N3,N2)); .FOR I .TO 4 .DO PRINT(E1[I]) .OD; PRINT((NEWLINE));
|
|
#MODULE 3: ARRAY AS PARAMETER#
|
|
.FOR I .TO N3 .DO PA(E1) .OD;
|
|
PRINT ((N3,N2,N2)); .FOR I .TO 4 .DO PRINT(E1[I]) .OD; PRINT((NEWLINE));
|
|
#MODULE 4: CONDITIONAL JUMPS#
|
|
J := 1;
|
|
.FOR I .TO N4 .DO
|
|
.IF J = 1 .THEN J := 2
|
|
.ELSE J := 3 .FI;
|
|
.IF J > 2 .THEN J := 0
|
|
.ELSE J := 1 .FI;
|
|
.IF J < 1 .THEN J := 1
|
|
.ELSE J := 0 .FI
|
|
.OD;
|
|
PRINT ((N4,J,J,X1,X2,X3,X4, NEWLINE));
|
|
# MODULE 5: OMITTED#
|
|
# MODULE 6: INTEGER ARITHMETIC#
|
|
J := 1; K := 2; L := 3;
|
|
.FOR I .TO N6 .DO
|
|
J := J*(K-J)*(L-K);
|
|
K := L*K - (L-J)*K;
|
|
L := (L-K)*(K+J);
|
|
E1[L-1] := J+K+L;
|
|
E1[K-1] := J*K*L
|
|
.OD;
|
|
PRINT ((N6,J,K)); .FOR I .TO 4 .DO PRINT(E1[I]) .OD; PRINT((NEWLINE));
|
|
#MODULE 7: TRIG FUNCTIONS#
|
|
X := Y := 0.5;
|
|
.FOR I .TO N7 .DO
|
|
X := T*ARCTAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0));
|
|
Y := T*ARCTAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0))
|
|
.OD;
|
|
PRINT ((N7,J,K,X,X,Y,Y, NEWLINE));
|
|
#MODULE 8: PROCEDURE CALLS#
|
|
X := Y := Z := 1.0;
|
|
.FOR I .TO N8 .DO P3(X,Y,Z) .OD;
|
|
PRINT ((N8,J,K,X,Y,Z,Z, NEWLINE)); #MODULE 9: ARRAY REFERENCES#
|
|
J :=1; K :=2; L :=3;
|
|
E1[1]:=1.0;E1[2] :=2.0;E1[3] :=3.0;
|
|
.FOR I .TO N9 .DO P0 .OD;
|
|
PRINT ((N9,J,K)); .FOR I .TO 4 .DO PRINT(E1[I]) .OD; PRINT((NEWLINE));
|
|
#MODULE 10: INTEGER ARITHMETIC#
|
|
J :=2;K :=3;
|
|
.FOR I .TO N10 .DO
|
|
J := J+K;K :=J+K;J := K-J;K := K-J-J
|
|
.OD;
|
|
PRINT((N10,J,K,X1,X2,X3,X4, NEWLINE));
|
|
#MODULE 11: STANDARD FUNCTIONS#
|
|
X := 0.75;
|
|
.FOR I .TO N11 .DO
|
|
X := SQRT(EXP(LN(X)/T1))
|
|
.OD;
|
|
PRINT ((N11,J,K,X,X,X,X, NEWLINE))
|
|
.END
|