⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 channel.cpp

📁 介绍了一种串行LDPC码的编码器和译码器的实现形式 C++环境下编写。有些地方还需完善
💻 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 + -