Operations on Codewords#

Construction of a Codeword#

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

Given a code \(C\) which is defined as a subset of the \(R\)-space \(R^{(n)}\), and elements \(a_1, \ldots, a_n\) belonging to \(R\), construct the codeword \((a_1, \ldots, a_n)\) of \(C\). It is checked that the vector (\(a_1, \ldots, a_n\)) is an element of \(C\).

C ! u: Code, ModTupRngElt -> ModTupRngElt#

Given a code \(C\) which is defined as a subset of the \(R\)-space \(V = R^{(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 code \(C\).

Random(C): Code -> ModTupRngElt#

A random codeword of \(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 field \(K\), and a codeword \(u\) belonging to the linear code \(C\), return the codeword \(a*u\).

Normalize(u): ModTupRngElt -> ModTupRngElt#

Given an element \(u\) over a field, not the zero element, belonging to the linear code \(C\), return \({1\over a}*u\), where \(a\) is the first non-zero component of \(u\). If \(u\) is the zero vector, it is returned as the value of this function. The net effect is that Normalize(u) always returns a vector \(v\) in the subspace generated by \(u\), such that the first non-zero component of \(v\) is the unit of \(K\).

Syndrome(w, C): ModTupFldElt, Code -> ModTupFldElt#

Given an \([n, k]\) linear code \(C\) over a finite field with parent vector space \(V\), and a vector \(w\) belonging to \(V\), construct the syndrome of \(w\) relative to the code \(C\). This will be an element of the syndrome space of \(C\).

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 code \(C\).

Weight(u): ModTupRngElt -> RngIntElt#

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

LeeWeight(u): ModTupRngElt -> RngIntElt#

The Lee weight of the codeword \(u\).

Example: Distance (ex-75e920)#

We calculate all possible distances between code words of the non-extended Golay code over GF(3), and show the correspondence with all possible code word weights.

> C := GolayCode(GF(3),false);
> {Distance(v,w):v,w in C};
{ 0, 5, 6, 8, 9, 11 }
> {Weight(v):v in C};
{ 0, 5, 6, 8, 9, 11 }

Run in calculator

Predicates for Codewords#

u eq v: ModTupRngElt, ModTupRngElt -> BoolElt#

The function returns true if and only if the codewords \(u\) and \(v\) are equal.

u ne v: ModTupRngElt, ModTupRngElt -> BoolElt#

The function returns true if and only if the codewords \(u\) and \(v\) 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\).