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\).
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\).
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\).
- Example: Distances in the Ternary Golay Code (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 }
Predicates for Codewords
- u eq v: ModTupRngElt, ModTupRngElt -> BoolElt
The function returns
trueif and only if the codewords \(u\) and \(v\) are equal.