Codeword( obj [, n] [, F] )
Codeword
returns a codeword or a list of codewords constructed from
obj. The object obj can be a vector, a string, a polynomial or a
codeword. It may also be a list of those (even a mixed list).
If a number n is specified, all constructed codewords have length n. This is the only way to make sure that all elements of obj are converted to codewords of the same length. Elements of obj that are longer than n are reduced in length by cutting of the last positions. Elements of obj that are shorter than n are lengthened by adding zeros at the end. If no n is specified, each constructed codeword is handled individually.
If a Galois field F is specified, all codewords are constructed over
this field. This is the only way to make sure that all elements of obj
are converted to the same field F (otherwise they are converted one by
one). Note that all elements of obj must have elements over F or over
Integers
. Converting from one Galois field to another is not
allowed. If no F is specified, vectors or strings with integer elements
will be converted to the smallest Galois field possible.
Note that a significant speed increase is achieved if F is specified, even when all elements of obj already have elements over F.
Every vector in obj can be a finite field vector over F or a vector
over Integers
. In the last case, it is converted to F or, if omitted,
to the smallest Galois field possible.
Every string in obj must be a string of numbers, without spaces, commas or any other characters. These numbers must be from 0 to 9. The string is converted to a codeword over F or, if F is omitted, over the smallest Galois field possible. Note that since all numbers in the string are interpreted as one-digit numbers, Galois fields of size larger than 10 are not properly represented when using strings.
Every polynomial in obj is converted to a codeword of length n or, if omitted, of a length dictated by the degree of the polynomial. If F is specified, a polynomial in obj must be over F.
Every element of obj that is already a codeword is changed to a codeword of length n. If no n was specified, the codeword doesn't change. If F is specified, the codeword must have base field F.
gap> c := Codeword([0,1,1,1,0]); [ 0 1 1 1 0 ] gap> Field(c); GF(2) gap> c2 := Codeword([0,1,1,1,0], GF(3)); [ 0 1 1 1 0 ] gap> Field(c2); GF(3) gap> Codeword([c, c2, "0110"]); [ [ 0 1 1 1 0 ], [ 0 1 1 1 0 ], [ 0 1 1 0 ] ] gap> p := Polynomial(GF(2), [Z(2)^0, 0*Z(2), Z(2)^0]); Z(2)^0*(X(GF(2))^2 + 1) gap> Codeword(p); x^2 + 1
Codeword( obj, C )
In this format, the elements of obj are converted to elements of the
same vector space as the elements of a code C. This is the same as
calling Codeword
with the word length of C (which is n) and the
field of C (which is F).
gap> C := WholeSpaceCode(7,GF(5)); a cyclic [7,7,1]0 whole space code over GF(5) gap> Codeword(["0220110", [1,1,1]], C); [ [ 0 2 2 0 1 1 0 ], [ 1 1 1 0 0 0 0 ] ] gap> Codeword(["0220110", [1,1,1]], 7, GF(5)); [ [ 0 2 2 0 1 1 0 ], [ 1 1 1 0 0 0 0 ] ]
GAP 3.4.4