📄 bch_decode_berlekamp.m.txt
字号:
function errpos=BCH_decode_berlekamp(R,N,K,T)
%received vector R
% Caculate the S2t syndrome values.
S=-1*ones(1,2*T);
for i=1:2*T
S(i)=GF_polyeval(R,i);
end
% Solving the system of equations using Berlekamp Massey Algorithm
%disp("Syndrome Vector")
S(1:2*T);
S=[-1 S];
one_Sx = [0 S(2:end)];
iK=[0]; %Iteration Count?
iLambda={0}; %Matrix of polynomials,
iT={0}; %Matrix of polynomials,
iDelta=[S(2)]; %Delta is coefficient of x^(2*K +1) in the polynomial
% disp("Entering Evaluator........");
for k=1:T
%Lambda(2k+2)(x) = Lambda(2k)(x) + Delta(2k)*[x*T(2k)(x)]
u=GF_product([-1 0],iT{k},iDelta(k));
t=[ iLambda{k} -1*ones(1,length(u)-length(iLambda{k}))];
v=-1*ones(1,length(t));
for i=1:length(v)
v(i)=GF_add(t(i),u(i));
end
iLambda{k+1}=v;
%calculate T,
if iDelta(k) == -1
iT{k+1}= GF_product([-1 -1 0],iT{k});
else
v= GF_product([-1 0],iLambda{k});
delinv=GF_complement(iDelta(k));
u=-1*ones(1,length(v));
for i=1:length(v)
u(i)=GF_mul(v(i),delinv);
end
iT{k+1}=u;
end
iT{k+1};
%Delta is coefficient of x^(2*K +1) in the polynomial product (Lambda_2k(X))*(1+S(x))
%
% if (GF_polydegree(local_poly)<(2*k+2))
% iDelta(k)= -1;
% else
%disp('Polynomial')
one_Sx;
iLambda{k+1};
local_poly=GF_product(iLambda{k+1},one_Sx);
iDelta(k+1)=local_poly(2*k+2); %Coefficient of x^2k+1 is located at index 2k+2
% fgets(stdin);
%disp("Iteration ************************************************");
%disp("Lambda(k+1)");
%iLambda{k+1};
%disp("T(k+1)");
%iT{k+1};
%disp("Delta(k+1)");
%iDelta(k+1);
% fgets(stdin)
end
iLambda{T+1};
% Find the roots of Lambda
% disp("Error Polynomial");
ErrorPoly=iLambda{T+1};
% disp("Roots")
errpos=GF_roots(ErrorPoly);
% one_Sx;
% iLambda;
% iDelta;
% iT;
% iK;
return
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -