Berlekamp-Massey algorithm
Encyclopedia
The Berlekamp–Massey algorithm is an algorithm
Algorithm
In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning...

 that will find the shortest linear feedback shift register
Linear feedback shift register
A linear feedback shift register is a shift register whose input bit is a linear function of its previous state.The most commonly used linear function of single bits is XOR...

 (LFSR) for a given binary output sequence. The algorithm will also find the minimal polynomial of a linearly recurrent sequence
Recurrence relation
In mathematics, a recurrence relation is an equation that recursively defines a sequence, once one or more initial terms are given: each further term of the sequence is defined as a function of the preceding terms....

 in an arbitrary field
Field (mathematics)
In abstract algebra, a field is a commutative ring whose nonzero elements form a group under multiplication. As such it is an algebraic structure with notions of addition, subtraction, multiplication, and division, satisfying certain axioms...

.

Elwyn Berlekamp
Elwyn Berlekamp
Elwyn Ralph Berlekamp is an American mathematician. He is a professor emeritus of mathematics and EECS at the University of California, Berkeley. Berlekamp is known for his work in information theory and combinatorial game theory....

 invented an algorithm for decoding Bose–Chaudhuri–Hocquenghem (BCH) codes. James Massey
James Massey
James Lee Massey is an information theorist andcryptographer, Professor Emeritus of Digital Technology at ETH Zurich. His notable work...

 recognized its application to linear feedback shift registers and simplified the algorithm. Massey termed the algorithm the LFSR Synthesis Algorithm (Berlekamp Iterative Algorithm) , but it is now known as the Berlekamp–Massey algorithm.

Description of algorithm

Berlekamp Massey algorithm is an alternate method to solve the set of linear equations described in Reed Solomon Peterson decoder, which can be summarized as:


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:


or reversed:


The goal of the algorithm is to determine the minimal degree L and C(x) which results in:


for all syndromes, n = L to (N-1).

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:


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:


The xm 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:


This would change a recalculated discrepancy to:


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 algorithm will update B(x), b, increase L, and reset m = 1. The L = (n + 1 - L) formula limits L to the number of available syndromes used to calculate discrepancies, and also handles the case where L increases by more than 1.

The algorithm for the binary field

The following is the Berlekamp–Massey algorithm specialized for the typical binary finite field
Finite field
In abstract algebra, a finite field or Galois field is a field that contains a finite number of elements. Finite fields are important in number theory, algebraic geometry, Galois theory, cryptography, and coding theory...

 F2 and GF(2). The field elements are 0 and 1. The field operations + and − are identical and become the exclusive or operation, XOR. The multiplication operator * becomes the logical AND operation. The division operator reduces to the identity operation (i.e., field division is only defined for dividing by 1, and x/1 = x).
  1. Let be the bit
    Bit
    A bit is the basic unit of information in computing and telecommunications; it is the amount of information stored by a digital device or other physical system that exists in one of two possible distinct states...

    s of the stream.
  2. Initialise two arrays and each of length to be zeroes, except
  3. assign
    Assignment (computer science)
    In computer programming, an assignment statement sets or re-sets the value stored in the storage location denoted by a variable name. In most imperative computer programming languages, assignment statements are one of the basic statements...

     .
  4. For step 1 while :
    • Let be .
    • if , then is already a polynomial which annihilates the portion of the stream from to .
    • else:
      • Let be a copy of .
      • Set up to (where is the Exclusive or operator).
      • If , set , set , and let ; otherwise leave , and alone.


At the end of the algorithm, is the length of the minimal LFSR for the stream, and we have for all .

Code sample for the binary field in Java

The following code sample is for a binary field.


public static int runTest(int[] array) {
final int N = array.length;
int[] b = new int[N];
int[] c = new int[N];
int[] t = new int[N];
b[0] = 1;
c[0] = 1;
int l = 0;
int m = -1;
for (int n = 0; n < N; n++) {
int d = 0;
for (int i = 0; i <= l; i++) {
d ^= c[i] * array[n - i];
}
if (d 1) {
System.arraycopy(c, 0, t, 0, N);
int N_M = n − m;
for (int j = 0; j < N − N_M; j++) {
c[N_M + j] ^= b[j];
}
if (l <= n / 2) {
l = n + 1 - l;
m = n;
System.arraycopy(t, 0, b, 0, N);
}
}
}
return l;
}

Berlekamp–Massey algorithm for fields
The algorithm from .


polynomial(field K) s(x) = ... /* coeffs are s_j; output sequence as N-1 degree polynomial) */
/* connection polynomial */
polynomial(field K) C(x) = 1; /* coeffs are c_j */
polynomial(field K) B(x) = 1;
int L = 0;
int m = 1;
field K b = 1;
int n;
for (n = 0; n < N; n++)
{
/* calculate discrepancy */
field K d = s_n + \Sigma_{i=1}^L c_i * s_{n-i};
if (d 0)
{
/* annihilation continues */
m = m + 1;
}
else if (2 * L <= n)
{
/* temporary copy of C(x) */
polynomial(field K) T(x) = C(x);
C(x) = C(x) - d b^{-1} x^m B(x);
L = n + 1 - L;
B(x) = T(x);
b = d;
m = 1;
}
else
{
C(x) = C(x) - d b^{-1} x^m B(x);
m = m + 1;
}
}
return L;

See also

  • Reeds–Sloane algorithm, an extension for sequences over integers mod n
  • Berlekamp–Welch algorithm
    Berlekamp–Welch algorithm
    The Berlekamp–Welch algorithm, also known as the Welch–Berlekamp algorithm, is named for Elwyn R. Berlekamp and Lloyd R. Welch. The algorithm efficiently corrects errors in BCH codes and Reed–Solomon codes...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK