00001
00002 c
00003 c Copyright (c) 1986,1987,1988,1989,1990,1991,1992,1993,
00004 c by Steve McMillan, Drexel University, Philadelphia, PA.
00005 c
00006 c All rights reserved.
00007 c
00008 c Redistribution and use in source and binary forms are permitted
00009 c provided that the above copyright notice and this paragraph are
00010 c duplicated in all such forms and that any documentation,
00011 c advertising materials, and other materials related to such
00012 c distribution and use acknowledge that the software was developed
00013 c by the author named above.
00014 c
00015 c THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
00016 c IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
00017 c WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00018 c
00019
00020 subroutine autocorrel(a,n,w)
00021 c
00022 c Replace a by its autocorrelation function.
00023 c
00024 real a(n),w(0:n)
00025 c
00026 if (n.le.1) return
00027 c
00028 c First take out the mean signal.
00029 c
00030 aver = 0.
00031 do i=1,n
00032 aver = aver + a(i)
00033 end do
00034 c
00035 aver = aver/n
00036 do i = 1,n
00037 a(i) = a(i) - aver
00038 end do
00039 c
00040 n2 = n/2
00041 c
00042 do i=0,n2
00043 w(i) = 0.
00044 do j=1,n-i
00045 w(i) = w(i) + a(j)*a(j+i)
00046 end do
00047 w(i) = w(i) / (n-i)
00048 end do
00049 c
00050 c Normalize by the i=0 term.
00051 c
00052 do i=1,n2
00053 a(i) = w(i)/w(0)
00054 end do
00055 c
00056 n = n2
00057 c
00058 end
00059