Subversion Repositories svnkaklik

Rev

Rev 523 | Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
522 kaklik 1
#include <stdio.h>
2
#include <stdlib.h>
3
 
4
int x[500];
5
int y[50];
6
 
7
int main (void)
8
{
9
  fprintf(stdout,"inicializace bufferu s chirpem");
10
 
11
   int i,j
12
   double mx,my,sx,sy,sxy,denom,r;
13
 
14
   /* Calculate the mean of the two series x[], y[] */
15
   mx = 0;
16
   my = 0;   
17
   for (i=0;i<n;i++) {
18
      mx += x[i];
19
      my += y[i];
20
   }
21
   mx /= n;
22
   my /= n;
23
 
24
   /* Calculate the denominator */
25
   sx = 0;
26
   sy = 0;
27
   for (i=0;i<n;i++) {
28
      sx += (x[i] - mx) * (x[i] - mx);
29
      sy += (y[i] - my) * (y[i] - my);
30
   }
31
   denom = sqrt(sx*sy);
32
 
33
   /* Calculate the correlation series */
34
   for (delay=-maxdelay;delay<maxdelay;delay++) {
35
      sxy = 0;
36
      for (i=0;i<n;i++) {
37
         j = i + delay;
38
         if (j < 0 || j >= n)
39
            continue;
40
         else
41
            sxy += (x[i] - mx) * (y[j] - my);
42
         /* Or should it be (?)
43
         if (j < 0 || j >= n)
44
            sxy += (x[i] - mx) * (-my);
45
         else
46
            sxy += (x[i] - mx) * (y[j] - my);
47
         */
48
      }
49
      r = sxy / denom;
50
 
51
      /* r is the correlation coefficient at "delay" */
52
 
53
   }
54
 
55
  exit(1);
56
}