# Inverting a generator matrix - Coding Theory

The general question I have is, once Ive been given a generator matrix $G$ for some linear $[n,k]_q$ code (or alternatively the parity check matrix $H$), How can I invert this in order to find the inverse? i.e.

$$G \rightsquigarrow H \text{ or } H \rightsquigarrow G$$

I understand that for $q=2$ we can rearange columns of $G$ to give the standard form $G=(I_n|A)$ which is easily manipulated to $H=(-A^T|I_n)$. However once $q>2$ I dont understand how to solve the question. Below is an example question given:

$$G= \begin{bmatrix} 1&1&1&0 \\ 2&0&1&1 \end{bmatrix}$$

Find the parity check matrix, $H$, in standard form.

• "I understand that for $q=2$ we can rearange columns of $G$ to give the standard form $G=(I_n|A)$", careful here. Rearranging the columns will not necessarily give you the same code that the original matrix does. You can only guarantee it will be an equivalent code. In this example matrix you say $q>2$. I assume the code is over $\mathbb F_q$, but the answer will depend on what $q$ is. Is it $3$? What you need to do is perform elementary operations on the rows of $G$ in order to get $I_2$ on the left most block. Can you do this? – Git Gud Jan 20 '18 at 0:47

What field are you in? In order for you to obtain a parity-check matrix of that particular code, tranform $G$ to its RREF form and you're there. I assume you already know what to do next after that.

The answer given in the the course was, for linear codes, row operations to $G$ will generate an equivalent code.

$$G= \begin{bmatrix} 1&1&1&0 \\ 2&0&1&1 \end{bmatrix}$$
$$G_{RREF}= \begin{bmatrix} 1&0&2&2 \\ 0&1&2&1 \end{bmatrix}$$
assuming that we are in $F_3$. This particular matrix is also a generator matrix for that code (i.e. its row space will still generate all codewords $c\in C$), as you have only performed row operations on $G$. Note that the above matrix is already in standard form. Thus, a parity check matrix for that code is given by
$$H= \begin{bmatrix} 1&1&1&0 \\ 1&2&0&1 \end{bmatrix}$$