# Introduction

Let $K$ be a finite field and let $V$ be the vector space of $n$-tuples over $K$. The *Hamming-distance* between elements $x$ and $y$ of $V$, denoted $d(x, y)$, is defined by

$$
d(x, y) := \#\{\ 1 \leq i \leq n\ |\ x_i \neq y_i\ \}.
$$

The *minimum distance d* for a subset $C$ of $V$ is then

$$
d = \min\{\ d(x, y)\ |\ x \in C, y \in C, x \neq y\ \}.
$$

The subset $C$ of $V$ is called an $(n, M, d)$ *code* if the minimum distance for the subset $C$ is $d$ and $|C| = M$. Then $V$ is referred to as the *ambient space* of $C$.

The code $C$ is called a $[n, k, d]$ *linear code* if $C$ is a $k$-dimensional subspace of $V$. Currently Magma supports not only linear codes, but also codes over finite fields which are only linear over some subfield. These are known as *additive codes* and can be found in Chapter [Additive Codes](../AdditiveCodes/index-additive-codes.md#chap-codeadd). This chapter deals only with linear codes.

In this chapter, the term “code” will refer to a linear code. Magma provides machinery for studying linear codes over finite fields $F_q=GF(q)$, over the integer residue classes ${\mathbb{Z}}_m = {\mathbb{Z}}/m{\mathbb{Z}}$, and over galois rings $GR(p^n,k)$.

This chapter describes those functions which are applicable to codes over $F_q$. The highlights of the facilities provided for such codes include:

- The construction of codes in terms of generator matrices, parity check matrices and generating polynomials (cyclic codes).

- A large number of constructions for particular families of codes, e.g., quadratic residue codes.

- Highly optimized algorithms for the calculation of the minimum weight.

- Various forms of weight enumerator including the MacWilliams transform.

- A database that gives the user access to best known linear codes $GF(q)$ for $q=2,3,4,5,7,8,9$.

- Machinery that allows the user to construct algebraic-geometric codes from a curve defined over $F_q$.

- The computation of automorphism groups for codes over small fields.

The reader is referred to [[MacWilliams and Sloane, 1978](../../references.md#cite-sloane)] as a general reference on coding theory.
