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

📄 test_kasami.c

📁 kasami伪码产生器
💻 C
字号:
/* * $Log: test_kasami.c,v $ * Revision 1.1  2000/05/03 14:30:04  bjc97r * Initial revision * */char *id = "$Id: test_kasami.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";#include <stdio.h>#include <stdlib.h>#include "kasami.h"#include "gf.h"int main( int argc, char *argv[] ){  unsigned deg;  ulong poly0, poly1;  unsigned pn_size;  unsigned offset;  if ( argc != 3 ) {    fprintf(stderr, "%s: deg poly\n", argv[0] );    fprintf(stderr, " deg is an even positive number >= 4.\n" );    fprintf(stderr, " poly is a primitive polynomial given in octal form.\n" );    fprintf(stderr, " Try, for example,\n" );    fprintf(stderr, "   %s 6 0103\n", argv[0] );    fprintf(stderr, "   %s 20 04000011\n", argv[0] );    exit(1);  }  deg = atoi( argv[1] );  if ( deg < 4 ) {    fprintf(stderr, "deg should be greater than 4\n");    exit(1);  }  poly0 = strtoul( argv[2], (char**)NULL, 0 );  if ( poly0 < 7 ) {    fprintf(stderr, "poly(%s) is invalid polynomial!\n", argv[2] );    exit(1);  }  poly1 = find_subpoly( deg, poly0 );  // Print the header.  printf("The chosen Kasami code specification is\n\n");  printf("  degree      : %d\n", deg);  printf("  poly0(octal): 0%lo\n",   poly0 );  printf("  poly1(octal): 0%lo\n\n", poly1 );  printf("This program generates two Kasami sequences using "	 "the above polynomials.\n"	 "The seeds for the first  Kasami sequence are '1' and '1'.\n"	 "The seeds for the second Kasami sequence are '1' and '5'.\n");  printf("\n1st column: offset\n");  printf("2nd column: autocorrelations of the first  Kasami sequence\n");  printf("3rd column: autocorrelations of the second Kasami sequence\n");  printf("4th column: cross-correlations between the two Kasami sequences\n");  puts("");  pn_size = (1 << deg) -1;  for ( offset = 0; offset < pn_size; offset++ ) {     int i;    long acorr0, acorr1, xcorr;    Kasami *pn00, *pn01;    Kasami *pn10, *pn11;    Kasami *pnx0, *pnx1;    pn00 = kasami_create( deg, poly0, 1);    pn01 = kasami_create( deg, poly0, 1);    pn10 = kasami_create( deg, poly0, 5);    pn11 = kasami_create( deg, poly0, 5);    pnx0 = kasami_create( deg, poly0, 1);    pnx1 = kasami_create( deg, poly0, 5);    // Apply the offset.    for( i = 0; i < offset; i++ ) {      kasami(pn01);      kasami(pn11);      kasami(pnx1);    }    acorr0 = acorr1 = xcorr = 0;    for ( i=0; i < pn_size; i++ ) {      acorr0 += ( kasami(pn00) == kasami(pn01) ) ? +1 : -1;      acorr1 += ( kasami(pn10) == kasami(pn11) ) ? +1 : -1;      xcorr  += ( kasami(pnx0) == kasami(pnx1) ) ? +1 : -1;    }    printf("%10d %10ld %10ld %10ld\n", offset, acorr0, acorr1, xcorr );    kasami_free(pn00);    kasami_free(pn01);    kasami_free(pn10);    kasami_free(pn10);    kasami_free(pnx0);    kasami_free(pnx1);  }  puts("");  return 0;}

⌨️ 快捷键说明

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