In a linear binary code, the set C of codewords is a vector space over GF(2).
In such a code, there is a matrix H, called the check matrix, such that C is the null space of H. When the Receiver receives the vector <math>\tilde{c}</math> , she can check whether the received vector is a codeword by multiplying it by H and checking whether the resulting vector (called the error syndrome) is the zero vector.
The vector space C can be specified:
The generator matrix for a linear code is a matrix G whose columns are generators for the set C of codewords. (It is traditional to define the generator matrix so that its rows are generators for C).
By the linear-combinations definition of matrix-vector multiplication, every matrix-vector product G p is a linear combination of the columns of G, and is therefore a codeword.
drives, flash memory, CDs, and DVDs
Hamming code is a linear binary block code:
To protect an 4-bit block:
C = set of permitted codewords
The 7-bit encodings are called codewords in the block code
Hamming discovered a code in which a four-bit message is represented by a seven-bit codeword. The generator matrix is: <MATH> G = \begin{bmatrix} 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 0 & 0 & 0 & 1 \\ 1 & 1 & 1 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \end{bmatrix} </MATH> A four-bit message is represented by a 4-vector p over GF(2). The encoding of p is the 7-vector resulting from the matrix-vector product G*p.
Let <math>f_G</math> be the encoding function, the function dened by <math>f_G(x) = G*p</math> The image of <math>f_G</math> , the set of all codewords, is the row space of <math>G</math> .
Four of the rows of G are the standard basis vectors e1, e2, e3, e4 of GF(2). It implies that the words are in the codewords.
<MATH> R = \begin{bmatrix} 0 & 0 & 0 & 0 & 0 & 0 & 1\\ 0 & 0 & 0 & 0 & 0 & 1& 0 \\ 0 & 0 & 0 & 0 & 1& 0 & 0 \\ 0 & 0 & 1& 0 & 0 & 0 & 0 \end{bmatrix} </MATH>
The matrix-matrix product RG should be the identity matrix
The codeword <math>c</math> is send across a noisy channel and the vector received is <math>\tilde{c}</math> . The following formula reflect the fact that <math>\tilde{c}</math> might differ from <math>c</math> : <MATH>c = \tilde{c} + e</MATH> where:
If we can figure out the error vector <math>e</math> , we can recover the codeword <math>c</math> and therefore the original message.
To figure out the error vector <math>e</math> , a check matrix is used, which for the Hamming code is:
<MATH> H = \begin{bmatrix} 0 & 0 & 0 & 1 & 1 & 1 & 1\\ 0 & 1 & 1 & 0 & 0 & 1& 1 \\ 1 & 0 & 1 & 0 & 1& 0 & 1 \end{bmatrix} </MATH>
The orders of the columns are specials. It's in gf2, the sequence from 001 to 111: <math>001, 010, 011, 100, 101, 110, 111</math>
Definition of the function <math>HG</math> :
<MATH> HG = \begin{bmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{bmatrix} </MATH>
As a first step towards figuring out the error vector, we computes the error syndrome: <MATH> H*\tilde{c} </MATH> which equals: <MATH> H*e </MATH> as <math>e</math> en <math>c</math> are codewords
We assumes that at most one bit of the codeword is corrupted, so at most one bit of <math>e</math> is nonzero in position <math>i \in \{1, 2, \dots, 7\}</math> .
The error syndrom (the value of <math>H*e</math> ) is the 3-vector where the error occurs.
It use the dot product property of Gf2
For instance, if <math>e</math> has a 1 in its third position, <math>e = [0, 0, 1, 0, 0, 0, 0]</math> , then the result of <math>H*e</math> gives the column where the bit error is. In this case, the third column of <math>H</math> , which is <math>[0, 1, 1]</math> .
non_codeword = Vec({0,1,2,3,4,5,6}, {0: one, 1:0, 2:one, 3:one, 4:0, 5:one, 6:one})
error_syndrome = H*non_codeword
error_vector = find_error(error_syndrome) # See the previous sectie
code_word = non_codeword + error_vector
original = R*code_word