信息论信道容量实验报告用c
湖 南 大 学
信息科学与工程学院
实 验 报 告
实验名称信道容量的迭代算法课程名称信息论与编码
1.实验目的
(1)进一步熟悉信道容量的迭代算法;
(2)学习如何将复杂的公式转化为程序;
(3)掌握C语言数值计算程序的设计和调试技术。
2、实验方法
硬件:pc机
开发平台:visual c++软件
编程语言:c语言
3、实验要求
(1)已知:信源符号个数r、信宿符号个数s、信道转移概率矩阵P。
(2)输入:任意的一个信道转移概率矩阵。信源符号个数、信宿符号个数和每个具体的转移概率在运行时从键盘输入。
(3)输出:最佳信源分布P*,信道容量C。
算法分析
1:procedure CHANNEL CAPACITY(r,s,())
2:initialize:信源分布=1/r,相对误差门限,C=—
3:repeat
4:
5:
6:
C (
7:until
8:output P*= ,C
9:end procedure
程序调试
1、头文件引入出错
f:\visualc++\channel\cpp1.cpp(4) : fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
————#include
纠错://#include
f:\visualc++\channel\cpp1.cpp(5) : fatal error C1083: Cannot open include file: 'values.h': No such file or directory
————#include
纠错://#include
2、变量赋值错误
f:\visualc++\channel\cpp1.cpp(17) : error C2065: 'ij' : undeclared identifier
f:\visualc++\channel\cpp1.cpp(17) : error C2440: 'initializing' : cannot convert from 'int' to 'float ** ' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
————float **phi_ij=ij=NULL;
纠错:float **phi_ij=NULL;
3、常量定义错误
f:\visualc++\channel\cpp1.cpp(40) : error C2143: syntax error : missing ';' before 'for'
————for(i=0;i
phi_ij[i]=(float *)calloc(s,sizeof(float));
f:\visualc++\channel\cpp1.cpp(52) : error C2021: expected exponent value, not ' '
棗棗if(fabs(validate -1.0)>DELTA)
f:\visualc++\channel\Cpp1.cpp(84) : error C2021: expected exponent value, not ' '
棗棗 if(fabs(p_j)>=DELTA)
f:\visualc++\channel\Cpp1.cpp(100) : error C2021: expected exponent value, not ' '
棗棗 if(fabs(phi_ij[i][j])>=DELTA)
f:\visualc++\channel\Cpp1.cpp(116) : error C2021: expected exponent value, not ' '
棗棗 while(fabs(C-C_pre)/C>DELTA);
纠错:#define DELTA 0.000001;
F:\visualc++\channel\Cpp1.cpp(68) : error C2065: 'MAXFLOAT' : undeclared identifier
F:\visualc++\channel\Cpp1.cpp(68) : warning C4244: '=' : conversion from '