# Toric Codes

## `ToricCode(P, q): TorPol, RngIntElt -> Code`

The linear code $C$ over the finite field ${\bf F}_{q}$ associated with the lattice points of the polygon $P$.

To achieve this, after a translation so that the lattice points of $P$ lie in the first quadrant, as close to the origin as possible, these points must lie in the box $[0,q-2] \times [0,q-2]$. Then the code is the monomial evaluation code where each point $(a,b)$ corresponds to the monomial $x^ay^b$, and these monomials are evaluated at the points of the torus $({\bf F}_{q}^*)^2$.

## `ToricCode(S, q): SeqEnum[TorLatElt], RngIntElt -> Code`

## `ToricCode(S, q): SetEnum[TorLatElt], RngIntElt -> Code`

The linear code $C$ over the finite field ${\bf F}_{q}$ associated with the lattice points in $S$. (Note that the points will be translated to lie within a box at the origin of the first quadrant, as is usual.)

## `Example: Toric Code (ex-deddf3)`

We construct the toric code based on the lattice points in the polygon with vertices $(3,0)$, $(5,0)$, $(3,3)$, $(1,5)$, $(0,3)$, $(0,1)$.

```magma
> P := Polytope( [[3,0], [5,0], [3,3], [1,5], [0,3], [0,1]] );
> C := ToricCode(P, 7);
> [ Length(C), Dimension(C), MinimumDistance(C) ];
[ 36, 19, 12 ]

```

We can compare this with the current database of best known linear codes.

```magma
> BKLCLowerBound(Field(C), Length(C), Dimension(C));
12

```
