www.pudn.com > matlab.rar > rs_decode_forney.m, change:2015-04-15,size:2479b


% a function to calculate evaluator polynomial using forney arithmetic 
% according to syndrome polynomial & locator polynomial & roots of  
%locator polynomial 
function [value,site]=rs_decode_forney(synd_x,sigma_x,root) 
T=[ 1     2     4     8    16    32    64   128    29    58   116   232   205   135    19    38    76   152    45    90   180   117   234   201   143     3     6    12    24    48    96   192   157    39   78   156    37    74   148    53   106   212   181   119   238   193   159    35    70   140     5   10    20    40    80   160    93   186   105   210   185   111   222   161    95   190    97   194  153    47    94   188   101   202   137    15    30    60   120   240   253   231   211   187   107   214   177   127   254   225   223   163    91   182   113   226   217   175    67   134    17    34  68   136    13    26    52   104   208   189   103   206   129    31    62   124   248   237   199   147    59   118   236   197   151    51   102   204   133    23    46    92   184   109   218   169  79   158    33    66   132    21    42    84   168    77   154    41    82   164    85   170    73   146    57   114   228   213   183   115   230   209   191    99   198   145    63   126   252   229  215   179   123   246   241   255   227   219   171    75   150    49    98   196   149    55   110    220   165    87   174    65   130    25    50   100   200   141     7    14    28    56   112   224  221   167    83   166    81   162    89   178   121   242   249   239   195   155    43    86   172    69   138     9    18    36    72   144    61   122   244   245   247   243   251   235   203   139  11    22    44    88   176   125   250   233   207   131    27    54   108   216   173    71   142]; 
% vector of evaluator polynomial 
w1=zeros(1,length(synd_x)+length(sigma_x)-1); 
% 't' is the max number of errors 
t=16;site=[]; 
% calculate the value of w(j) 
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))); 
    end 
end 
% evaluator polynomial 
w=w1(1:2*t); 
s=zeros(1,length(sigma_x)); 
% differential coefficient of locator polynomial 
for h=1:length(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)); 
    s_final=rs_poly(s,root(k)); 
    % error value 
    value(k)=rs_mul(w_final,rs_rev(s_final)); 
   site(k)=mod((255-(find(T==root(k))-1)),255); 
end