#include "tools.h"
#include <stdlib.h>
#include <stdio.h>
Go to the source code of this file.
◆ corr()
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
computes (R[k]), (k = 0, 1,\dotsc, M) (x,y) are (N)-dimensional (R) is ((M+1))-dimensional
Definition at line 5 of file corr.c.
12 for (R[k]=0, n=0; n<N-k; n++)
13 R[k] +=
x[n+k] * y[n] / N;
References x.
Referenced by main().
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 19 of file corr.c.
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;
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
References corr(), init_args(), init_data_float(), malloc(), out, and printf().