Berlekamp–Massey algorithm: Difference between revisions

Content deleted Content added
Slayt (talk | contribs)
No edit summary
Slayt (talk | contribs)
Line 93:
int[] c = new int[array.length];
int[] t = new int[array.length];
b[0] = 1;
c[0] = 1;
int n = 0;
int l = 0;
int m = -1;
for (n = 0; n < array.length; n++) {
int d = 0;
for (int i = 0; i <= l; i++) {
d = d ^ (c[i] * array[n - i]);
if (d==1) {}
if (d t=c.clone(= 1); {
fort (int= j=0;j<arrayc.length-n+m-1;j++clone() c[n-m+j]=c[n-m+j]^b[j];
iffor (l<int j = 0; j < array.length - n/2 + m - 1; j++) {
l=c[n - m +1 j] = c[n -l m + j] ^ b[j];
m=n;}
if (l <= n b=t.clone(/ 2); {
l = n + 1 - l;
m = n;
b = t.clone();
}
}
Line 114 ⟶ 118:
}
</source>
 
==See also==
* [[Reeds-Sloane algorithm]], an extension for sequences over integers mod ''n''