Algorithm Alley

by Gary D. Knott





Listing One

FUNCTION F(T)=IF T<=6 THEN SIN(T)+2*COS(3*T)*EXP(-T) ELSE = J-J*EXP(-2*(T-6));

J = -.27614; MINA = .05; MAXA = .41; MAXD = .28; MIND = .05;

T0 = 0; T1 = 11; D = MIND; A = MINA; G = 1.6; C = 1.5;

TYPE "SET T0,T1,A,D, ETC. AS DESIRED."; DO CONSOLE;



FUNCTION ADM(I)= IF T+A<=T1 THEN (B:=((PV:=P(ME[I]:=OLDP(ADM)))<=F(MT[I+1]:=

(T:=T+A))))+0*(A:=NEWA(X1:=X2,X2:=B))+0*(D:=NEWD()) ELSE 1000-I;



FUNCTION OLDP(B)=PV+D*(2*B-1);

FUNCTION P(H1)=H1;



FUNCTION NEWA(X1,X2)=IF X1=X2 THEN MINA ELSE MIN(G*A,MAXA);

FUNCTION NEWD()=IF X1=X2 THEN MIN(D*C,MAXD) ELSE MAX(D/C,MIND);



X2 = 1; ADM =.5; T = T0; IF T1 <= T0 THEN TYPE ("null interval"); = PV = F(T0);

"PRE-ALLOCATE THE ARRAYS MT, ME.";

MT = 0^^360; ME[360] = 0; MT[1] = T0;MB = ADM ON 1:360;



N = MAXI(MB); IF N >=360 THEN TYPE "TOO MANY POINTS.";



ME(N) = OLDP(B); ME = ME ROW 1:N; MT = MT ROW 1:N; MB = MB ROW = 1:(N-1);

SME = MESH(MT,MT)&'ROTATE(MESH(ME,ME),1); DELETE SME ROW (1,N+N);



ME = MT&'ME; MF = POINTS(F,MT);

"MB IS THE DELTA-MODULATION BIT-VECTOR, MF IS THE SAMPLED SIGNAL POINTS, ME IS

THE ESTIMATED SIGNAL POINTS, AND SME IS THE STEP-FUNCTION ESTIMATE.";







Example 2:



(a)



ADMencode(s0, s1, d, a, f):

begin  real x1,x2,t,h,b;

real procedure P: [h <-=C8h+(2b-1)d; return(h)];

b,x2=C8.5; t=C8s0; h=C8f(s0);

send (t0, h,d, a) to ADMdecode; "This send starts the decoder."

while t <=3D  s1 do=20

      [t=C8t+a; x1=C8x2; if f(t) > P then b=C81 else b=C80;

       x2=C8b; output(b);

       if x1=3Dx2 then (a=C8amin; d=C8min(cd,dmax))

       else (d=C8max(d/c,dmin); a=C8min(ga,amax))

     ];

output(end-message); "This will stop the decoder."

end.



(b)



ADMdecode(t, h, d, a):

begin  real x1,x2,h,b;

real procedure P: [h=C8h+(2b-1)d; return(h)];

b,x2=C8.5;

repeat=20

     [output (t,P);

      "Initially, the output point (t,P) is the point (s0,(s0));

        then subsequent points on the -curve are output."

       receive a bit in b, on end-message, goto exit;

       x1=C8x2; x2=C8b; t=C8t+a;

       if x1=3Dx2 then (a=C8amin; d=C8min(cd,dmax))

       else (d=C8max(d/c,dmin); a=C8min(ga,amax))

      ];

exit: end.







