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

📄 test_mseq.c

📁 在linux系统下开发研究移动通信的工具型代码
💻 C
字号:
/* * $Log: test_mseq.c,v $ * Revision 1.1  2000/05/03 14:30:04  bjc97r * Initial revision * */char *id = "$Id: test_mseq.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";/* * This program demonstrates some uses of mseq*() functions. * Choose the degree of the m-sequence polynomial from 3 to 11. */#define DEGREE 4#if DEGREE == 3#define POLY 013#endif#if DEGREE == 4#define POLY 023#endif#if DEGREE == 5#define POLY 045#endif#if DEGREE == 6#define POLY 0103#endif#if DEGREE == 7#define POLY 0211#endif#if DEGREE == 8#define POLY 0435#endif#if DEGREE == 9#define POLY 01021#endif#if DEGREE == 10#define POLY 02011#endif#if DEGREE == 11#define POLY 04005#endif#include <stdio.h>#include <stdlib.h>#include "mseq.h"#include "pnutil.h"int main( void ){  Mseq *pn0, *pn1;  char *pnd0, *pnd1;  unsigned length;  int i;  length = (1 << DEGREE) - 1;  pn0 = mseq_create( DEGREE, POLY, 1 );  pnd0 = (char*) malloc(length);  for( i = 0; i < length; i++ ) {    pnd0[i] = mseq(pn0);  }  pn1 = mseq_create( DEGREE, POLY, 5 );  pnd1 = (char*) malloc(length);  for( i = 0; i < length; i++ ) {    pnd1[i] = mseq(pn1);  }  /* Print the header. */  printf("This program was compiled for the following m-sequences.\n\n");  printf("degree     : %d\n", DEGREE );  printf("poly(octal): 0%o\n\n", POLY );  printf("This program generates two m-sequences with the above polynomial.\n"	 "The seed of the first m-sequence is '1'.\n"	 "The seed of the  next m-sequence is '5'.\n");  printf("Please note that the seed does not directly correspond to "	 "the offset.\n");  printf("\n1st column: offset\n");  printf("2nd column: autocorrelations of the first m-sequence\n");  printf("3rd column: autocorrelations of the second m-sequence\n");  printf("4th column: cross-correlations between the two m-sequences\n\n");  /* Print the correlations. */  for( i = 0; i < length; i++ ) {    printf("%4d %6d %6d %6d\n", i,	   pn_acorr(pnd0, i, length),	   pn_acorr(pnd1, i, length),	   pn_xcorr(pnd0, pnd1, i, length) );  }  puts("");  return 0;}

⌨️ 快捷键说明

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