---
title: "Invariants of an Additive Code"
canonical: "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/access.html"
source: "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/access.md"
part: "Coding Theory"
chapter: "Additive Codes"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Coding Theory", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/index-coding-theory.md"}
  - {"title": "Additive Codes", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/index-additive-codes.md"}
prev: {"title": "Construction of Additive Codes", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/creation.md"}
next: {"title": "Operations on Codewords", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/AdditiveCodes/element.md"}
intrinsics:
  - {"name": "Alphabet", "signature": "Alphabet(C): Code -> Rng"}
  - {"name": "Field", "signature": "Field(C): Code -> Rng"}
  - {"name": "CoefficientField", "signature": "CoefficientField(C): Code -> Rng"}
  - {"name": "AmbientSpace", "signature": "AmbientSpace(C): Code -> ModTupRng"}
  - {"name": "Generic", "signature": "Generic(C): Code -> Code"}
  - {"name": "Length", "signature": "Length(C): Code -> RngIntElt"}
  - {"name": "Dimension", "signature": "Dimension(C): Code -> FldRatElt"}
  - {"name": "NumberOfGenerators", "signature": "NumberOfGenerators(C): Code -> RngIntElt"}
  - {"name": "Ngens", "signature": "Ngens(C): Code -> RngIntElt"}
  - {"name": "#", "signature": "# C: Code -> RngIntElt"}
  - {"name": "InformationRate", "signature": "InformationRate(C): Code -> FldPrElt"}
  - {"name": "GeneratorMatrix", "signature": "GeneratorMatrix(C): Code -> ModMatFldElt"}
  - {"name": "BasisMatrix", "signature": "BasisMatrix(C): Code -> ModMatRngElt"}
  - {"name": "Basis", "signature": "Basis(C): Code -> [ ModTupRngElt ]"}
  - {"name": "Generators", "signature": "Generators(C): Code -> { ModTupFldElt }"}
  - {"name": ".", "signature": "C . i: Code, RngIntElt -> ModTupFldElt"}
  - {"name": "Dual", "signature": "Dual(C): CodeAdd -> CodeAdd"}
  - {"name": "ParityCheckMatrix", "signature": "ParityCheckMatrix(C): Code -> ModMatFldElt"}
examples:
  - "ex-b0a75c"
---

# 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)}$.

<a id="function-alphabet-code"></a>
### `Alphabet(C): Code -> Rng`

<a id="function-field-code"></a>
### `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)}$.

<a id="function-coefficientfield-code"></a>
### `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$.

<a id="function-ambientspace-code"></a>
### `AmbientSpace(C): Code -> ModTupRng`

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

<a id="function-generic-code"></a>
### `Generic(C): Code -> Code`

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

<a id="example-ex-b0a75c"></a>
### `Example: Alphabet and Coefficient 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

<a id="function-length-code"></a>
### `Length(C): Code -> RngIntElt`

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

<a id="function-dimension-code"></a>
### `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.

<a id="function-numberofgenerators-code"></a>
### `NumberOfGenerators(C): Code -> RngIntElt`

<a id="function-ngens-code"></a>
### `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$.

<a id="operation-operation-code-rngintelt"></a>
### `# C: Code -> RngIntElt`

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

<a id="function-informationrate-code"></a>
### `InformationRate(C): Code -> FldPrElt`

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

## The Code Space

<a id="function-generatormatrix-code"></a>
### `GeneratorMatrix(C): Code -> ModMatFldElt`

<a id="function-basismatrix-code"></a>
### `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$.

<a id="function-basis-code"></a>
### `Basis(C): Code -> [ ModTupRngElt ]`

<a id="function-generators-code"></a>
### `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$.

<a id="operation-operation-code-rngintelt-modtupfldelt"></a>
### `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

<a id="function-dual-codeadd"></a>
### `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.

<a id="function-paritycheckmatrix-code"></a>
### `ParityCheckMatrix(C): Code -> ModMatFldElt`

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