Procedure CORREL(DATA1,DATA2:array of real;N:integer;var ANS:array of real);
var
FFT:array[0..128] of real;
NO2,I:integer; DUM,DUM1,DUM2:real;
begin
TWOFFT(DATA1, DATA2, FFT, ANS, N);
NO2:=N div 2;
For I:=1 To NO2 + 1 do
begin
DUM:=ANS[2 * I - 1];
DUM1:=FFT[2 * I - 1] * DUM + FFT[2 * I] * ANS[2 * I];
ANS[2 * I - 1]:=DUM1 / NO2;
DUM2:=FFT[2 * I] * DUM - FFT[2 * I - 1] * ANS[2 * I];
ANS[2 * I]:=DUM2 / NO2;
end;
ANS[2]:=ANS[N + 1];
REALFT(ANS, NO2, -1);
end;