📄 channel.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -