Operations on Codewords

Contents

Construction of a Codeword

C ! [a1, ..., an] : Code, [ RngElt ] -> ModTupRngElt
elt< C | a1, ..., an> : Code, List -> ModTupRngElt
Given a code C which is defined as a subset of the R-space R(n), and elements a1, ..., an belonging to R, construct the codeword (a1, ..., an) of C. It is checked that the vector (a1, ..., an) 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/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 CodeFld_Distance (H161E11)

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 }

Vector Space and Related Operations

(u, v) : ModTupRngElt, ModTupRngElt -> RngElt
InnerProduct(u, v) : ModTupRngElt, ModTupRngElt -> RngElt
Inner product of the vectors u and v with respect to the Euclidean norm, where u and v belong to the parent vector space of the code C.
Support(w) : ModTupRngElt -> { RngIntElt }
Given a word w belonging to the [n, k] code C, return its support as a subset of the integer set { 1 .. n }. The support of w consists of the coordinates at which w has non-zero entries.
Coordinates(C, u) : Code, ModTupRngElt -> [ RngFinElt ]
Given an [n, k] linear code C and a codeword u of C return the coordinates of u with respect to C. The coordinates of u are returned as a sequence Q = [a1, ..., ak] of elements from the alphabet of C so that u = a1 * C.1 + ... + ak * C.k.
Parent(w): ModTupRngElt -> ModTupRng
Given a word w belonging to the code C, return the ambient space V of C.
Rotate(u, k) : ModTupRngElt, RngIntElt -> ModTupRngElt
Given a vector u, return the vector obtained from u by cyclically shifting its components to the right by k coordinate positions.
Rotate(~u, k) : ModTupRngElt, RngIntElt ->
Given a vector u, destructively rotate u by k coordinate positions.
Trace(u, S) : ModTupFldElt, FldFin -> ModTupFldElt
Trace(u) : ModTupFldElt -> ModTupFldElt
Given a vector u with components in K, and a subfield S of K, construct the vector with components in S obtained from u by taking the trace of each component with respect to S. If S is omitted, it is taken to be the prime field of K.

Example CodeFld_Coordinates (H161E12)

We create a specific code word in the length 5 even weight code, after a failed attempt to create a code word of odd weight. We then display its support, find its coordinates with respect to the basis and then confirm it by way of re-construction.
> C := EvenWeightCode(5);
> C![1,1,0,1,0];
>> C![1,1,0,1,0];
    ^
Runtime error in '!': Result is not in the given structure
> c := C![1,1,0,1,1];
> c;
(1 1 0 1 1)
> Support(c);
{ 1, 2, 4, 5 }
> Coordinates(C,c);
[ 1, 1, 0, 1 ]
> C.1 + C.2 + C.4;
(1 1 0 1 1)

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 = Rn, a positive integer i, 1 ≤i≤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.
V2.28, 13 July 2023