Operations on Codewords#

Construction of a Codeword#

C ! [a₁, ..., aₙ]: Code, [ RngElt ] -> ModTupRngElt#
elt< C | a₁, ..., aₙ>: Code, List -> ModTupRngElt#

Given a length \(n\) additive code \(C\) with alphabet \(F\), then the codewords of \(C\) lie in \(F^{(n)}\). Given elements \(a_1, \ldots, a_n\) belonging to \(F\), construct the codeword \((a_1, \ldots, a_n)\) of \(C\). A check is made that the vector (\(a_1, \ldots, a_n\)) is an element of \(C\).

C ! u: Code, ModTupRngElt -> ModTupRngElt#

Given an additive code \(C\) which is defined as a subset of the \(F\)-space \(V = F^{(n)}\), and an element \(u\) belonging to \(V\), create the codeword of \(C\) corresponding to \(u\). The function will fail if \(u\) does not belong to \(C\).

C ! 0: Code, RngIntElt -> ModTupRngElt#

The zero word of the additive code \(C\).

Random(C): Code -> ModTupRngElt#

A random codeword of the additive code \(C\).

Arithmetic Operations on Codewords#

u + v: ModTupRngElt, ModTupRngElt -> ModTupRngElt#

Sum of the codewords \(u\) and \(v\), where \(u\) and \(v\) belong to the same linear code \(C\).

- u: ModTupRngElt -> ModTupRngElt#

Additive inverse of the codeword \(u\) belonging to the linear code \(C\).

u - v: ModTupRngElt, ModTupRngElt -> ModTupRngElt#

Difference of the codewords \(u\) and \(v\), where \(u\) and \(v\) belong to the same linear code \(C\).

a * u: RngElt, ModTupRngElt -> ModTupRngElt#

Given an element \(a\) belonging to the alphabet \(F\), and a codeword \(u\) belonging to the additive code \(C\), return the codeword \(a*u\).

Normalize(u): ModTupRngElt -> ModTupRngElt#

Normalize a codeword \(u\) of an additive code \(C\), returning a scalar multiple of \(u\) such that its first non-zero entry is \(1\).

Distance and Weight#

Distance(u, v): ModTupRngElt, ModTupRngElt -> RngIntElt#

The Hamming distance between the codewords \(u\) and \(v\), where \(u\) and \(v\) belong to the same additive code \(C\).

Weight(u): ModTupRngElt -> RngIntElt#

The Hamming weight of the codeword \(u\), i.e., the number of non-zero components of \(u\).

Predicates for Codewords#

u eq v: ModTupRngElt, ModTupRngElt -> BoolElt#

The function returns true if and only if the codewords \(u\) and \(v\) belonging to the same additive code are equal.

u ne v: ModTupRngElt, ModTupRngElt -> BoolElt#

The function returns true if and only if the codewords \(u\) and \(v\) belonging to the same additive code are not equal.

IsZero(u): ModTupRngElt -> BoolElt#

The function returns true if and only if the codeword \(u\) is the zero vector.

Accessing Components of a Codeword#

u[i]: ModTupRngElt, RngIntElt -> RngElt#

Given a codeword \(u\) belonging to the code \(C\) defined over the ring \(R\), return the \(i\)-th component of \(u\) (as an element of \(R\)).

u[i] := x;#

Given an element \(u\) belonging to a subcode \(C\) of the full \(R\)-space \(V = R^n\), a positive integer \(i\), \(1 \leq i\leq n\), and an element \(x\) of \(R\), this function returns a vector in \(V\) which is \(u\) with its \(i\)-th component redefined to be \(x\).