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

📄 channel.c

📁 用于LDPC编码译码的仿真实现。包括随机生成校验矩阵、由校验矩阵产生生成矩阵、编码、加随机噪声、译码等内容。原作者是老外
💻 C
字号:
/* CHANNEL.C - Procedures and variables regarding channels. */
//关于信道的程序和变量
/* Copyright (c) 2001 by Radford M. Neal 
 *
 * Permission is granted for anyone to copy, use, or modify this program 
 * for purposes of research or education, provided this copyright notice 
 * is retained, and note is made of any changes that have been made. 
 *
 * This program is distributed without any warranty, express or implied.
 * As this program was written for research purposes only, it has not been
 * tested to the degree that would be advisable in any important application.
 * All use of this program is entirely at the user's own risk.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "channel.h"


/* GLOBAL VARIABLES.  Declared in channel.h. */

channel_type channel;	/* Type of channel */ //信道类型,枚举型变量,全局变量

double error_prob;	/* Error probability for BSC */
double std_dev;		/* Noise standard deviation for AWGN */
double lwidth;		/* Width of noise distributoin for AWLN */


/* PARSE A COMMAND-LINE SPECIFICATION OF A CHANNEL.  Takes a pointer to an
   argument list and an argument count; returns the number of arguments that 
   make up a channel specification at this point in the command line.  Returns
   zero if the argument list does not start with a channel specification.
   Returns -1 if there seems to be a channel specification here, but it's 
   invalid.

   Sets the variables declared in channel.h to the type and parameters of
   the channel.
 */
//分析信道类型,并设置关于信道的全局变量
void channel_parse   
( char *fact_channel,		 /* channel type */
  double channel_para		/* channel parameter */
)
{ 
	if (strcmp(fact_channel,"bsc")==0  || strcmp(fact_channel,"BSC")==0)
	{
		channel = BSC;
        if (channel_para<=0 || channel_para>=1)
		{ channel_usage();
		}
		
	}
	else if (strcmp(fact_channel,"awgn")==0 || strcmp(fact_channel,"AWGN")==0)
	{
		channel = AWGN;
        if (channel_para<=0)
		{ channel_usage();
		}
        
	}
    else if (strcmp(fact_channel,"awln")==0 || strcmp(fact_channel,"AWLN")==0)
	{
		channel = AWLN;
        if (lwidth<=0)
		{ channel_usage();
		}
        
	}
    else
	{ channel_usage();
	}
}


/* PRINT USAGE MESSAGE REGARDING CHANNEL SPECIFICATIONS. */

void channel_usage(void)
{
  fprintf(stderr,
    "Channel: bsc error-probability | awgn standard-deviation | awln width\n");
}

⌨️ 快捷键说明

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