⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_ekasami.c

📁 在linux系统下开发研究移动通信的工具型代码
💻 C
字号:
/* * $Log: test_ekasami.c,v $ * Revision 1.1  2000/05/03 14:30:04  bjc97r * Initial revision * */char *id = "$Id: test_ekasami.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";#include <stdio.h>#include <stdlib.h>#include <string.h>#include "ekasami.h"#include "gf.h"#include "u2long.h"#define SZ_BUF 128/* static u2long zero={0,0}; */static u2long one={0,1};static u2long two={0,2};int main( int argc, char *argv[] ){  unsigned deg;  char poly0[SZ_BUF], poly1[SZ_BUF];  unsigned long poly2;  EKasami *pn00, *pn01;  EKasami *pn10, *pn11;  u2long pn_size;  u2long offset;  if ( argc != 4 ) {    fprintf(stderr, "%s: deg poly0 poly1\n", argv[0] );    fprintf(stderr, " deg is a positive even interger.\n" );    fprintf(stderr, " poly0 and poly1 are primitive polynomials of a preferred"	    " pair of m-sequences.\n" );    fprintf(stderr, " Try, for example,\n" );    fprintf(stderr, "   %s 6 0103 0147\n", argv[0] );    fprintf(stderr, "   %s 18 01000201 01002241\n", argv[0] );    /*    fprintf(stderr, "   %s 36 01000000004001\n", argv[0] ); */    exit(1);  }  deg = atoi( argv[1] );  if ( deg < 4 ) {    fprintf(stderr, "deg should be greater than 4\n");    exit(1);  }  strncpy( poly0, argv[2], SZ_BUF );  strncpy( poly1, argv[3], SZ_BUF );  poly2 = find_longsubpoly( deg, poly1 );  /* Print the header. */  printf("The entered long Kasami code specification is\n\n");  printf("  degree      : %d\n", deg);  printf("  poly0(octal): %s\n",   poly0 );  printf("  poly1(octal): %s\n",   poly1 );  printf("  poly2(octal): 0%lo\n\n", poly2 );  printf("This program generates two eKasami sequences using "	 "the above polynomials.\n"	 "The seeds for the first  Kasami sequence are '1', '1' and '1'.\n"	 "The seeds for the second Kasami sequence are '1', '2' and '5'.\n");  printf("\n1st column: offset in hexadecimal format\n");  printf("2nd column: autocorrelations of the first  eKasami sequence\n");  printf("3rd column: autocorrelations of the second eKasami sequence\n");  printf("4th column: cross-correlations between the two Kasami sequences\n");  puts("");    pn_size.h = 0; pn_size.l = 1;  u2long_lshift( &pn_size, deg );  u2long_dec( &pn_size );  pn00 = ekasami_create( deg, poly0, poly1, one, one, 0 );  pn01 = ekasami_create( deg, poly0, poly1, one, one, 0 );  pn10 = ekasami_create( deg, poly0, poly1, one, two, 1 );  pn11 = ekasami_create( deg, poly0, poly1, one, two, 1 );  for ( offset.h = 0, offset.l = 0; u2long_cmp(offset,pn_size) < 0;	u2long_inc(&offset) ) {     u2long i;    u2long acorr0, acorr1, xcorr;    char c0, c1;    acorr0.h = acorr1.h = xcorr.h = 0;    acorr0.l = acorr1.l = xcorr.l = 0;    for ( i.h=0, i.l=0; u2long_cmp(i,pn_size) < 0; u2long_inc(&i) ) {      if( (c0=ekasami(pn00)) == ekasami(pn01) )  u2long_inc(&acorr0);      else  u2long_dec(&acorr0);      if( ekasami(pn10) == (c1=ekasami(pn11)) )  u2long_inc(&acorr1);      else  u2long_dec(&acorr1);      if( c0 == c1 ) u2long_inc(&xcorr );      else u2long_dec(&xcorr );    }    printf("%08lx:%08lx %10ld %10ld %10ld\n", offset.h, offset.l,	   acorr0.l, acorr1.l, xcorr.l );    /* increment the offset. */    ekasami(pn01);    ekasami(pn11);  }  puts("");  ekasami_free(pn00);    ekasami_free(pn01);  ekasami_free(pn10);    ekasami_free(pn11);  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -