Week 3 Linear codes
Version 2023-10-02. To PDF of this week only Open the whole set of notes in PDF
Synopsis. The most important class of codes is linear codes. Their ability to correct errors is no worse than that of general codes, but linear codes are easier to implement in practice and allow us to use algebraic methods. We learn how to find the minimum distance by looking at weights, and how to define a linear code by its generator matrix.
The definition of a linear code
Reminder (vector spaces): let
Definition: linear code, codevector
A linear code is a subspace of the vector space
Codewords of a linear code are called codevectors.
This means that the zero vector
Discussion: Why are linear codes useful? (not examinable)
1. They seem to be as efficient as general codes. In particular, it was proved that Shannon’s Theorem about the capacity of a channel (discussed later) is still true for linear codes.
2. It is possible to define a linear code without specifying all the codewords (see below).
3. The minimum distance is easier to calculate than for general codes (see below).
4. We can use algebra to design linear codes and to construct efficient encoding and decoding algorithms.
The absolute majority of codes designed by coding theorists are linear codes. In the rest of the course, (almost) all the codes we consider will be linear codes.
End of discussion.
Example: trivial, repetition codes
The trivial code
The repetition code
To get non-trivial examples, we need to introduce more structure.
The weight
Definition: weight of a vector, weight of a code
The weight
The weight
-
Proof. Indeed,
is the number of positions where Obviously, this is the same as the number of positions where By definition of the weight, this is as claimed. □
Recall that the minimum distance,
-
Proof. Take a codevector
such that Observe, but so We proved thatNow take a pair
such that Rewrite this as Since is linear, so We proved that □
Remark: in the proof, we twice used that
Remark: given a linear code
Here is a non-trivial construction of a linear code.
Example: the zero sum code
For any finite field
We note that the zero sum code in
Binary zero sum codes are very common and have a special name.
Example: The binary even weight code
The binary even weight code of length
Due to the rules of arithmetic in
which shows that
Note:
Basic properties of the binary even weight code
Minimum distance = weight: a vector with only one
The number of codewords: in a codeword
Another argument to that effect is as follows. We can take a binary word and flip (change) its first bit. This operation splits the set
Conclusion:
Remark: A widely used code. If an error is detected, the recipient will request retransmission of the codeword where the error occurred. Error correction is not available.
The code generated by a matrix. A generator matrix of a linear code
We have an unlimited supply of linear codes, due to the following construction.
Definition: the linear code generated by a matrix
Let
is said to be generated by the matrix
is the encoder for
Proposition 3.3: properties of a code generated by a matrix
In the above definition,
-
Proof. The definition says that
is the span of in the vector space By linear algebra, a span is a subspace of hence a linear code.Matrix multiplication is linear in each argument so
is a linear function of As consists of vectors of the form the image of is so is surjective. The kernel of is made up of all such that but as are linearly independent, and so is injective, hence bijective.Hence
and so the information dimension of isOn the other hand, the vector space dimension of
is, by definition, the number of element in a basis of Note that the -element set is a basis of as this is a linearly independent set which spans Hence is also □
In fact, all linear codes arise from the above construction. Indeed, we know from linear algebra that every vector space
Definition: generator matrix
Let
Let us consider some simple matrices and work out the codes they generate.
Example: matrices that can generate a trivial code
The identity matrix
Example: matrices that generate repetition codes
The repetition code
Example: matrices that generate the binary even weight code
To write down a generator matrix, we need to take two linearly independent codevectors. We must not use the zero codevector,
is a generator matrix for
Discussion: storing generator matrix instead of the whole code
Thus, to work with a linear code, it is enough to store just its generator matrix instead of storing all codevectors. This approach to linear codes has its practical advantages and disadvantages.
The single advantage which outweighs everything else is the amount of storage space required.
To visualise the difference between storing all the
codewords of a linear code and storing only rows of a generator matrix, consider a binary code of dimension about used in computer networking for error detection. We can store rows of a generator matrix, but it is absolutely impossible to store a list of all codewords. Indeed, the number (the googol) is believed to be bigger than the number of electrons in the visible Universe; but googol is less than
Disadvantages. A generator matrix is in general not unique, because a basis of a vector space
If a linear code
Generator matrices in standard form
For a linear code
Definition: matrix in standard form
A matrix
Note that entries in the last
If
(this is an easy example of multiplication of block matrices). This means that it is easy to unencode a codevector, simply by taking its first
In this situation, the first
Theorem 3.4: generator matrix in standard form
If a generator matrix in standard form exists for a linear code
-
(R1) Permutation of rows.
-
(R2) Multiplication of a row by a non-zero scalar.
-
(R3) Adding a scalar multiple of one row to another row.
-
Proof. Not given — a standard fact from linear algebra (uniqueness of reduced row echelon form). We will do examples to show how to find the generator matrix in standard form. □
Remark. If we apply a sequence of the row operations (R1), (R2) and (R3) to a generator matrix of a code
Examples of finding a generator matrix in standard form, and some codes which have no generator matrix in standard form, are on example sheets. We consider one example here:
Example: bringing a generator matrix into standard form
The binary code
Solution: apply row operations
The parameters of