-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrosscorr.f
executable file
·52 lines (37 loc) · 1.24 KB
/
Crosscorr.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
subroutine crosscorr (ishift,rxy,xcross,ycross,npx)
c******************************************************************************
c This routine determines the correlation of array 'x' and array 'y',
c comparing array elements 'i' in 'x' with elements 'i+ishift';
c the number of points in each array is assumed to be equal.
c******************************************************************************
implicit real*8 (a-h,o-z)
real*4 xcross(100000),ycross(100000)
real*8 xsum,ysum,xysum,x2sum,y2sum,covar,varx,vary
real*8 xx,yy
xsum = 0.
ysum = 0.
xysum = 0.
x2sum = 0.
y2sum = 0.
if (ishift .ge. 0) then
minpt = 1
maxpt = npx - ishift
else
minpt = iabs(ishift) + 1
maxpt = npx
endif
do 10 i=minpt,maxpt
xx = xcross(i)
yy = ycross(i+ishift)
xsum = xsum + xx
ysum = ysum + yy
xysum = xysum + xx*yy
x2sum = x2sum + xx*xx
10 y2sum = y2sum + yy*yy
xn = real(maxpt - minpt + 1)
covar = xn*xysum - xsum*ysum
varx = dsqrt(xn*x2sum - xsum*xsum)
vary = dsqrt(xn*y2sum - ysum*ysum)
rxy = sngl(covar/(varx*vary))
return
end