PROGRAM d11r7(input,output);
(* driver for routine HQR *)
CONST
   np=5;
TYPE
   glnpnp = ARRAY [1..np,1..np] OF real;
   glnp = ARRAY [1..np] OF real;
VAR
   i,j : integer;
   a : glnpnp;
   wi,wr : glnp;

(*$I MODFILE.PAS *)
(*$I BALANC.PAS *)

(*$I ELMHES.PAS *)

(*$I HQR.PAS *)

BEGIN
   a[1,1] := 1.0; a[1,2] := 2.0; a[1,3] := 0.0;
   a[1,4] := 0.0; a[1,5] := 0.0;
   a[2,1] := -2.0; a[2,2] := 3.0; a[2,3] := 0.0;
   a[2,4] := 0.0; a[2,5] := 0.0;
   a[3,1] := 3.0; a[3,2] := 4.0; a[3,3] := 50.0;
   a[3,4] := 0.0; a[3,5] := 0.0;
   a[4,1] := -4.0; a[4,2] := 5.0; a[4,3] := -60.0;
   a[4,4] := 7.0; a[4,5] := 0.0;
   a[5,1] := -5.0; a[5,2] := 6.0; a[5,3] := -70.0;
   a[5,4] := 8.0; a[5,5] := -9.0;
   writeln('matrix:');
   FOR i := 1 to np DO BEGIN
      FOR j := 1 to np DO write(a[i,j]:12:2);
      writeln
   END;
   balanc(a,np);
   elmhes(a,np);
   hqr(a,np,wr,wi);
   writeln('eigenvalues:');
   writeln('real':11,'imag.':16);
   FOR i := 1 to np DO BEGIN
      writeln('  ',wr[i]:13,'  ',wi[i]:13)
   END
END.
PROGRAM d3r6 (input,output);
(* driver for routine HUNT *)
CONST
   n=100;
TYPE
   glnarray = ARRAY [1..n] OF real;
VAR
   i,j,ji : integer;
   x : real;
   xx : glnarray;

(*$I MODFILE.PAS *)
(*$I HUNT.PAS *)

BEGIN
(* create array to be searched *)
   FOR i := 1 to n DO begin
      xx[i] := exp(i/20.0)-74.0
   END;
   writeln ('  result of:',' ':3,'j := 0 indicates x too small');
   writeln (' ':15,'j := 100 indicates x too large');
   writeln ('locate:':12,'guess':8,'j':4,'xx(j)':11,'xx(j+1)':13);
(* do test *)
   FOR i := 1 to 19 DO begin
      x := -100.0+200.0*i/20.0;
(* trial parameter *)
      ji := 5*i;
      j := ji;
(* begin search *)
      hunt(xx,n,x,j);
      IF ((j<n) AND (j>0)) THEN BEGIN
         writeln (x:12:5,ji:6,j:6,xx[j]:12:6,xx[j+1]:12:6)
      END ELSE IF (j=n) THEN BEGIN
         writeln (x:12:5,ji:6,j:6,xx[j]:12:6,'   upper lim')
      END ELSE BEGIN
         writeln (x:12:5,ji:6,j:6,'   lower lim',xx[j+1]:12:6)
      END
   END
END.
