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

📄 mrog.c

📁 Orthogonal Codes
💻 C
字号:
/* * $Log: mrog.c,v $ * Revision 1.1  2000/05/03 14:30:04  bjc97r * Initial revision * */char *_mrog_id = "$Id: mrog.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";#include <stdio.h>#include <stdlib.h>#include "mrog.h"// It create an Multi-Rate Orthogonal Gold(MROG) code generator with// the given connection polynomials and for the given index'th code.// The MROG generator is returned.Mrog *mrog_create( unsigned deg, unsigned long poly0, unsigned long poly1,		   unsigned index ){  Mrog *mrog;  int   bindex; /* base ogold index */  if ( deg > 31 ) {    fprintf(stderr, "mrog_create: ..cannot handle deg > 31\n");    return NULL; /* too big degree of polynomial */  }  mrog = (Mrog*) malloc( sizeof(Mrog) );  bindex = index & ( (1<<deg) - 1 ); /* last deg bits of the index */  mrog->id = ogold_create( deg, poly0, poly1, bindex );  mrog->period   = 1 << deg; /* 2^deg */  mrog->og_cnt   = 1;        /* 1..period */  mrog->ext_code = index >> deg; /* upper part of the index */  mrog->ext_cnt  = 0;        /* 0.. */  mrog->ext      = 0;        /* 0 or 1 */  return mrog;}void mrog_free( Mrog *mrog ){  ogold_free( mrog->id );  free( (void*) mrog );}// mrog() gives the next multi-rate orthogonal Gold code sequence.char mrog( Mrog *id ){  char seq;    seq = id->ext ^ ogold( id->id );  if ( id->og_cnt == id->period ) {    /* ogold code cycles at this point. update extension modifier */    unsigned long dump;    char          tmp;    id->og_cnt = 1;    id->ext_cnt++;    /* Sylvester construction or Hadamard transform of the original       orthogonal Gold code sequence */    dump = id->ext_cnt & id->ext_code;    tmp = 0;    for( tmp = 0; dump; dump >>= 1 ) {      tmp ^= dump & 1;    }    id->ext = tmp;  }  else {    id->og_cnt++;  }  return seq;}

⌨️ 快捷键说明

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