Constructing parity check matrix for Hamming codes of given parameters

coding-theory

First things first, I'm not entirely sure if this question belongs here or stackoverflow so feel free to close if I was mistaken.

I'm having an introduction to linear and cyclic codes at my university and we're studying the properties of Hamming codes of any given parameter value. Our notation is $\text{Ham}(r,q)$ and we defined to be the code whose parity check matrix is obtained putting in columns a set of vectors $\{\underline{v}_1,\dots, \underline{v}_s\}$ such that they represent all the lines passing through $\underline{0}$ in $\mathbb F_q^{\:r}$.

Now, we saw as an example $\text{Ham}(r=3, q=2)$ whose bit parity check matrix has sizes $3\times 7$ and is built this way:

$$ H = \begin{bmatrix} 1 & 1 & 1 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 1 & 1 & 1 & 0 \\ 0 & 1 & 0 & 1 & 0 & 1 & 1 \end{bmatrix}$$

And then we're asked to build a parity check matrix for $\text{Ham}(r=3, q=3)$ whose parity check matrix has size $3\times 13$.

Now, if I have to make an observation the $H$ matrix above seems to be have been built setting the first element to $1$ and then letting the other two bits span in $\mathbb F_{q=2}$ until all the vectors in $\mathbb F_{q=2}^{\:3}$ starting with a one were generated, then repeated the process setting the first bit of the remaining columns to $0$ and the second to $1$, generated all the vectors in $\mathbb F_2^{\:3}$ starting with $(0,1)$ and so on.

My guess was that to solve the exercise I should generalize this idea, but I'd argue that the vectors in $H$'s columns would generate all the lines through the origin in $\mathbb F_3^{\:3}$ too since $H$ contains $Id\colon \mathbb F_3^{\:3}\mapsto\mathbb F_3^{\:3}$. Aim I wrong? If I am how would the actual generalization process go? (Hints appreciated).

Best Answer

Yep, you are right. Indeed a Hamming code is usually defined as a code where the columns of the parity check matrix are the coordinates of all the points of a projective space (which is what you have said but written in a rigurous way).

If for example we are working in $\mathbb{Z}_q$, a projective space of dimension $r$ is the set of all points $\left(x_1,...,x_r\right)\neq\left(0,\dots,0\right)$, with $x_i\in\lbrace 0,\dots,q-1\rbrace$ with respect to the equivalence relation $x\sim y$ iff there exists $\lambda\in\lbrace 1,\dots,q-1\rbrace$ such that $x=\lambda y$. Hence a Hamming code of dimension $r$ over $\mathbb{Z}_q$ has $\frac{q^r-1}{q-1}$ elements.

Therefore, if you have a code $\text{Ham}(r,q)$ its matrix will have size $\left(\frac{q^r-1}{q-1}\right)\times\left(\frac{q^r-1}{q-1}-r\right)$ and every colum will be a diferent point of the corresponding projective space.

Hope this answer your question.

Related Question