1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
   |  
 
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
 
int puiss (int x, int y) {
  int resultat;
  for (resultat = 1; y > 0; y--) resultat*=x;
  return resultat;
}
 
//the correlation property
void correlation(char *Bin)
{
	int T,C,i,n,s;// T stands for Time shift Tau=0,1,... 
	char a1,a2;
	//and C is the auto correlation function
	//n=number of elements of the sequence or period
	n=strlen(Bin);
	C=0;
 
	for(T=0;T<n;T++)
	{
		for(i=0;i<n;i++)
		{
			a1=Bin[i];
			a2=Bin[period(i,T,n)];
		printf("a1=%c a2=%c \n",a1,a2);
		s=(int)a1+(int)a2;
		C+=puiss(-1,s);
		printf("C=%d s=%d\n",C,s);
		}
		printf("auto correlation of T=%d est %d\n",T,C);
	}
} | 
Partager