Mathwords logoMathwords

Generator Matrix — Definition, Formula & Example

A generator matrix is a compact recipe for a linear error-correcting code. You multiply a short message by it to produce a longer codeword that carries extra check bits.

Let CC be an [n,k][n,k] linear code over the finite field Fq\mathbb{F}_q. A generator matrix for CC is a k×nk \times n matrix GG over Fq\mathbb{F}_q whose rows form a basis of CC. Then rank⁡(G)=k\operatorname{rank}(G) = k, and C={mG:m∈Fqk}C = \{\mathbf{m}G : \mathbf{m} \in \mathbb{F}_q^k\}. GG is in systematic (standard) form when G=[ Ik∣P ]G = [\,I_k \mid P\,], where PP is a k×(n−k)k \times (n-k) matrix.

Key Formula

c=mG,G=[ Ik∣P ]\mathbf{c} = \mathbf{m}G, \qquad G = [\,I_k \mid P\,]
Where:
  • m\mathbf{m} = Message: a row vector of length k with entries in the field (0s and 1s for binary codes)
  • GG = Generator matrix with k rows and n columns
  • c\mathbf{c} = Codeword: a row vector of length n
  • IkI_k = The k × k identity matrix, which copies the message into the first k positions
  • PP = The k × (n − k) parity part, which produces the check symbols

Worked Example

Problem: A binary [6, 3] code has the systematic generator matrix G=[100110010011001101]G = \begin{bmatrix} 1&0&0&1&1&0 \\ 0&1&0&0&1&1 \\ 0&0&1&1&0&1 \end{bmatrix}. Encode the message m=(1,0,1)\mathbf{m} = (1, 0, 1). All arithmetic is mod 2.
Step 1: The product mG\mathbf{m}G is a combination of the rows of GG. The message has 1s in positions 1 and 3, so the codeword is row 1 plus row 3.
c=1⋅(1,0,0,1,1,0)+0⋅(0,1,0,0,1,1)+1⋅(0,0,1,1,0,1)\mathbf{c} = 1\cdot(1,0,0,1,1,0) + 0\cdot(0,1,0,0,1,1) + 1\cdot(0,0,1,1,0,1)
Step 2: Add the two rows entry by entry, reducing mod 2. In column 4 you get 1+1=2≡01 + 1 = 2 \equiv 0.
c=(1+0,  0+0,  0+1,  1+1,  1+0,  0+1)≡(1,0,1,0,1,1)\mathbf{c} = (1+0,\; 0+0,\; 0+1,\; 1+1,\; 1+0,\; 0+1) \equiv (1, 0, 1, 0, 1, 1)
Step 3: Check the systematic structure. The first three bits repeat the message, and the last three are parity bits. Every message in F23\mathbb{F}_2^3 gives one codeword, so the code has 23=82^3 = 8 codewords.
c=(1,0,1⏟message∣0,1,1⏟parity)\mathbf{c} = (\underbrace{1,0,1}_{\text{message}} \mid \underbrace{0,1,1}_{\text{parity}})
Answer: The codeword is c=(1,0,1,0,1,1)\mathbf{c} = (1, 0, 1, 0, 1, 1). Its first three bits are the original message, and its last three bits, (0,1,1)(0, 1, 1), are the check bits.

Why It Matters

Generator matrices are how engineers specify the codes in QR codes, deep-space probe links, and computer memory with error correction. In a coding theory or abstract algebra course, you use GG to find the parity-check matrix H=[ −P⊤∣In−k ]H = [\,-P^{\top} \mid I_{n-k}\,], which then drives syndrome decoding.

Common Mistakes

Mistake: Using ordinary integer arithmetic when multiplying mG\mathbf{m}G, which leaves entries like 2 in a binary codeword.
Correction: A binary code lives over F2\mathbb{F}_2, so you reduce every sum mod 2. Then 1+1=01 + 1 = 0. A codeword may contain only 0s and 1s.

Related Terms

  • Coding Theory — The field that builds and studies codes from generator matrices
  • Matrix — Explains the matrix multiplication used in encoding c = mG
  • Block Matrix — Describes the partitioned systematic form [I | P]