下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.#include #include Conio.h#define N 7#include math.h#include #include#define randomize() srand(unsigned)time(NULL)encode(unsigned int *symbols, /*编码输出*/unsigned int *data, /*编码输入*/unsigned int nbytes, /*nbytes=n/16,n为实际输入码字的数目*/unsigned int startstate /*定义初始化状态*/) int j; unsigned int input,a1=0,a2=0
2、; for(j=0;j1)&1)(state2&1)(state1&1); sym2=(state21)&1)(state1&1); sym=(sym11)=(state2&1) c=(m&1)(sym&1)+(m 1)&1)(sym 1)&1);else c=10000; return(c); int traninput(int a,int b) /*状态从a到b时输入卷积码的符号*/int c; c=(b&2)1); return(c); int tranoutput(int a,int b) /*状态从a到b时卷积码输出的符号*/int c,s1,s2; s1=(a&1)(a&2)1)(
3、b&2)1); s2=(a&1)(b&2)1); c=(s11)|s2; return(c); void viterbi(int initialstate, /*定义解码器初始状态*/ int *viterbiinput, /*解码器输入码字序列*/ int *viterbioutput /*解码器输出码字序列*/ )struct sta /*定义网格图中每一点为一个结构体,其元素包括*/ int met; /*转移到此状态累计的度量值*/ int value; /*输入符号 */ struct sta *last; /*及指向前一个状态的指针*/ ; struct sta state4N;
4、struct sta *g,*head; int i,j,p,q,t,r,u,l; for(i=0;i4;i+) /* 初始化每个状态的度量值*/ for(j=0;jN;j+) stateij.met=0; for(l=0;l4;l+) statel0.met=trandistance(*viterbiinput,initialstate,l); statel0.value=traninput(initialstate,l); statel0.last=NULL; viterbiinput+; /*扩展第一步幸存路径*/ for(t=1;tN;t+) for(p=0;p4;p+) statep
5、t.met=state0t-1.met+trandistance(*viterbiinput,0,p); statept.value=traninput(0,p); statept.last=&state0t-1; for(q=0;q4;q+) if(stateqt-1.met+trandistance(*viterbiinput,q,p)0;u-) /*向前递归的找出最大似然路径 */ *(viterbioutput+(u-1)=g-value; g=g-last; /* for(u=0;u8;u+) *(viterbioutput+u)=stateu2.met; */ /*此行程序可用于检
6、测第n列的度量值*/ void decode(unsigned int *input, int *output,int n) int viterbiinput100; int j; for(j=0;jn+2;j+) viterbiinputj=(inputj*21)|inputj*2+1; /printf(%3d,viterbiinputj); viterbi(0,viterbiinput,output); void main()unsigned int encodeinput100,wrong10=0,0,0,0,0,0,0,0,0,0,encodeoutput100; int n=5,i,
7、m,j=0,decodeinput100,decodeoutput100; randomize(); for(i=0; in; i+) encodeinputi=rand()%2; encodeinputn= encodeinputn+1=0;encode(encodeoutput,encodeinput,n+2,0);printf(the input of encoder is :n); for(i=0;in; i+)printf(%2d,encodeinputi); printf(n); printf(the output of encoder is :n); for(i=0;i(n+2)
8、*2;i+)printf(%2d,encodeoutputi); if(i%20=19) printf(n);printf(n);printf(please input the number of the wrong bitn);scanf(%d,&m);printf(please input the positions of the wrong bit(0-9)n);for(i=0;im;i+)scanf(%d,&wrongm); if(encodeoutputwrongm=0) encodeoutputwrongm=1; else encodeoutputwrongm=0; printf(the input of decoder is :n); for(i=0;i(n+2)*2;i+)printf(%2d,encodeoutputi); if(i%20=19) printf(n); printf(n);decode(encodeoutput,decodeoutput,n+2);printf(the output of decoder is :n);for(i=0;in;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 印染助剂复配工标准化强化考核试卷含答案
- 托育师安全专项知识考核试卷含答案
- 石墨化工操作管理评优考核试卷含答案
- 味精发酵工岗位专业实务考核试卷含答案
- 动物胶提胶浓缩工基础管理水平考核试卷含答案
- 消毒员岗前综合评价考核试卷含答案
- 避雷器装配工岗前岗中考核试卷含答案
- 劳务经纪人岗位质量监控考核试卷含答案
- 汽轮机值班员安全生产基础知识测试考核试卷含答案
- 客运车辆驾驶员岗位模拟考核试卷含答案
- 2026小学数学北师大版新教材培训:四至六年级教材解析
- 2026人教版小学三年级下册数学期末综合试卷3套(打印版+答案解析)
- 2026年巨量本地推初级题库
- 校本教材-无人机空气动力学与飞行原理
- T/CEC 193-2018 电力行业无人机巡检作业人员培训考核规范
- 麻醉科术中过敏反应处理教程
- 生物医药研发项目计划书范例
- 医疗器械经营质量管理规范现场检查原则培训试题及答案
- 智能交通系统在公共交通线路优化中的应用可行性研究报告
- 第十届“雄鹰杯”小动物医师技能大赛备考试题库(附答案)
- 医院食品安全培训
评论
0/150
提交评论