binlfsr.cc.txt

来自「压缩文件中是Error Correction Coding - Mathemat」· 文本 代码 · 共 43 行

TXT
43
字号
//  Program: BinLFSR.cc////  Todd K. Moon//// Copyright 2004 by Todd K. Moon// Permission is granted to use this program/data// for educational/research only#include "BinLFSR.h"BinLFSR::BinLFSR(int in_g, int in_n, int initstate){   int i;   n = in_n;   mask = (1<<n)-1;  // a mask of n ones   mask1 = (1<<(n-1));  // select the highest bit in shift register   g = in_g & mask;   state = initstate;}   char BinLFSR::step(void){   char out = (state&mask) >> (n-1);   state = ((state<<1)^(g*out))&mask;   return out;}char BinLFSR::step(int &stateout){   char out = (state&mask) >> (n-1);   stateout = state;   state = ((state<<1)^(g*out))&mask;   return out;}/*Local Variables:compile-command: "gcc -c -g BinLFSR.cc"End:*/

⌨️ 快捷键说明

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