int crosscorrelate (x, y, cvec, dim, avg) STATFUNS.C Level 3
 
float *x, *y The x and y input vectors.
float *cvec The output correlation function.
int dim The dimension of the three arrays.
int avg = 1 the average of the x and y vectors will be subtracted from the respective vectors before the correlation.
= 0 the average will not be subtracted.
 
Calculate the cross-correlation function for two functions. If they are the same, the auto-correlation function will be calculated. 
Assumptions:
Each function is given at equally-spaced ordinates 0,,t,,dim.
The functions are both assumed to be periodic with period dim, i.e.,
 x[0] == x[dim];  y[0] == y[dim];
The cross-correlation function is defined as 
 
<x> = average of x. If avg == 0, the average will not be subtracted from the vector(s). The output vector, cvec
will have dimension k. The correlation coefficient is cvec[0], and ranges from -1.0 to 1.0. A correlation coefficient of 1.0 means that the functions x and y are fully correlated. -1.0 means that they are anticorrelated.

crosscorrelate() returns 1 if one vector was all zeros, or if memory allocation failed. It returns 0 upon succcess.