channel.cpp
来自「介绍了一种串行LDPC码的编码器和译码器的实现形式 C++环境下编写。有些地方」· C++ 代码 · 共 39 行
CPP
39 行
#include "main.h"
extern int sgn(double);
extern double Clipping(double x);
/*function: gemerate the guass noise
parameter:no the guass noise power*/
double gauss(double n0)
{
double u1,u0;
double gaussnoise;
u0 = (double)rand()/(double)RAND_MAX;
u1 = (double)rand()/(double)RAND_MAX;
//*
if( u0 < limit)
{
u0 = limit;
// printf("limit\n");
}
//*/
gaussnoise = sqrt( -n0*log(u0) )*cos( 2*pi*u1 );
return gaussnoise;
}
/*function: simulating the process of the sigal being transformed in the gauss channel
parameter:*codebit pointer point to the codewords to be transformed
*receive pointer point to the received signal
lratio the likelihood ratio of the probability of 0 to that of 1
n0 the noise power */
void transmit(int *codedbit,double *receive,double *lratio, double n0)
{
int i;
for(i = 0;i < EncodedLength; i++ )
{
receive[i] = (double)( (codedbit[i]<<1)-1 ) + gauss(n0);
lratio[i] = 4.*receive[i]/n0 ;
lratio[i] = Clipping( lratio[i] );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?