
%BEGIN
%CONSTINTEGER NMAX=4
%ROUTINESPEC TEST MATRIX(%LONGREALARRAYNAME A, %INTEGER N)
%INTEGER I
%LONGREALARRAY A(1:NMAX,1:NMAX)
%LONGREALARRAY W(1:NMAX)
      TEST MATRIX(A,NMAX)
      PRINTSTRING("
TEST MATRIX EIGENVALUES
")
      %STOP
!%LONG %REAL %FN SQRT(%LONG %REAL ARG)
!!***********************************************************************
!!*    THIS ROUTINE SCALES WITH A LOOP AND HENCE IS VERY SLOW           *
!!*    MUCHFASTER M-C DEPENDENT SCALING IS POSSIBLE                     *
!!***********************************************************************
!%INTEGER I,J,h,n
!%LONG %REAL Y,OLD,NEW,f,ta
!      %IF ARG<0.0 %THEN ARG=-ARG
!      %IF ARG=0 %THEN %RESULT=0.0
!      i=0
!      y=arg
!      y=y/16 %AND i=1+1 %WHILE y>1.0
!      y=y*16.0 %AND i=i-1 %WHILE y<1/16
!      %IF Y>0.34375 %THEN OLD=Y/2+0.4368 %ELSE OLD=Y/2+0.381
!      %CYCLE J=0,1,14
!         NEW=(OLD+Y/OLD)/2
!         %IF MOD(NEW-OLD)<0.000000000000005 %THEN %EXIT
!         OLD=NEW
!      %REPEAT
!      %IF I>0 %THEN NEW=NEW*4.0**i
!      %IF i<0 %THEN new=new/(4.0**imod(i))
!      %RESULT=NEW
!%END
%ROUTINE TEST MATRIX(%LONGREALARRAYNAME A, %INTEGER N)
%INTEGER I,J
%LONGREAL T,C,D,F
      C=N*(N+1)*(2*N-5)/6
      D=1/C
      A(N,N)=-D
      %CYCLE I=1,1,N-1
         F=I
         A(I,N)=D*F
         A(N,I)=A(I,N)
         A(I,I)=D*(C-F**2)
         %CYCLE J=1,1,I-1
            T=J
            A(I,J)=-D*F*T
            A(J,I)=A(I,J)
         %REPEAT
      %REPEAT
      %CYCLE I=1,1,N
         %CYCLE J=1,1,N
            PRINTFL(A(I,J),4)
         %REPEAT
         NEWLINE
      %REPEAT
%END
%ENDOFPROGRAM
