5 void corr(
int N,
float x[N],
float y[N],
int M,
float R[M])
12 for (R[k]=0, n=0; n<N-k; n++)
13 R[k] +=
x[n+k] * y[n] / N;
19 int main(
int argc,
char **argv) {
20 int n = atoi(argv[1]);
23 float (*in)[n] = (float (*)[n])
malloc(
sizeof(
float)*(1+n));
24 float (*in2)[n] = (float (*)[n])
malloc(
sizeof(
float)*(1+n));
25 float (*
out)[k] = (float (*)[n])
malloc(
sizeof(
float)*(k));
32 gettimeofday(&s,NULL);
34 gettimeofday(&e,NULL);
35 double diff = (double)(e.tv_sec-s.tv_sec)*1000.0 +
36 (double)(e.tv_usec-s.tv_usec)/1000.0;
int main(int argc, char **argv)
void corr(int N, float x[N], float y[N], int M, float R[M])
corr.c - sample cross correlation of two length-N signals