Content deleted Content added
→Code sample: specify for arbitrary field |
|||
(42 intermediate revisions by 28 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
|publisher=Aegean Park Press
|isbn= 978-0-89412-063-
|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
|last= Ben Atti▼
|
}}</ref><ref>{{Citation
|first1= Nadia
|last2= Diaz-Toca
|first2= Gema M.
Line 37 ⟶ 42:
|first3= Henri
|title= The Berlekamp–Massey Algorithm revisited
|journal= Applicable Algebra in Engineering, Communication and Computing
|id= {{citeseerx|10.1.1.96.2743}}▼
|date=April 2006 |volume=17 |issue=1 |pages=75–82
|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.▼
|url= http://hlombardi.free.fr/publis/ABMAvar.html
|doi= 10.1007/s00200-005-0190-z
|arxiv= 2211.11721
|s2cid= 14944277
▲
==Description of algorithm==
The Berlekamp–Massey algorithm is an
:<math> S_{i + \nu} + \Lambda_1 S_{i+\nu-1} + \cdots + \Lambda_{\nu-1} S_{i+1} + \Lambda_
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) =
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>
being equal to 0:
:<math>
Algorithm:
''C''(''x'') is initialized to 1, ''L'' is the current number of assumed errors, and initialized to zero. ''N'' is the total number of syndromes. ''n'' is used as the main iterator and to index the syndromes from 0 to
Each iteration of the algorithm calculates a discrepancy ''d''. At iteration ''k'' this would be:
:<math> d
If ''d'' is zero, the algorithm assumes that ''C''(''x'') and ''L'' are correct for the moment, increments ''m'', and continues.
If ''d'' is not zero, the algorithm adjusts ''C''(''x'') so that a recalculation of ''d'' would be zero:
:<math>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''
:<math> d
This would change a recalculated discrepancy to:
:<math> d = d - (d/b)b = d - d = 0.
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
==
The algorithm from {{Harvtxt|Massey|1969|p=124}} for an arbitrary field:
<!-- Notes: notation changes from Massey:
Massey Here
Line 94 ⟶ 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 164 ⟶ 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]
* {{
* [
{{DEFAULTSORT:Berlekamp-Massey Algorithm}}
[[Category:Error detection and correction]]
[[Category:Cryptanalytic algorithms]]
[[Category:Articles with example code]]
|