Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Berlekamp–Massey algorithm
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{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-feedback shift register]] (LFSR) for a given binary output sequence. The algorithm will also find the [[Minimal polynomial (field theory)|minimal polynomial]] of a linearly [[Recurrence relation|recurrent sequence]] in an arbitrary [[field (mathematics)|field]]. The field requirement means that the Berlekamp–Massey algorithm requires all non-zero elements to have a multiplicative inverse.<ref>{{Harvnb|Reeds|Sloane|1985|p=2}}</ref> Reeds and Sloane offer an extension to handle a [[ring (mathematics)|ring]].<ref>{{Citation |last1=Reeds |first1=J. A. |last2=Sloane |first2=N. J. A. |author-link2=N. J. A. Sloane |journal=SIAM Journal on Computing |volume=14 |issue=3 |pages=505–513 |year=1985 |title=Shift-Register Synthesis (Modulo n) |url=http://neilsloane.com/doc/Me111.pdf |doi=10.1137/0214038 |citeseerx=10.1.1.48.4652 }}</ref> [[Elwyn Berlekamp]] invented an algorithm for decoding [[BCH code|Bose–Chaudhuri–Hocquenghem (BCH) codes]].<ref>{{Citation |last= Berlekamp |first= Elwyn R. |author-link= Elwyn Berlekamp |title= Nonbinary BCH decoding |year= 1967 |series= International Symposium on Information Theory |place= San Remo, Italy}}</ref><ref>{{Citation |last= Berlekamp |first= Elwyn R. |author-link= Elwyn Berlekamp |title=Algebraic Coding Theory |place=Laguna Hills, CA |orig-year=1968 |year=1984 |edition= Revised |publisher=Aegean Park Press |isbn= 978-0-89412-063-3}}. Previous publisher McGraw-Hill, New York, NY.</ref> [[James Massey]] recognized its application to linear feedback shift registers and simplified the algorithm.<ref>{{Citation |first= J. L. |last= Massey |author-link= James Massey |title= Shift-register synthesis and BCH decoding |journal= IEEE Transactions on Information Theory |volume= IT-15 |issue= 1 |date= January 1969 |pages= 122–127 |url= http://crypto.stanford.edu/~mironov/cs359/massey.pdf |doi= 10.1109/TIT.1969.1054260 |s2cid= 9003708 }}</ref><ref>{{Citation |last1= Ben Atti |first1= Nadia |last2= Diaz-Toca |first2= Gema M. |last3= Lombardi |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= 10.1007/s00200-005-0190-z |arxiv= 2211.11721 |s2cid= 14944277 }}</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. ==Description of algorithm== The Berlekamp–Massey algorithm is an alternative to the [[Reed–Solomon error correction#Peterson–Gorenstein–Zierler decoder|Reed–Solomon Peterson decoder]] for solving the set of linear equations. It can be summarized as finding the coefficients Λ<sub>''j''</sub> of a polynomial Λ(''x'') so that for all positions ''i'' in an input stream ''S'': :<math> S_{i + \nu} + \Lambda_1 S_{i+\nu-1} + \cdots + \Lambda_{\nu-1} S_{i+1} + \Lambda_\nu S_i = 0. </math> 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 x^L + C_{L-1} x^{L-1} + \cdots + C_2 x^2 + C_1 x + 1 </math> or reversed: :<math> C(x) = 1 + C_1 x + C_2 x^2 + \cdots + C_{L-1} x^{L-1} + C_L x^L. </math> 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 S_{n-1} + \cdots + C_L S_{n-L}</math> being equal to 0: :<math> S_n + C_1 S_{n-1} + \cdots + C_L S_{n-L} = 0,\qquad L\le n\le N-1.</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 ''N''−1. ''B''(''x'') is a copy of the last ''C''(''x'') since ''L'' was updated and initialized to 1. ''b'' is a copy of the last discrepancy ''d'' (explained below) since ''L'' was updated and initialized to 1. ''m'' is the number of iterations since ''L'', ''B''(''x''), and ''b'' were updated and initialized to 1. Each iteration of the algorithm calculates a discrepancy ''d''. At iteration ''k'' this would be: :<math> d \gets S_k + C_1 S_{k-1} + \cdots + C_L S_{k-L}.</math> 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) \gets C(x) - (d / b) x^m B(x).</math> 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 S_{k-1} + \cdots - (d/b) (S_j + B_1 S_{j-1} + \cdots ).</math> This would change a recalculated discrepancy to: :<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. == Pseudocode == The algorithm from {{Harvtxt|Massey|1969|p=124}} for an arbitrary field: <!-- Notes: notation changes from Massey: Massey Here N n count 0 to n-1 x m count D x formal variable B(D) B(x) polynomial C(D) C(x) polynomial 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 s<sub>j</sub>; output sequence as N-1 degree polynomial) */</span> <span class="cm">/* connection polynomial */</span> polynomial(field K) C(x) = 1; <span class="cm">/* coeffs are c<sub>j</sub> */</span> 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++) { <span class="cm">/* step 2. calculate discrepancy */</span> 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;--> <span class="k">if</span> (d == 0) { <span class="cm">/* step 3. discrepancy is zero; annihilation continues */</span> m = m + 1; } <span class="k">else</span> <span class="k">if</span> (2 * L <= n) { <span class="cm">/* step 5. */</span> <span class="cm">/* temporary copy of C(x) */</span> polynomial(field K) T(x) = C(x); C(x) = C(x) - d b<sup>−1</sup> x<sup>m</sup> B(x); L = n + 1 - L; B(x) = T(x); b = d; m = 1; } <span class="k">else</span> { <span class="cm">/* step 4. */</span> C(x) = C(x) - d b<sup>−1</sup> x<sup>m</sup> B(x); m = m + 1; } } <span class="k">return</span> L; </div> 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. {{sxhl|2=c|1=<nowiki/> /* ... */ for (n = 0; n < N; n++) { /* if odd step number, discrepancy == 0, no need to calculate it */ if ((n&1) != 0) { m = m + 1; continue; } /* ... */ }} ==See also== * [[Reed–Solomon error correction]] * [[Reeds–Sloane algorithm]], an extension for sequences over integers mod ''n'' * [[Nonlinear-feedback shift register]] (NLFSR) ==References== {{reflist}} ==External links== * {{springer|title=Berlekamp-Massey algorithm|id=p/b120140}} * {{PlanetMath|BerlekampMasseyAlgorithm|Berlekamp–Massey algorithm}} * {{MathWorld|urlname=Berlekamp-MasseyAlgorithm|title=Berlekamp–Massey Algorithm}} * [https://code.google.com/p/lfsr/ GF(2) implementation in Mathematica] * {{in lang|de}} [http://www.informationsuebertragung.ch/indexAlgorithmen.html Applet Berlekamp–Massey algorithm] * [https://berlekamp-massey-algorithm.appspot.com/ Online GF(2) Berlekamp-Massey calculator] {{DEFAULTSORT:Berlekamp-Massey Algorithm}} [[Category:Error detection and correction]] [[Category:Cryptanalytic algorithms]] [[Category:Articles with example code]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Citation
(
edit
)
Template:Distinguish
(
edit
)
Template:Harvnb
(
edit
)
Template:Harvtxt
(
edit
)
Template:In lang
(
edit
)
Template:Math
(
edit
)
Template:MathWorld
(
edit
)
Template:PlanetMath
(
edit
)
Template:Reflist
(
edit
)
Template:SfnRef
(
edit
)
Template:Short description
(
edit
)
Template:Springer
(
edit
)
Template:Sxhl
(
edit
)