In coding theory, a linear code is an error-correcting code for which any linear combination of codewords is also a codeword. Linear codes are traditionally partitioned into block codes and convolutional codes, although turbo codes can be seen as a hybrid of these two types.[1] Linear codes allow for more efficient encoding and decoding algorithms than other codes (cf. syndrome decoding).
Linear codes are used in forward error correction and are applied in methods for transmitting symbols (e.g., bits) on a communications channel so that, if errors occur in the communication, some errors can be corrected or detected by the recipient of a message block. The codewords in a linear block code are blocks of symbols that are encoded using more symbols than the original value to be sent.[2] A linear code of length n transmits blocks containing n symbols. For example, the [7,4,3] Hamming code is a linear binary code which represents 4-bit messages using 7-bit codewords. Two distinct codewords differ in at least three bits. As a consequence, up to two errors per codeword can be detected while a single error can be corrected.[3] This code contains 24=16 codewords.
n | |
F | |
q |
Fq
The weight of a codeword is the number of its elements that are nonzero and the distance between two codewords is the Hamming distance between them, that is, the number of elements in which they differ. The distance d of the linear code is the minimum weight of its nonzero codewords, or equivalently, the minimum distance between distinct codewords. A linear code of length n, dimension k, and distance d is called an [''n'',''k'',''d''] code (or, more precisely,
[n,k,d]q
We want to give
n | |
F | |
q |
As a linear subspace of
n | |
F | |
q |
k
\boldsymbol{G}=[Ik|P]
Ik
k x k
k x (n-k)
A matrix H representing a linear function
\phi:
n\to | |
F | |
q |
n-k | |
F | |
q |
\boldsymbol{G}=[Ik|P]
\boldsymbol{H}=[-PT|In-k]
k x n
(n-k) x n
Linearity guarantees that the minimum Hamming distance d between a codeword c0 and any of the other codewords c ≠ c0 is independent of c0. This follows from the property that the difference c - c0 of two codewords in C is also a codeword (i.e., an element of the subspace C), and the property that d(c, c0) = d(c - c0, 0). These properties imply that
min | |
c\inC, c ≠ c0 |
d(c,c0)=min
c\inC, c ≠ c0 |
d(c-c0,0)=mincd(c,0)=d.
In other words, in order to find out the minimum distance between the codewords of a linear code, one would only need to look at the non-zero codewords. The non-zero codeword with the smallest weight has then the minimum distance to the zero codeword, and hence determines the minimum distance of the code.
The distance d of a linear code C also equals the minimum number of linearly dependent columns of the check matrix H.
Proof: Because
\boldsymbol{H} ⋅ \boldsymbol{c}T=\boldsymbol{0}
n | |
\sum | |
i=1 |
(ci ⋅ \boldsymbol{Hi})=\boldsymbol{0}
\boldsymbol{Hi}
ith
\boldsymbol{H}
ci=0
\boldsymbol{Hi}
ci ≠ 0
d
\{\boldsymbol{Hj}|j\inS\}
S
n | |
\sum | |
i=1 |
(ci ⋅ \boldsymbol{Hi})=\sumj(cj ⋅ \boldsymbol{Hj})+\sumj(cj ⋅ \boldsymbol{Hj})=\boldsymbol{0}
\boldsymbol{c'}
cj'=0
j\notinS
\boldsymbol{c'}\inC
\boldsymbol{H} ⋅ \boldsymbol{c'}T=\boldsymbol{0}
d\lewt(\boldsymbol{c'})
\boldsymbol{H}
See main article: Hamming code.
As the first class of linear codes developed for error correction purpose, Hamming codes have been widely used in digital communication systems. For any positive integer
r\ge2
[2r-1,
r-r-1,3] | |
2 | |
2 |
d=3
Example : The linear block code with the following generator matrix and parity check matrix is a
[7,4,3]2
\boldsymbol{G}=\begin{pmatrix}1 0 0 0 1 1 0\ 0 1 0 0 0 1 1\ 0 0 1 0 1 1 1\ 0 0 0 1 1 0 1\end{pmatrix},
\boldsymbol{H}=\begin{pmatrix}1 0 1 1 1 0 0\ 1 1 1 0 0 1 0\ 0 1 1 1 0 0 1\end{pmatrix}
See main article: Hadamard code.
Hadamard code is a
[2r,r,2r-1]2
ith
i
2r-1
2r-2-1
Example: The linear block code with the following generator matrix is a
[8,3,4]2
\boldsymbol{G}Had=\begin{pmatrix}0 0 0 0 1 1 1 1\ 0 0 1 1 0 0 1 1\ 0 1 0 1 0 1 0 1\end{pmatrix}
Hadamard code is a special case of Reed–Muller code. If we take the first column (the all-zero column) out from
\boldsymbol{G}Had
[7,3,4]2
The parameter d is closely related to the error correcting ability of the code. The following construction/algorithm illustrates this (called the nearest neighbor decoding algorithm):
Input: A received vector v in
n | |
F | |
q |
Output: A codeword
w
C
v
t=0
t
v
Bt(v)
w
Bt(v)
w
C
w
t
t>(d-1)/2
We say that a linear
C
t
Bt(v)
v
n | |
F | |
q |
Codes in general are often denoted by the letter C, and a code of length n and of rank k (i.e., having n code words in its basis and k rows in its generating matrix) is generally referred to as an (n, k) code. Linear block codes are frequently denoted as [''n'', ''k'', ''d''] codes, where d refers to the code's minimum Hamming distance between any two code words.
(The [''n'', ''k'', ''d''] notation should not be confused with the (n, M, d) notation used to denote a non-linear code of length n, size M (i.e., having M code words), and minimum Hamming distance d.)
Lemma (Singleton bound): Every linear [n,k,d] code C satisfies
k+d\leqn+1
A code C whose parameters satisfy k+d=n+1 is called maximum distance separable or MDS. Such codes, when they exist, are in some sense best possible.
If C1 and C2 are two codes of length n and if there is a permutation p in the symmetric group Sn for which (c1,...,cn) in C1 if and only if (cp(1),...,cp(n)) in C2, then we say C1 and C2 are permutation equivalent. In more generality, if there is an
n x n
M\colon
n | |
F | |
q |
\to
n | |
F | |
q |
Lemma: Any linear code is permutation equivalent to a code which is in standard form.
A code is defined to be equidistant if and only if there exists some constant d such that the distance between any two of the code's distinct codewords is equal to d.[4] In 1984 Arrigo Bonisoli determined the structure of linear one-weight codes over finite fields and proved that every equidistant linear code is a sequence of dual Hamming codes.[5]
Some examples of linear codes include:
Hamming spaces over non-field alphabets have also been considered, especially over finite rings, most notably Galois rings over Z4. This gives rise to modules instead of vector spaces and ring-linear codes (identified with submodules) instead of linear codes. The typical metric used in this case the Lee distance. There exist a Gray isometry between
2m | |
Z | |
2 |
m | |
Z | |
4 |
2m | |
Z | |
2 |
m | |
Z | |
4 |
Some authors have referred to such codes over rings simply as linear codes as well.[9]
. David J.C. MacKay. Information Theory, Inference, and Learning Algorithms . 2003 . 9. Cambridge University Press. 9780521642989. "In a linear block code, the extra
N-K
K