全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#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; 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)(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; 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+) statept.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; */ /*此行程序可用于检测第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,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)*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;i
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 法律职业资格(主观题)真题及答案解析2025
- 大学英译汉课件
- 2026天津美术学院第一批招聘硕士研究生及以上人员考试笔试模拟试题及答案解析
- 陕西交控集团2026校园招聘笔试考试参考试题及答案解析
- 2025四川广元剑阁县行政争议化解中心调解专家库成员选聘考试笔试备考题库及答案解析
- 2025云南曲靖市麒麟区政协办公室招聘公益性岗位工作人员1人笔试考试备考题库及答案解析
- 大学唐诗课件
- 2025湖南永州陆港枢纽投资发展集团有限公司招聘4人笔试考试参考试题及答案解析
- 低频神经电刺激治疗仪
- 2026年甘肃省酒泉市教育系统高层次人才引进补充考试笔试备考题库及答案解析
- 井下支柱工安全操作规程
- 数控铣工内部技能考核试卷及答案
- 施工质量安全环保工期售后服务保障措施及相关的违约承诺
- 人工智能对生产关系变革的推动作用研究
- 沟槽施工安全培训课件
- 铸牢中华民族共同体课件
- 2025贵州盘江煤电集团医院招聘68人笔试参考题库附答案解析
- 建筑工程土建施工技术方案
- 白天和夜间的消防应急预案(3篇)
- 液流电池原理讲解
- 盐酸羟考酮注射液用法
评论
0/150
提交评论