# Invariants of an Additive Code

## The Ambient Space and Alphabet

A length $n$ additive code has an alphabet $F$ and coefficient field $K \subseteq F$. The code consists of codewords which are a $K$-linear subspace of $F^{(n)}$.

### `Alphabet(C): Code -> Rng`

### `Field(C): Code -> Rng`

The underlying field (or alphabet) of the codewords of the additive code $C$. A length $n$ additive code with alphabet $F$ consists of codewords from $F^{(n)}$.

### `CoefficientField(C): Code -> Rng`

The field over which the codewords of the additive code $C$ are considered linear. This will be a subfield of the alphabet of $C$.

### `AmbientSpace(C): Code -> ModTupRng`

The ambient space of the additive code $C$, i.e. the generic $R$-space $V$ in which $C$ is contained.

### `Generic(C): Code -> Code`

Given a length $n$ additive code $C$, return the generic $[n, n, 1]$ code in which $C$ is contained.

### `Example: Alphabet Coeff Field (ex-b0a75c)`

A code can often be represented using several different coefficient fields.

```magma
> F<w> := GF(5,4);
> K := GF(5,2);
> C := RandomAdditiveCode(F, K, 12, 5);
> C:Minimal;
[12, 2 1/2 : 5] GF(5^2)-Additive Code over GF(5^4)
> #C;
9765625
> Alphabet(C);
Finite field of size 5^4
> CoefficientField(C);
Finite field of size 5^2
>
> C1 := AdditiveCode(GF(5), C);
> C1:Minimal;
[12, 2 1/2 : 10] GF(5)-Additive Code over GF(5^4)
> #C1;
9765625
> Alphabet(C1);
Finite field of size 5^4
> CoefficientField(C1);
Finite field of size 5

```

## Basic Numerical Invariants

### `Length(C): Code -> RngIntElt`

Return the block length $n$ of an additive code $C$.

### `Dimension(C): Code -> FldRatElt`

The (rational) dimension $k$ of $C$. If the alphabet of $C$ is $F$, then the dimension is defined by the equation $\#C = (\#F)^k$.

Note that since any basis of the additive code $C$ is relative to the coefficient field $K$, this dimension is not necessarily equal to the number of generators of $C$ and is not even necessarily integral.

### `NumberOfGenerators(C): Code -> RngIntElt`

### `Ngens(C): Code -> RngIntElt`

The number of generators of the additive code $C$. Note that if the coefficient ring of $C$ is not the same as its alphabet then this will be different from the dimension of $C$.

### `# C: Code -> RngIntElt`

Given an additive code $C$, return the number of codewords belonging to $C$.

### `InformationRate(C): Code -> FldPrElt`

The information rate of the $[n, k]$ code $C$. This is the ratio $k/n$.

## The Code Space

### `GeneratorMatrix(C): Code -> ModMatFldElt`

### `BasisMatrix(C): Code -> ModMatRngElt`

The generator matrix for an $[n, k(k_g)]$ $K$-additive code $C$ over $F$ is a $k_g \times n$ matrix over $F$, whose $k_g$ rows form a basis for $C$ when considered as vectors over $K$.

### `Basis(C): Code -> [ ModTupRngElt ]`

### `Generators(C): Code -> { ModTupFldElt }`

A basis for the $K$-additive code $C$, returned as a sequence of codewords over the alphabet of $C$, which generate the code over $K$.

### `C . i: Code, RngIntElt -> ModTupFldElt`

Given an $[n, k(k_g)]$ $K$-additive code $C$ and a positive integer $i$, $1 \le i \le k_g$, return the $i$-th element of the current basis of $C$ over $K$.

## The Dual Space

### `Dual(C): CodeAdd -> CodeAdd`

The code that is dual to the code $C$. For an additive code $C$, this is the nullspace with respect to the trace inner product of the coefficient field.

### `ParityCheckMatrix(C): Code -> ModMatFldElt`

The parity check matrix for the code $C$, returned as an element of ${\operatorname{Hom}}(V, U)$.
