home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
PASCAL
/
NRPAS13.ZIP
/
CORREL.DEM
< prev
next >
Wrap
Text File
|
1991-04-29
|
962b
|
45 lines
PROGRAM d12r7(input,output);
(* driver for routine CORREL *)
CONST
n=64;
n2=128; (* n2=2*nn *)
pi=3.1415927;
TYPE
glnarray = ARRAY [1..n] OF real;
gl2narray = ARRAY [1..n2] OF real;
gldarray = gl2narray;
VAR
i,j : integer;
cmp : real;
data1,data2 : glnarray;
ans : gl2narray;
(*$I MODFILE.PAS *)
(*$I FOUR1.PAS *)
(*$I TWOFFT.PAS *)
(*$I REALFT.PAS *)
(*$I CORREL.PAS *)
BEGIN
FOR i := 1 to n DO BEGIN
data1[i] := 0.0;
IF ((i > ((n DIV 2)-(n DIV 8))) AND
(i < ((n DIV 2)+(n DIV 8)))) THEN
data1[i] := 1.0;
data2[i] := data1[i]
END;
correl(data1,data2,n,ans);
(* calculate directly *)
writeln ('n':3,'CORREL':14,'direct calc.':18);
FOR i := 0 to 16 DO BEGIN
cmp := 0.0;
FOR j := 1 to n DO BEGIN
cmp := cmp+data1[((i+j-1) MOD n)+1]*data2[j]
END;
writeln (i:3,ans[i+1]:15:6,cmp:15:6)
END
END.