Code covered by the BSD License  

Highlights from
reed solomon code

reed solomon code

by

 

24 Dec 2010 (Updated )

everything about RS generation and generation polynomial and encoding and syndrome

[A,R]=BerMass(S,t,Y)
function [A,R]=BerMass(S,t,Y)
% Reed-Solomon decoder by Berlekamp-Massey Algorithm
A=[2 ones(1,2*t-1)];
B=[2 ones(1,2*t-1)];
S=fliplr(S);
r=1;
for r=1:2*t 
    L=0;
    r1 = 2*t-r+1;
    r2 = min(r1+t,2*t);
    num = r2-r1+1;
    Sa(1:num) = S(r1:r2);
    delta=1;
    for j=1:num
        delta=add(mult(A(j),Sa(j),Y),delta,Y);
    end
    if delta==1
        dalta=1;
    else
        if 2*L<=r-1
            dalta=2;
            L=r-L-2;
        else 
            dalta=1;
        end
    end   
 I=invv(delta,Y);
 if delta==1
   mat=[2,1;1,dalta];
   else
     mat=[2,delta;mult(I,dalta,Y),dalta-1];
 end
 AB=[A;B];
for i=1:2:4*t
 A0(i)=mult(mat(1),AB(i),Y);
 B0(i)=mult(mat(2),AB(i),Y);
end
for k=2:2:4*t
A1(k)=mult(mat(3),AB(k),Y);
B1(k)=mult(mat(4),AB(k),Y);
end
for l=2:2:4*t-2
    A(l)=add(A1(l),A0(l+1),Y);
    B(l)=add(B1(l),B0(l+1),Y);
end
A=[A0(1) A(2:2:4*t-2)];
B=[B0(1) B(2:2:4*t-2)];
end
  for m=2:2^(size(Y,2))
    M=powmult(m,A,Y);
        synd=2;
        for j=2:length(A)   
           synd = add(mult(A(j),M(j),Y),synd,Y);
            if synd==1
               temp=m;
               X(temp)=temp;
               IND=find(X>0);
               R=X(IND); 
            end 
        end       
    end

Contact us