Content deleted Content added
→Description of algorithm: Improve formatting. I still don't understand the explanation, but at least it uses minus signs and italic variable names consistently |
|||
(27 intermediate revisions by 20 users not shown) | |||
Line 1:
{{Short description|Algorithm on linear-feedback shift registers}}
{{distinguish|Berlekamp's algorithm}}
[[File:Berlekamp–Massey algorithm.png|thumb|right|Berlekamp–Massey algorithm]]
The '''Berlekamp–Massey algorithm''' is an [[algorithm]] that will find the shortest [[linear
[[Elwyn Berlekamp]] invented an algorithm for decoding [[BCH code|Bose–Chaudhuri–Hocquenghem (BCH) codes]].<ref>{{Citation
|last= Berlekamp
|first= Elwyn R.
|
|title= Nonbinary BCH decoding
|year= 1967
Line 12 ⟶ 14:
|last= Berlekamp
|first= Elwyn R.
|
|title=Algebraic Coding Theory
|place=Laguna Hills, CA
|
|year=1984
|edition= Revised
Line 22 ⟶ 24:
|first= J. L.
|last= Massey
|
|title= Shift-register synthesis and BCH decoding
|journal= IEEE
|volume= IT-15
|issue= 1
|
|pages= 122–127
|url= http://crypto.stanford.edu/~mironov/cs359/massey.pdf
|doi= 10.1109/TIT.1969.1054260 |s2cid= 9003708
}}</ref><ref>{{Citation
|
|
|last2= Diaz-Toca
|first2= Gema M.
Line 38 ⟶ 42:
|first3= Henri
|title= The Berlekamp–Massey Algorithm revisited
|journal= Applicable Algebra in Engineering, Communication and Computing
|date=April 2006 |volume=17 |issue=1 |pages=75–82
|citeseerx=10.1.1.96.2743
|url= http://hlombardi.free.fr/publis/ABMAvar.html
|doi= }}</ref> Massey termed the algorithm the LFSR Synthesis Algorithm (Berlekamp Iterative Algorithm),<ref>{{Harvnb|Massey|1969|p=124}}</ref> but it is now known as the Berlekamp–Massey algorithm.▼
|doi= 10.1007/s00200-005-0190-z
|arxiv= 2211.11721
|s2cid= 14944277
▲
==Description of algorithm==
Line 48 ⟶ 58:
In the code examples below, ''C''(''x'') is a potential instance of ''Λ''(''x''). The error locator polynomial ''C''(''x'') for ''L'' errors is defined as:
:<math> C(x) = C_L
or reversed:
:<math> C(x) = 1 + C_1
The goal of the algorithm is to determine the minimal degree ''L'' and ''C''(''x'') which results in all [[Decoding methods#Syndrome decoding|syndromes]]
:<math> S_n + C_1
being equal to 0:
:<math> S_n + C_1
Algorithm:
Line 64 ⟶ 74:
Each iteration of the algorithm calculates a discrepancy ''d''. At iteration ''k'' this would be:
:<math> d \gets S_k + C_1
If ''d'' is zero, the algorithm assumes that ''C''(''x'') and ''L'' are correct for the moment, increments ''m'', and continues.
Line 70 ⟶ 80:
If ''d'' is not zero, the algorithm adjusts ''C''(''x'') so that a recalculation of ''d'' would be zero:
:<math>C(x) \gets C(x)
The ''x<sup>m</sup>'' term ''shifts'' B(x) so it follows the syndromes corresponding to ''b''. If the previous update of ''L'' occurred on iteration ''j'', then ''m'' = ''k'' − ''j'', and a recalculated discrepancy would be:
:<math> d \gets S_k + C_1
This would change a recalculated discrepancy to:
Line 80 ⟶ 90:
:<math> d = d - (d/b)b = d - d = 0.</math>
The algorithm also needs to increase ''L'' (number of errors) as needed. If ''L'' equals the actual number of errors, then during the iteration process, the discrepancies will become zero before ''n'' becomes greater than or equal to 2''L''. Otherwise ''L'' is updated and the algorithm will update ''B''(''x''), ''b'', increase ''L'', and reset ''m'' = 1. The formula ''L'' = (''n'' + 1 − ''L'') limits ''L'' to the number of available syndromes used to calculate discrepancies, and also handles the case where ''L'' increases by more than 1.
==
The algorithm from {{Harvtxt|Massey|1969|p=124}} for an arbitrary field:
<!-- Notes: notation changes from Massey:
Massey Here
Line 95 ⟶ 104:
T(D) T(x) polynomial
-->
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr">
polynomial(field ''K'') s(x) = ... <span class="cm">/* coeffs are
<span class="cm">/* connection polynomial */</span>
polynomial(field K) C(x) = 1; <span class="cm">/* coeffs are
polynomial(field K) B(x) = 1;
int L = 0;
int m = 1;
field K b = 1;
int n;
<span class="cm">/* steps 2. and 6. */</span>▼
<span class="k">for</span> (n = 0; n < N; n++) {▼
▲ /* steps 2. and 6. */
<span class="cm">/* step 2. calculate discrepancy */</span>▼
▲ for (n = 0; n < N; n++)
field K d = s<sub>n</sub> + {{math|∑{{su|p=L|b=i=1}} c<sub>i</sub> s<sub>n - i</sub>}} <!--Σi=1Lci⋅sn−i;-->
▲ /* step 2. calculate discrepancy */
<span class="cm">/* step 3. discrepancy is zero; annihilation continues */</span>
} <span class="k">else</span> <span class="k">if</span> (2 * L <= n) {
{▼
<span class="cm">/* step
polynomial(field K) T(x) = C(x);▼
L = n + 1 - L;▼
} <span class="k">else</span> {
<span class="cm">/* step 4. */</span>▼
}
}▼
▲ else if (2 * L <= n)
<span class="k">return</span> L;
</div>
▲ /* step 5. */
▲ polynomial(field K) T(x) = C(x);
In the case of binary GF(2) BCH code, the discrepancy d will be zero on all odd steps, so a check can be added to avoid calculating it.
▲ C(x) = C(x) - d b^{-1} x^m B(x);
{{sxhl|2=c|1=<nowiki/>
▲ L = n + 1 - L;
/* ...
for (n = 0; n <
/* if odd step number, discrepancy == 0, no need to calculate it */
▲ m = 1;
if ((n&1) != 0) {
m = m + 1;
continue;
}
/* ...
}}
▲ /* step 4. */
▲ C(x) = C(x) - d b^{-1} x^m B(x);
▲ m = m + 1;
▲ }
==See also==
* [[Reed–Solomon error correction]]
* [[Reeds–Sloane algorithm]], an extension for sequences over integers mod ''n''
* [[Nonlinear-feedback shift register]] (NLFSR)
==References==
Line 165 ⟶ 162:
==External links==
* {{springer|title=Berlekamp-Massey algorithm|id=p/b120140}}
*
* {{MathWorld|urlname=Berlekamp-MasseyAlgorithm|title=Berlekamp–Massey Algorithm}}
* [https://code.google.com/p/lfsr/ GF(2) implementation in Mathematica]
* {{
* [https://berlekamp-massey-algorithm.appspot.com/ Online GF(2) Berlekamp-Massey calculator]
Line 174 ⟶ 171:
[[Category:Error detection and correction]]
[[Category:Cryptanalytic algorithms]]
[[Category:Articles with example code]]
|