next up previous contents
Next: Function: avg_inv_spec() Up: GRASP Routines: Gravitational Radiation Previous: Comparison of signal detectability   Contents


Function: correlate()

0 void correlate(float *s,float *h,float *c,float *r,int n)
This function evaluates the correlation (as a function of lag time $t$) defined by the discrete equivalent of equation ([*]):
\begin{displaymath}
s(t) = {1 \over 2} \int_{-\infty}^\infty df \; { \tilde h(f) \tilde c^* (f) \tilde r (f) }
\; {\rm e}^{- 2 \pi i f t}.
\end{displaymath} (6.16.95)

It is assumed that $\tilde h(f)$ and $\tilde c(f)$ are Fourier transforms of real functions, and that $\tilde r(f)$ is real. The factor of $1/2$ appears in ([*]) for efficiency reasons; in order to calculate the integral ([*]) one should set $\tilde r(f) = 2/S_h(f)$. The routine assumes that $\tilde r$ vanishes at both DC and the Nyquist frequency.

The arguments are:

s: Output. Upon return, the array s[0..n-1] contains the correlation $s(t)$ at times
\begin{displaymath}
\nonumber
t=0,\Delta t, 2 \Delta t,\cdots,(n-1) \Delta t.
\end{displaymath}  

h: Input. The array h[0..n-1] contains the positive frequency ($f \ge 0$) part of the complex function $\tilde h(f)$. The packing of $\tilde h$ into this array follows the scheme used by the Numerical Recipes routine realft(), which is described between equations (12.3.5) and (12.3.6) of [1]. The DC component $\tilde h(0)$ is real, and located in h[0]. The Nyquist-frequency component $\tilde h(f_{\rm Nyquist})$ is also real, and is located in h[1]. The array elements h[2] and h[3] contain the real and imaginary parts, respectively, of $\tilde h(\Delta f)$ where $\Delta f = 2 f_{\rm Nyquist}/n = (n
\Delta t)^{-1}$. Array elements h[2j] and h[2j+1] contain the real and imaginary parts of $\tilde h( j \; \Delta f)$ for $j=1,\cdots,n/2-1$. It is assumed that $\tilde h(f)$ is the Fourier transform of a real function, so that correlate() can infer the negative frequency components from the equation $\tilde
h(-f) = \tilde h^*(f)$
c: Input. The array c[0..n-1] contains the complex function $\tilde c$, packed in the same format as $\tilde h(f)$, with the same assumption that $\tilde c(-f) = \tilde c^*(f)$. Note that while you provide the function $\tilde c(f)$ to the routine, it is the complex-conjugate of the function contained in the array c[ ] which is used in calculating the correlation. Thus if $\tilde r$ is positive, correlate(s,c,c,r,n) will always return ${\tt s[0]}\ge 0$.
r: Input. The array r[0..n/2] contains the values of the real function $\tilde r$ used as a weight in the integral. This is often chosen to be (twice!) the inverse of the receiver noise, as in equation ([*]), so that $\tilde r(f) = 2/\tilde
S_h(\vert f\vert)$. The array elements are arranged in order of increasing frequency, from the DC value at subscript 0, to the Nyquist frequency at subscript n/2. Thus, the $j$'th array element r[j] contains the real value $\tilde r(j \; \Delta f)$, for $j=0,1,\cdots,n/2$. Again it is assumed that $\tilde r(-f) = \tilde r^*(f) = \tilde r(f)$.
n: Input. The total length of the complex arrays h and c, and the number of points in the output array s. Note that the array r contains $n/2+1$ points. n must be even.
The correlation function calculated by this routine is ${1 \over 2} FFT^{-1}[\tilde
h \tilde c^* \tilde r]$ and has the same dimensions as the product $\tilde h \times \tilde c \times \tilde r$. The definition is
\begin{displaymath}
{\tt s}_k = {1 \over 2} \sum_{j=0}^{{\tt n}-1} {\tt h}_j {\tt c}^*_j {\tt r}_j
{\rm e}^{- 2 \pi i j k/{\tt n}}
\end{displaymath} (6.16.96)

where it is understood that ${\tilde h}_{{\tt n}-j} = \tilde h^*_j$ and that ${\tilde c}_{{\tt n}-j} = \tilde c^*_j$, and that ${\tilde r}_{{\tt n}-j} = \tilde r_j$.

Note that the input arrays h[ ] and c[ ] can be the same array. For example correlate(s,c,c,r,n) calculates the discrete equivalent of

\begin{displaymath}
s(t) = {1 \over 2} \int_{-\infty}^\infty df \; { \vert\tilde c (f) \vert^2 \tilde r (f) }
\; {\rm e}^{- 2 \pi i f t}.
\end{displaymath} (6.16.97)

Author: Bruce Allen, ballen@dirac.phys.uwm.edu
Comments: For the sake of efficiency, this function does not include the contribution from either DC or Nyquist frequency bins to the correlation (these are negligible in any sensible data).


next up previous contents
Next: Function: avg_inv_spec() Up: GRASP Routines: Gravitational Radiation Previous: Comparison of signal detectability   Contents
Bruce Allen 2000-11-19