PIPS
corr.c File Reference
#include "tools.h"
#include <stdlib.h>
#include <stdio.h>
+ Include dependency graph for corr.c:

Go to the source code of this file.

Functions

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 More...
 
int main (int argc, char **argv)
 

Function Documentation

◆ 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.

8 {
9  int k, n;
10 
11  for (k=0; k<M; k++)
12  for (R[k]=0, n=0; n<N-k; n++)
13  R[k] += x[n+k] * y[n] / N;
14 }
static char * x
Definition: split_file.c:159

References x.

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 19 of file corr.c.

19  {
20  int n = atoi(argv[1]);
21  int k = 5;
22  //int k = atoi(argv[3]);
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));
26  init_args(argc, argv);
27  init_data_float(*in,n);
28  init_data_float(*in2,n);
29 
30  if (argc>20) k=10;
31  struct timeval s,e;
32  gettimeofday(&s,NULL);
33  corr(n,*in,*in2,k,*out);
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;
37  printf("%0.6f\n", diff);
38  return 0;
39 }
static FILE * out
Definition: alias_check.c:128
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
Definition: corr.c:5
void * malloc(YYSIZE_T)
int printf()
void init_args(int argc, char **argv)
Definition: tools.c:151
int init_data_float(float *ptr, const unsigned int n)
Definition: tools.c:125

References corr(), init_args(), init_data_float(), malloc(), out, and printf().

+ Here is the call graph for this function: