Berlekamp–Massey algorithm: Difference between revisions

Content deleted Content added
The algorithm for the binary field: changed variable names (capitalization) to match previous pseudocode
Code sample for the binary field in Java: changed variables to match pseudocode [again]
Line 160:
<source lang="java">
public class BerlekampMassey {
public static String findPolynomial(char[] sS) {
final int nN = sS.length;
char[] bB = new char[nN]; bB[0] = 1;
char[] cC = new char[nN]; cC[0] = 1;
char[] tT = new char[nN];
int L = 0, m = -1;
for (int Nn = 0; Nn < nN; Nn++) {
int d = sS[Nn];
for (int i = 1; i <= L; i++) d ^= (cC[i] & sS[Nn - i]);
if (d == 1) {
System.arraycopy(cC, 0, tT, 0, nN);
for (int diffi = N0, j = n - m; j < N; i++, j++) C[j] ^= B[i];
forif (int iL <= 0, j = diff; j < n; i++,/ j++2) c[j] ^= b[i];{
if ( L <= Nn /+ 2)1 {- L;
Lm = N + 1 - Ln;
mSystem.arraycopy(T, =0, B, 0, N);
System.arraycopy(t, 0, b, 0, n);
}
}
}
return stringify(cC, L);
}