galois.bch_generator_poly¶
- class galois.bch_generator_poly(n, k, c=1, primitive_poly=None, primitive_element=None)¶
Returns the generator polynomial for the primitive binary \(\textrm{BCH}(n, k)\) code.
The BCH generator polynomial \(g(x)\) is defined as \(g(x) = \textrm{LCM}(m_{c}(x), m_{c+1}(x), \dots, m_{c+2t-2}(x))\), where \(m_c(x)\) is the minimal polynomial of \(\alpha^c\) where \(\alpha\) is a primitive element of \(\mathrm{GF}(2^m)\). If \(c = 1\), then the code is said to be narrow-sense.
- Parameters
n (int) – The codeword size \(n\), must be \(n = 2^m - 1\).
k (int) – The message size \(k\).
c (int, optional) – The first consecutive power of \(\alpha\). The default is 1.
primitive_poly (galois.Poly, optional) – Optionally specify the primitive polynomial that defines the extension field \(\mathrm{GF}(2^m)\). The default is
None
which uses the lexicographically-smallest primitive polynomial, i.e.galois.primitive_poly(2, m, method="smallest")
. The use of the lexicographically-smallest primitive polynomial, as opposed to a Conway polynomial, is most common for the default in textbooks, Matlab, and Octave.primitive_element (int, galois.Poly, optional) – Optionally specify the primitive element \(\alpha\) whose powers are roots of the generator polynomial \(g(x)\). The default is
None
which uses the lexicographically-smallest primitive element in \(\mathrm{GF}(2^m)\), i.e.galois.primitive_element(2, m)
.
- Returns
The generator polynomial \(g(x)\).
- Return type
- Raises
ValueError – If the \(\textrm{BCH}(n, k)\) code does not exist.
Examples
In [1]: g = galois.bch_generator_poly(15, 7); g Out[1]: Poly(x^8 + x^7 + x^6 + x^4 + 1, GF(2))