gold.c
来自「产生PN序列」· C语言 代码 · 共 50 行
C
50 行
/* * $Log: gold.c,v $ * Revision 1.1 2000/05/03 14:30:04 bjc97r * Initial revision * */char *_gold_id = "$Id: gold.c,v 1.1 2000/05/03 14:30:04 bjc97r Exp $";#include <stdio.h>#include <stdlib.h>#include "gold.h"/* * It creates a Gold code generator with the two preferred m-sequences * with the given seeds. The Gold code generator is returned. */Gold * gold_create( unsigned deg, unsigned long p0, unsigned long p1, unsigned long s0, unsigned long s1 ){ Gold *gold; if ( deg > 31 ) { fprintf(stderr, "gold_create: ..cannot handle deg > 31\n"); return NULL; } gold = (Gold*) malloc ( sizeof(Gold) ); gold->mseq0 = mseq_create( deg, p0, s0 ); gold->mseq1 = mseq_create( deg, p1, s1 ); return gold;}/* gold_free() deallocates the memory space for the Gold sequence generator. */void gold_free( Gold *gold ){ mseq_free( gold->mseq0 ); mseq_free( gold->mseq1 ); free( gold );}/* gold() gives the next Gold sequence. The sequence is unipolar, ie 1 or 0. */char gold( Gold *gen ){ return mseq(gen->mseq0) ^ mseq(gen->mseq1);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?