galois.generator_to_parity_check_matrix(G: FieldArray) FieldArray

Converts the generator matrix G of a linear [n,k] code into its parity-check matrix H.

The generator and parity-check matrices satisfy the equations GHT=0.

Parameters
G: FieldArray

The (k,n) generator matrix G in systematic form G=[Ik,k | Pk,nk].

Returns

The (nk,n) parity-check matrix H=[Pk,nkT | Ink,nk].

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]: G @ H.T
Out[4]: 
GF([[0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]], order=2)