📄 test_lmseq.c
字号:
/* * $Log: test_lmseq.c,v $ * Revision 1.1 2000/05/03 14:30:04 bjc97r * Initial revision * */char *id = "$Id: test_lmseq.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";#include <stdio.h>#include <stdlib.h>#include <string.h>#include "lmseq.h"#include "u2long.h"#define SZ_BUF 128static u2long zero= {0,0};static u2long one = {0,1};int main( int argc, char *argv[] ){ unsigned deg; char poly[SZ_BUF]; u2long pn_size; u2long offset; u2long i; u2long acorr0, acorr1, xcorr; LMseq *pn00, *pn01; LMseq *pn10, *pn11; char c0, c1; if ( argc != 3 ) { fprintf(stderr, "%s: deg poly\n", argv[0] ); fprintf(stderr, " Try, for example,\n" ); fprintf(stderr, " %s 5 045\n", argv[0] ); fprintf(stderr, " %s 34 201000000007\n", argv[0] ); exit(1); } deg = atoi( argv[1] ); if ( deg < 2 || deg > 63 ) { fprintf(stderr, "deg(%d) is out of range!\n", deg); exit(1); } strncpy( poly, argv[2], SZ_BUF ); /* Print the header. */ printf("The entered long Mseq code specification is\n\n"); printf(" degree : %d\n", deg); printf(" poly(octal): %s\n", poly); printf("This program generates two long Mseq sequences using " "the above polynomial.\n" "The seed for the first Mseq sequence is '1'.\n" "The seed for the second Mseq sequence is '5'.\n"); printf("\n1st column: offset in hexadecimal format\n"); printf("2nd column: autocorrelations of the first Mseq sequence\n"); printf("3rd column: autocorrelations of the second Mseq sequence\n"); printf("4th column: cross-correlations between the two Mseq sequences\n\n"); pn_size = one; u2long_lshift( &pn_size, deg ); u2long_dec( &pn_size ); pn00 = lmseq_create( deg, poly, 0, 1); pn01 = lmseq_create( deg, poly, 0, 1); pn10 = lmseq_create( deg, poly, 0, 5); pn11 = lmseq_create( deg, poly, 0, 5); for ( offset=one; u2long_cmp(offset,pn_size) < 0; u2long_inc(&offset) ) { /* increment the offset */ lmseq(pn01); lmseq(pn11); acorr0 = acorr1 = xcorr = zero; for ( i = zero; u2long_cmp(i,pn_size) < 0; u2long_inc(&i) ) { c0 = lmseq(pn00); c1 = lmseq(pn11); if ( c0 == lmseq(pn01) ) u2long_inc(&acorr0); else u2long_dec(&acorr0); if ( lmseq(pn10) == c1 ) 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 ); } puts(""); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -