function m_xo = rs_decode (r_x,n,k,m,t,m_xi,alpha_to,index_of,gx)
%%
%rs译码
%%
%本函数实现伴随多项式的计算
s=zeros(1,n-k);
for j = 1:n-k
s(j) = rs_poly( r_x,alpha_to(j+1),m,alpha_to,index_of);%生成伴随矩阵s(j)=R*(alpha_to(j+1))
end
synd_x=[1,s]; %从第二位开始
%%
%本函数实现计算错误位置多项式
%sigma(i,:)是第i次叠带产生的错误位置多项式,step(i)表示第i次叠带产生的错误位置多项式的阶数,high是pi(x)第i+1次叠带的最高项系数
sigma=zeros(n-k+2,n-k+1);
step=zeros(1,n-k+2);
high=zeros(1,n-k+2);
sigma(1,1)=1;
step(1)=0;
high(1)=1;
sigma(2,1)=1;
step(2)=0;
high(2)=synd_x(2);
for j=2:n-k+1
if (high(j)==0) %若high(j)==0,不需要进行修正
sigma(j+1,:)=sigma(j,:);
step(j+1)=step(j);
else
for h=1:j-1 %high(j)~=0,找出j-1个当中,使得i-d(j)最大,且d(j)~=0
if(high(h)~=0)
i=h;
end;
end;
temp=zeros(1,j-i+1);
temp(j-i+1)=1;
temp1=rs_polymul(temp,sigma(i,:),m,alpha_to,index_of); %多项式乘法,算得
len=length(temp1);
temp2=zeros(1,n-k+1);
temp2=temp1(1:n-k+1);
% high
sigma(j+1,:)=sigma(j,:)+high(j)*rs_rev(high(i),m,alpha_to,index_of)*temp2; %修正sigma(j+1,:)
temp4=rs_mul(high(j),rs_rev(high(i),m,alpha_to,index_of),m,alpha_to,index_of);
for l=1:n-k+1
sigma(j+1,l)=rs_add(sigma(j,l),rs_mul(temp4,temp2(l),m,alpha_to,index_of),m); %计算sigma(j+1,:)
end;
end;
for h=1:n-k+1
if (sigma(j+1,h)~=0)
step(j+1)=h-1; %因h=1:n-k+1,所以h需要-1
end;
end;
for h=1:step(j+1)
temp3=rs_mul(sigma(j+1,h+1),synd_x(j+1-h),m,alpha_to,index_of); %更新计算
high(j+1)=rs_add(high(j+1),temp3,m);
end;
if(j+1<n-k+2)
high(j+1)=rs_add(high(j+1),synd_x(j+1),m);
end;
end;
sigma_x=sigma(n-k+2,:);
%%
%本函数实现错误位置的根的计算
% sigma_x为错误位置多项式,root为错误位置的根
j=1;
root=[];
for i=1:(2^m-1)
result=rs_poly(sigma_x,alpha_to(i),m,alpha_to,index_of);
if result==0
root(j)=alpha_to(i);
j=j+1;
end
end
site=[];
gf_site=[];
for i=1:length(root)
temp=rs_rev(root(i),m,alpha_to,index_of);
site(i)=index_of(temp);
end
%%
%本函数实现用forney算法计算出错误数值和对应的错误位置
value=zeros(1,t);
w1=zeros(1,length(synd_x)+length(sigma_x)-1);
for i=1:length(synd_x)-1
for j=1:length(sigma_x)
w1(i+j-1)=rs_add(w1(i+j-1),rs_mul(synd_x(i+1),sigma_x(j),m,alpha_to,index_of),m); %计算w(x)=s(x)*sigma(x)
end
end
w=w1(1:2*t);
s=zeros(1,length(sigma_x));
% differential coefficient of locator polynomial
for h=1:length(sigma_x) %计算sigma(x)的倒数
if mod(h,2)==0
s(h-1)=sigma_x(h);
end
end
s(length(sigma_x))=0;
for k=1:length(root)
w_final=rs_poly(w,root(k),m,alpha_to,index_of);
s_final=rs_poly(s,root(k),m,alpha_to,index_of);
% error value
value(k)=rs_mul(w_final,rs_rev(s_final,m,alpha_to,index_of),m,alpha_to,index_of); %相除
end
temp=[];
m_xo=[];
temp=r_x;
%%
%r-e=c完成纠错
for i=1:length(site)
temp(site(i)+1)=rs_add(r_x(site(i)+1),value(i),m);
end
m_xo=temp;
rs编译码matlab可用程序
5星 · 超过95%的资源 需积分: 17 116 浏览量
2013-07-08
16:06:21
上传
评论 9
收藏 10KB ZIP 举报
xidianzc
- 粉丝: 0
- 资源: 1
最新资源
- TIA PORTAL V19 UPD2更新包(2024.05最新).txt
- 1_提高高温超导体的临界温度的方法_pdf_1629817511660_6.jpg
- 1_提高高温超导体的临界温度的方法_pdf_1629817511859_7.jpg
- IMG_20240507_122805.jpg
- 1_提高高温超导体的临界温度的方法_pdf_1629817512307_9.jpg
- 用户故事示例导入模板(官网示例)
- 1_提高高温超导体的临界温度的方法_pdf_1629817510190_0.jpg
- Java实现计数排序算法(源代码)
- 这个 ide98 是适合老式机器上用到的一个补充文件,文件的过程代表过程的文件这个 ide98 是适合老式机器上用到的一个补充文
- 866164937784007CarLife3.0车机修改版支持无线和方控.apk
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
前往页