Content deleted Content added
m convert special characters found by Wikipedia:Typo Team/moss (via WP:JWB) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1:
{{Short description|Algorithm on linear-feedback shift registers}}
{{distinguish|Berlekamp's algorithm}}
[[File:
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>
Line 95:
The algorithm from {{Harvtxt|Massey|1969|p=124}} for an arbitrary field:
<!-- Notes: notation changes from Massey:
Massey Here
Line 105 ⟶ 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 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;
Line 114 ⟶ 113:
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>
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>
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++) {
Line 150:
}
/* ... */
}}
==See also==
Line 161 ⟶ 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]
|