galois.bch_generator_matrix¶
- class galois.bch_generator_matrix(n, k, c=1, primitive_poly=None, primitive_element=None, systematic=True)¶
Returns the generator matrix for the primitive binary \(\textrm{BCH}(n, k)\) code.
- 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)
.systematic (bool, optional) – Optionally specify if the encoding should be systematic, meaning the codeword is the message with parity appended. The default is
True
.
- Returns
The \((n, k)\) generator matrix \(G\), such that given a message \(m\), a codeword is defined by \(c = mG\).
- Return type
Examples
In [1]: galois.bch_generator_matrix(15, 7) Out[1]: GF([[1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1], [0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1]], order=2) In [2]: galois.bch_generator_matrix(15, 7, systematic=False) Out[2]: GF([[1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1]], order=2)