---
title: "Invariants"
canonical: "https://docs.magma-maths.org/v2.30-1/CodingTheory/LinearCodesOverFiniteRings/access.html"
source: "https://docs.magma-maths.org/v2.30-1/CodingTheory/LinearCodesOverFiniteRings/access.md"
part: "Coding Theory"
chapter: "Linear Codes over Finite Rings"
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": "Linear Codes over Finite Rings", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/LinearCodesOverFiniteRings/index-linear-codes-over-finite-rings.md"}
prev: {"title": "Constructions", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/LinearCodesOverFiniteRings/creation.md"}
next: {"title": "Subcodes", "source": "https://docs.magma-maths.org/v2.30-1/CodingTheory/LinearCodesOverFiniteRings/subcode.md"}
intrinsics:
  - {"name": "#", "signature": "# C: Code -> RngIntElt"}
  - {"name": ".", "signature": "C . i: Code, RngIntElt -> ModTupRngElt"}
  - {"name": "Name", "signature": "Name(C, i): Code, RngIntElt -> ModTupRngElt"}
  - {"name": "Alphabet", "signature": "Alphabet(C): Code -> Rng"}
  - {"name": "AmbientSpace", "signature": "AmbientSpace(C): Code -> ModTupRng"}
  - {"name": "Basis", "signature": "Basis(C): Code -> [ ModTupRngElt ]"}
  - {"name": "Generators", "signature": "Generators(C): Code -> { ModTupRngElt }"}
  - {"name": "GeneratorMatrix", "signature": "GeneratorMatrix(C): Code -> ModMatRngElt"}
  - {"name": "Generic", "signature": "Generic(C): Code -> Code"}
  - {"name": "Length", "signature": "Length(C): Code -> RngIntElt"}
  - {"name": "PseudoDimension", "signature": "PseudoDimension(C): Code -> RngIntElt"}
  - {"name": "NumberOfGenerators", "signature": "NumberOfGenerators(C): Code -> RngIntElt"}
  - {"name": "Ngens", "signature": "Ngens(C): Code -> RngIntElt"}
  - {"name": "ParityCheckMatrix", "signature": "ParityCheckMatrix(C): Code -> ModMatRngElt"}
  - {"name": "Random", "signature": "Random(C): Code -> ModTupRngElt"}
  - {"name": "RSpace", "signature": "RSpace(C): Code -> ModTupRng"}
  - {"name": "InformationRate", "signature": "InformationRate(C): Code -> RngPrElt"}
---

# Invariants

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

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

<a id="operation-operation-code-rngintelt-modtuprngelt"></a>
## `C . i: Code, RngIntElt -> ModTupRngElt`

<a id="function-name-code-rngintelt"></a>
## `Name(C, i): Code, RngIntElt -> ModTupRngElt`

Given a code $C$ and a positive integer $i$, return the $i$-th generator of $C$.

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

The underlying ring (or alphabet) $R$ of the code $C$.

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

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

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

The basis of the linear code $C$, returned as a sequence of elements of $C$.

<a id="function-generators-code"></a>
## `Generators(C): Code -> { ModTupRngElt }`

The generators for the linear code $C$, returned as a set.

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

The generator matrix for the linear code $C$. This gives a unique canonical generating set for the code.

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

Given a length $n$ code $C$ over a ring $R$, return the generic $(n, \#R^n, 1)$ code in which $C$ is contained.

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

Given a code $C$, return the block length $n$ of $C$.

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

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

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

The number of generators (which equals the pseudo-dimension $k$) of the linear code $C$.

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

The parity check matrix for the code $C$, which can be defined as the canonical generator matrix of the dual of $C$.

<a id="function-random-code"></a>
## `Random(C): Code -> ModTupRngElt`

A random codeword of the code $C$.

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

Given a length $n$ linear code $C$, defined as a subspace $U$ of the $n$-dimensional space $V$, return $U$ as a subspace of $V$ with basis corresponding to the rows of the generator matrix for $C$.

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

Given a code $C$ over a ring with cardinality $q$, return the information rate of $C$, that is, the ratio $Log_q(\#C)/n$.
