📄 test_lgold.c
字号:
/* * $Log: test_lgold.c,v $ * Revision 1.1 2000/05/03 14:30:04 bjc97r * Initial revision * */char *id = "$Id: test_lgold.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";#include <stdio.h>#include <stdlib.h>#include <string.h>#include "lgold.h"#include "u2long.h"#define SZ_BUF 128int main( int argc, char *argv[] ){ unsigned deg; char poly0[SZ_BUF], poly1[SZ_BUF]; u2long pn_size; u2long offset; u2long one, five; if ( argc != 4 ) { fprintf(stderr, "%s: deg poly poly1\n", argv[0] ); fprintf(stderr, " Try, for example,\n" ); fprintf(stderr, " %s 5 045 075\n", argv[0] ); fprintf(stderr, " %s 23 040000041 040404041\n", argv[0] ); exit(1); } deg = atoi( argv[1] ); if ( deg < 2 ) { fprintf(stderr, "deg should be greater than 2\n"); exit(1); } strncpy( poly0, argv[2], SZ_BUF ); strncpy( poly1, argv[3], SZ_BUF ); /* Print the header. */ printf("The entered long Gold code specification is\n\n"); printf(" degree : %d\n", deg); printf(" poly0(octal): %s\n", poly0 ); printf(" poly1(octal): %s\n\n", poly1 ); printf("This program generates two Gold sequences using " "the above polynomials.\n" "The seeds for the first Gold sequence are '1' and '1'.\n" "The seeds for the second Gold sequence are '1' and '5'.\n"); printf("\n1st column: offset in hexadecimal format\n"); printf("2nd column: autocorrelations of the first Gold sequence\n"); printf("3rd column: autocorrelations of the second Gold sequence\n"); printf("4th column: cross-correlations between the two Gold sequences\n\n"); pn_size.h = 0; pn_size.l = 1; u2long_lshift( &pn_size, deg ); u2long_dec( &pn_size ); one.h = 0; one.l = 1; five.h = 0; five.l = 5; for ( offset.h = 0, offset.l = 1; u2long_cmp(offset,pn_size) < 0; u2long_inc(&offset) ) { u2long i; long acorr0, acorr1, xcorr; LGold *pn00, *pn01; LGold *pn10, *pn11; LGold *pnx0, *pnx1; pn00 = lgold_create( deg, poly0, poly1, one, one); pn01 = lgold_create( deg, poly0, poly1, one, one); pn10 = lgold_create( deg, poly0, poly1, one, five); pn11 = lgold_create( deg, poly0, poly1, one, five); pnx0 = lgold_create( deg, poly0, poly1, one, one); pnx1 = lgold_create( deg, poly0, poly1, one, five); /* Apply the offset. */ for( i.h=0, i.l=0; u2long_cmp(i,offset) < 0; u2long_inc(&i) ) { lgold(pn01); lgold(pn11); lgold(pnx1); } acorr0 = acorr1 = xcorr = 0; for ( i.h=0, i.l=0; u2long_cmp(i,pn_size) < 0; u2long_inc(&i) ) { acorr0 += ( lgold(pn00) == lgold(pn01) ) ? +1 : -1; acorr1 += ( lgold(pn10) == lgold(pn11) ) ? +1 : -1; xcorr += ( lgold(pnx0) == lgold(pnx1) ) ? +1 : -1; } printf("%08lx:%08lx %10ld %10ld %10ld\n", offset.h, offset.l, acorr0, acorr1, xcorr ); lgold_free(pn00); lgold_free(pn01); lgold_free(pn10); lgold_free(pn10); lgold_free(pnx0); lgold_free(pnx1); } puts(""); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -