📄 lkasami.c
字号:
/* * $Log: lkasami.c,v $ * Revision 1.1 2000/05/03 14:30:04 bjc97r * Initial revision * */char *_lkasami_id = "$Id: lkasami.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";#include <stdio.h>#include <stdlib.h>#include "lkasami.h"#include "gf.h"#include "lmseq.h"#include "mseq.h"/* * It creates a Kasami code generator. Only the generator polynomial * for the main m-sequence is specified through the arguments. * The sub-sequence polynomial is calculated internally based on the * main polynomial. The relative shift of the subsequence is controlled * by the subsequence 'seed' argument. The initial state of the main * m-sequence generator is fixed to 1. Note that 'seed' does not correspond * to a 'serial shift' directly, if this makes sense to you. The valid range * of 'seed' is from 0 to 2^(deg/2)-1, so that 2^(deg/2) number of different * Kasami sequences can be obtained. To generate the other sequence in the * family, ie the sub-m-sequence itself, use find_longsubpoly() to get the * primitive polynomial of the sub-m-sequence and use mseq_create() to actually * generate the m-sequence. */LKasami *lkasami_create( unsigned deg, char *poly, unsigned long seed ){ LKasami *kasami; unsigned long subpoly; unsigned subdeg; if ( deg & 1 ) { fprintf(stderr, "lkasami_create: the degree of the main m-seq polynomial" " should be even.\n"); return NULL; /* odd main degree */ } if ( deg > 62 ) { fprintf(stderr, "lkasami_create: ..cannot handle deg > 62\n"); return NULL; /* too high degree */ } subdeg = deg >> 1; subpoly = find_longsubpoly( deg, poly ); kasami = (LKasami*) malloc( sizeof(LKasami) ); kasami->mseq0 = lmseq_create( deg, poly, 0, 1 ); kasami->mseq1 = mseq_create ( subdeg, subpoly, seed & ((1<<subdeg)-1) ); return kasami;}/* * lkasami_free() deallocates the memory space for * the long Kasami sequence generator. */void lkasami_free( LKasami *kasami ){ lmseq_free( kasami->mseq0 ); mseq_free ( kasami->mseq1 ); free( kasami );}/* lkasami() gives the next long Kasami sequence in unipolar form, ie 1 or 0.*/char lkasami( LKasami *id ){ return lmseq(id->mseq0) ^ mseq(id->mseq1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -