- galois.parity_check_to_generator_matrix(H: FieldArray) FieldArray
Converts the parity-check matrix \(\mathbf{H}\) of a linear \([n, k]\) code into its generator matrix \(\mathbf{G}\).
The generator and parity-check matrices satisfy the equations \(\mathbf{G}\mathbf{H}^T = \mathbf{0}\).
- Parameters¶
- H: FieldArray¶
The \((n-k, n)\) parity-check matrix \(\mathbf{G}\) in systematic form \(\mathbf{H} = [-\mathbf{P}_{k,n-k}^T\ |\ \mathbf{I}_{n-k,n-k}]\).
- Returns¶
The \((k, n)\) generator matrix \(\mathbf{G} = [\mathbf{I}_{k,k}\ |\ \mathbf{P}_{k,n-k}]\).
Examples¶
In [1]: g = galois.primitive_poly(2, 3); g Out[1]: Poly(x^3 + x + 1, GF(2)) In [2]: G = galois.poly_to_generator_matrix(7, g); G Out[2]: GF([[1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 0, 1, 1, 1], [0, 0, 1, 0, 1, 1, 0], [0, 0, 0, 1, 0, 1, 1]], order=2) In [3]: H = galois.generator_to_parity_check_matrix(G); H Out[3]: GF([[1, 1, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 1]], order=2) In [4]: G2 = galois.parity_check_to_generator_matrix(H); G2 Out[4]: GF([[1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 0, 1, 1, 1], [0, 0, 1, 0, 1, 1, 0], [0, 0, 0, 1, 0, 1, 1]], order=2) In [5]: G2 @ H.T Out[5]: GF([[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]], order=2)