3 The Many Decoding Algorithms for Reed – Solomon Codes
3.5 The Berlekamp–Massey algorithm
The Berlekamp–Massey algorithm inverts a Toeplitz system of equations, in any field F, of the form
The Berlekamp–Massey algorithm is formally valid in any field, but it may suffer from problems of numerical precision in the real field or the complex field. The computational problem it solves is the same problem solved by the Sugiyama algorithm.
The Berlekamp–Massey algorithm can be described as a fast algorithm for finding a linear recursion, of shortest length, of the form
Ej = −ν
k=1
kE(( j−k)) j= ν, . . . , 2t − 1.
This is the shortest linear recursion that produces Eν,. . . , E2t−1from E0,. . . , Eν−1. This formulation of the problem statement is actually stronger than the problem of solving the matrix equation because the matrix equation may have no solution. If the matrix equation has a solution, then a minimum-length linear recursion of this form exists, and the Berlekamp–Massey will find it. If the matrix equation has no solution, then the Berlekamp–Massey algorithm finds a linear recursion of minimum length, but with ν > t, that produces the sequence. Thus the Berlekamp–Massey algorithm actually provides more than was initially asked for. It always computes the linear complexity L=L(E0,. . . , E2t−1) and a corresponding shortest linear recursion that will produce the given sequence.
The Berlekamp–Massey algorithm, shown in Figure3.1, is an iterative procedure for finding a shortest cyclic recursion for producing the initial r terms, E0, E1,. . . , Er−1, of the sequence E. At the rth step, the algorithm has already computed the linear recursions((i)(x), Li) for all i smaller than r. These are the linear recursions that, for each i, produce the first i terms of the sequence E. Thus for each i= 0, . . . , r − 1, we have already found the linear recursion
Ej = −
Li
k=1
(i)k Ej−k j= Li,. . . , i
for each i smaller than r. Then for i= r, the algorithm finds a shortest linear recursion that produces all the terms of the sequence E. That is, it finds the linear recursion ((r)(x), Lr) such that
Ej = −
Lr
k=1
(r)k Ej−k j= Lr,. . . , r.
The rth step of the algorithm begins with a shortest linear recursion, ((r−1)(x), Lr−1), that produces the truncated sequence Er−1 = E0, E1,. . . , Er−1. Define
δr = Er−
⎛
⎝−Lr−1
k=1
(r−1)k Er−k
⎞
⎠
=
Lr−1
k=0
(r−1)k Er−k
157 3.5 The Berlekamp–Massey algorithm
Initialize
(x) = B(x) = 1
No ∆ = 0 Yes
?
?
L = r = 0
2L ≤ r – 1
r ← r+1
r = 2t Yes No
Halt
d = 0 d = 1
L ← r – L
(x) B (x)
(x) B (x) –∆x
(1 – d)x I
∆–1d
n –1
j = 0
Σ
∆ = j Er – j
Figure 3.1. Berlekamp–Massey algorithm.
as the discrepancy in the output of the recursion at the rth iteration. The discrepancyδr
need not be zero. Ifδris zero, the output of the recursion is the desired field element.
It is then trivial to specify the next linear recursion. It is the same linear recursion as found in the previous iteration. In this case, set
((r)(x), Lr) = ((r−1)(x), Lr−1)
as a shortest linear recursion that produces the truncated sequence Er, and the iteration is complete. In general, however,δrwill be nonzero. Then
((r)(x), Lr) = ((r−1)(x), Lr−1).
To see how(r−1)(x) must be revised to get (r)(x), choose an earlier iteration count m, smaller than r, such that
Lm−1
By translating indices so that j+ m − r replaces j and then scaling, this becomes δr
where δm is nonzero and Ej is regarded as zero for j negative. This suggests the polynomial update second sum equalsδm. Therefore
Lr
and the new polynomial(r)(x) provides a new linear recursion that produces one more symbol than the previous linear recursion.
To ensure that the recursion is a minimum-length recursion, we need to place an additional condition on the choice of(m−1)(x). Until now, we only required that m be chosen so thatδm= 0. Now we will further require that m be the most recent index such that Lm> Lm−1. This requirement implies the earlier requirement thatδm= 0, so that condition need not be checked. The following theorem shows that this last condition ensures that the new recursion will be of minimum length. By continuing this process for 2t iterations, the desired recursion is found.
159 3.5 The Berlekamp–Massey algorithm
Theorem 3.5.1 (Berlekamp–Massey) Suppose thatL(E0, E1,. . . , Er−2) = L. If the recursion ((x), L) produces E0, E1,. . . , Er−2, but ((x), L) does not produce E0, E1,. . . , Er−1, thenL(E0, E1,. . . , Er−1) = max[L, r − L].
Proof: Let E(r)= E0, E1,. . . , Er−1. Massey’s theorem states that L(E(r)) ≥ max[L, r − L].
Thus it suffices to prove that L(E(r)) ≤ max[L, r − L].
Case (1) E(r) = (0, 0, . . . , 0, Er−1 = 0). The theorem is immediate in this case because a linear shift register of length zero produces E(r−1)= (0, 0, . . . , 0), while a linear shift register of length r is needed to produce E(r) = (0, 0, . . . , 0, Er−1).
Case (2) E(r−1) = (0, 0, . . . , 0). The proof is by induction. Let m be such that L(E(m−1)) < L(E(m)) = L(E(r−1)). The induction hypothesis is that L(E(m)) = max[Lm−1, m− Lm−1]. By the construction described prior to the theorem,
L(E(r)) ≤ max[L, Lm−1+ r − m].
Consequently,
L(E(r)) ≤ max[L(E(r−1)), r −L(E(r−1))]
= max[L, r − L],
which proves the theorem.
Corollary 3.5.2 (Berlekamp–Massey algorithm) In any field, let S1,. . . , S2t be given. Under the initial conditions(0)(x) = 1, B(0)(x) = 1, and L0 = 0, let the following set of equations be used iteratively to compute(2t)(x):
δr=
Lr−1
j=0
(r−1)j Sr−j,
Lr= r(r − Lr−1) + (1 − r)Lr−1,
(r)(x) B(r)(x)
=
1 −δrx δ−1r r (1 − r)x
(r−1)(x) B(r−1)(x)
,
r = 1, . . . , 2t, where r= 1 if both δr= 0 and 2Lr−1 ≤ r − 1, and otherwise r= 0.
Then(2t)(x) is the polynomial of smallest degree with the properties that (2t)0 = 1,
and
Sr+
Lr−1
j=1
(2t)j Sr−j= 0 r = L2t,. . . , 2t − 1.
The compact matrix formulation given in the corollary includes the term δr−1r. Becauseδrcan be zero only whenris zero, the termδr−1ris then understood to be zero. The Berlekamp–Massey algorithm, as shown in Figure3.1, saves the polynomial
(x) whenever there is a length change as the “interior polynomial” B(x). This B(x) will play the role of(m−1)(x) when it is needed in a later iteration. In Corollary3.5.2, the interior polynomial B(x) is equal to δm−1xr−m(m)(x). When r = 1, B(x) is replaced by(x), appropriately scaled, and when r= 0 it is multiplied by x to account for the increase in r.
Note that the matrix update requires at most 2t multiplications per iteration, and the calculation ofδr requires no more than t multiplications per iteration. There are 2t iterations and hence at most 6t2 multiplications. Thus using the algorithm will usually be much better than using a matrix inversion, which requires on the order of t3 multiplications.
The Berlekamp–Massey algorithm is formally valid in any field. However, the deci-sion to branch is based on whether or notδrequals zero, so in the real field the algorithm is sensitive to problems of computational precision.
A simple example of the iterations of the Berlekamp–Massey algorithm in the rational field is shown in Table 3.2. In this example, the algorithm computes the shortest recursion that will produce the sequence 1, 1, 0, 1, 0, 0 in the rational field.
A second example of the iterations of the Berlekamp–Massey algorithm in the field GF(16) is shown in Table3.3. In this example, the algorithm computes the shortest recursion that will compute the sequenceα12, 1,α14,α13, 1,α11 in the field GF(16).
This is the sequence of syndromes for the example of the (15, 9, 7) Reed–Solomon code, using the same error pattern that was studied earlier in Section3.1. As before, the senseword is the all-zero codeword, andα is the primitive element of GF(16) that satisfiesα4= α + 1.
Now we turn to the final task of this section, which is to exploit the structure of the Berlekamp–Massey algorithm to improve the Forney formula by eliminating the need to compute(x).
Corollary 3.5.3 (Horiguchi–Koetter) Suppose(x) has degree ν. The components of the error vector e satisfy
ei=
⎧⎨
⎩
0 if(ω−i) = 0 ω−i(ν−1)
ω−iB(ω−i)(ω−i) if(ω−i) = 0,
161 3.5 The Berlekamp–Massey algorithm
Table 3.2. Example of Berlekamp–Massey algorithm for a sequence of rationals S0= 1
S1= 1 S2= 0 S3= 1 S4= 0 S5= 0
r δr B(x) (x) L
0 1 1 0
1 1 1 1− x 1
2 0 x 1− x 1
3 −1 −1 + x 1− x + x2 2
4 2 −x + x2 1+ x − x2 2
5 1 1+ x − x2 1+ x − x3 3
6 0 x+ x2− x3 1+ x − x3 3
(x) = 1 + x − x3
Table 3.3. Example of Berlekamp–Massey algorithm for a Reed–Solomon (15, 9, 7) code
g(x) = x6+ α10x5+ α14x4+ α4x3+ α6x2+ α9x+ α6 v(x) = αx7+ α5x5+ α11x2 = e(x)
S1= αα7+ α5α5+ α11α2= α12 S2= αα14+ α5α10+ α11α4= 1 S3= αα21+ α5α15+ α11α6= α14 S4= αα28+ α5α20+ α11α8= α13 S5= αα35+ α5α25+ α11α10= 1 S6= αα42+ α5α30+ α11α12= α11
r δr B(x) (x) L
0 1 1 0
1 α12 α3 1+ α12x 1
2 α7 α3x 1+ α3x 1
3 1 1+ α3x 1+ α3x+ α3x2 2
4 1 x+ α3x2 1+ α14x 2
5 α11 α4+ α3x 1+ α14x+ α11x2+ α14x3 3 6 0 α4x+ α3x2 1+ α14x+ α11x2+ α14x3 3
(x) = 1 + α14x+ α11x2+ α14x3
= (1 + α7x)(1 + α5x)(1 + α2x)
where B(x) is the interior polynomial computed by the Berlekamp–Massey algorithm.
Proof: The actual number of errors isν, the degree of (x). Define the modified error vector˜e by the components ˜ei = eiB(ω−i). To prove the corollary, we will first show that B(ω−i) is nonzero everywhere that ei is nonzero. Then we will apply the Forney formula to the modified error vector˜e, and finally divide out B(ω−i).
The iteration equation of the Berlekamp–Massey algorithm can be inverted as follows:
(1 − r)x δrx
−δ−1r r 1
(r)(x) B(r)(x)
= x
(r−1)(x) B(r−1)(x)
.
If(r)(x) and B(r)(x) have a common factor other than x, then (r−1)(x) and B(r−1)(x) have that factor also. Hence by induction,(0)(x) and B(0)(x) also have that same factor.
Because(r)(x) does not have x as a factor, and because (0)(x) = B(0)(x) = 1, there is no common factor. Therefore
GCD[(x), B(x)] = 1.
Because (x) and B(x) are coprime, they can have no common zero. This means that the modified error component˜ei is nonzero if and only if error component ei is nonzero. Consequently,(x) is also the error-locator polynomial for the modified error vector˜e. For the modified error vector, the syndromes are
Sj=
n−1
i=0
eiB(ω−i)ωij j= 0, . . . , 2t − 1
=
n−1
k=0
BkSj−k
=
0 j< ν − 1 1 j= ν − 1
where the second line is a consequence of the convolution theorem, and the third line is a consequence of the structure of the Berlekamp–Massey algorithm. Thus S(x) = xν−1. The modified error-evaluator polynomial for the modified error vector is given by
(x) = (x)S(x) (mod xν)
= xν−1.
163 3.6 Decoding of binary BCH codes
The Forney algorithm, now applied to the modified error vector, yields
˜ei = − (ω−i) ω−i(ω−i),
from which the conclusion of the corollary follows.