  
  [1m[4m[31m3. Codewords[0m
  
  Let GF(q) denote a finite field with q (a prime power) elements. A [22m[36mcode[0m is a
  subset C of some finite-dimensional vector space V over GF(q). The [22m[36mlength[0m of
  C  is the dimension of V. Usually, V=GF(q)^n and the length is the number of
  coordinate  entries.  When  C is itself a vector space over GF(q) then it is
  called  a  [22m[36mlinear  code[0m  and the [22m[36mdimension[0m of C is its dimension as a vector
  space over GF(q).
  
  In  [1mGUAVA[0m, a `codeword' is a [1mGAP[0m record, with one of its components being an
  element in V. Likewise, a `code' is a [1mGAP[0m record, with one of its components
  being a subset (or subspace with given basis, if C is linear) of V.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35m  gap> C:=RandomLinearCode(20,10,GF(4));[0m
    [22m[35m  a  [20,10,?] randomly generated code over GF(4)[0m
    [22m[35m  gap> c:=Random(C);[0m
    [22m[35m  [ 1 a 0 0 0 1 1 a^2 0 0 a 1 1 1 a 1 1 a a 0 ][0m
    [22m[35m  gap> NamesOfComponents(C);[0m
    [22m[35m  [ "LeftActingDomain", "GeneratorsOfLeftOperatorAdditiveGroup", "WordLength",[0m
    [22m[35m    "GeneratorMat", "name", "Basis", "NiceFreeLeftModule", "Dimension", [0m
    [22m[35m     "Representative", "ZeroImmutable" ][0m
    [22m[35m  gap> NamesOfComponents(c);[0m
    [22m[35m  [ "VectorCodeword", "WordLength", "treatAsPoly" ][0m
    [22m[35m  gap> c!.VectorCodeword;[0m
    [22m[35m  [ immutable compressed vector length 20 over GF(4) ] [0m
    [22m[35m  gap> Display(last);[0m
    [22m[35m  [ Z(2^2), Z(2^2), Z(2^2), Z(2)^0, Z(2^2), Z(2^2)^2, 0*Z(2), Z(2^2), Z(2^2),[0m
    [22m[35m    Z(2)^0, Z(2^2)^2, 0*Z(2), 0*Z(2), Z(2^2), 0*Z(2), 0*Z(2), 0*Z(2), Z(2^2)^2,[0m
    [22m[35m    Z(2)^0, 0*Z(2) ][0m
    [22m[35m  gap> C!.Dimension;[0m
    [22m[35m  10[0m
  [22m[35m------------------------------------------------------------------[0m
  
  Mathematically,  a  `codeword'  is  an element of a code C, but in [1mGUAVA[0m the
  [22m[32mCodeword[0m and [22m[32mVectorCodeword[0m commands have implementations which do not check
  if  the  codeword  belongs  to C (i.e., are independent of the code itself).
  They  exist  primarily  to  make  it  easier for the user to construct a the
  associated [1mGAP[0m record. Using these commands, one can enter into a [1mGAP[0m both a
  codeword c (belonging to C) and a received word r (not belonging to C) using
  the  same  command.  The  user  can input codewords in different formats (as
  strings, vectors, and polynomials), and output information is formatted in a
  readable way.
  
  A codeword c in a linear code C arises in practice by an initial encoding of
  a  'block'  message  m,  adding  enough  redundancy  to recover m after c is
  transmitted  via a 'noisy' communication medium. In [1mGUAVA[0m, for linear codes,
  the  map mlongmapsto c is computed using the command [22m[32mc:=m*C[0m and recovering m
  from  c  is obtained by the command [22m[32mInformationWord(c,C)[0m. These commands are
  explained more below.
  
  Many  operations  are  available on codewords themselves, although codewords
  also work together with codes (see chapter [1m4.[0m on Codes).
  
  The  first  section  describes  how  codewords are constructed (see [1m[34mCodeword[0m
  ([1m3.1-1[0m)   and  [1m[34mIsCodeword[0m  ([1m3.1-3[0m)).  Sections  [1m3.2[0m  and  [1m3.3[0m  describe  the
  arithmetic   operations   applicable  to  codewords.  Section  [1m3.4[0m  describe
  functions  that  convert  codewords  back  to  vectors  or  polynomials (see
  [1m[34mVectorCodeword[0m  ([1m3.4-1[0m) and [1m[34mPolyCodeword[0m ([1m3.4-2[0m)). Section [1m???Functions that
  Change  the Display Form of a Codeword???[0m describe functions that change the
  way  a  codeword  is  displayed  (see  [1m[34mTreatAsVector[0m ([1m3.5-1[0m) and [1m[34mTreatAsPoly[0m
  ([1m3.5-2[0m)).  Finally, Section [1m3.6[0m describes a function to generate a null word
  (see  [1m[34mNullWord[0m  ([1m3.6-1[0m))  and  some  functions  for extracting properties of
  codewords  (see [1m[34mDistanceCodeword[0m ([1m3.6-2[0m), [1m[34mSupport[0m ([1m3.6-3[0m) and [1m[34mWeightCodeword[0m
  ([1m3.6-4[0m)).
  
  
  [1m[4m[31m3.1 Construction of Codewords[0m
  
  [1m[4m[31m3.1-1 Codeword[0m
  
  [1m[34m> Codeword( [0m[22m[34mobj[, n][,][F][0m[1m[34m ) _______________________________________[0mfunction
  
  [22m[32mCodeword[0m returns a codeword or a list of codewords constructed from [22m[34mobj[0m. The
  object  [22m[34mobj[0m  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 [22m[34mn[0m is specified, all constructed codewords have length [22m[34mn[0m. This is
  the  only  way  to  make  sure  that  all  elements  of [22m[34mobj[0m are converted to
  codewords  of  the  same  length. Elements of [22m[34mobj[0m that are longer than [22m[34mn[0m are
  reduced in length by cutting of the last positions. Elements of [22m[34mobj[0m that are
  shorter  than  [22m[34mn[0m  are  lengthened  by  adding  zeros  at the end. If no [22m[34mn[0m is
  specified, each constructed codeword is handled individually.
  
  If  a  Galois  field [22m[34mF[0m is specified, all codewords are constructed over this
  field.  This  is  the  only  way  to  make sure that all elements of [22m[34mobj[0m are
  converted  to  the  same  field [22m[34mF[0m (otherwise they are converted one by one).
  Note  that all elements of [22m[34mobj[0m must have elements over [22m[34mF[0m or over `Integers'.
  Converting  from  one  Galois  field  to  another is not allowed. If no [22m[34mF[0m 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 [22m[34mF[0m is specified, even
  when all elements of [22m[34mobj[0m already have elements over [22m[34mF[0m.
  
  Every  vector  in  [22m[34mobj[0m  can be a finite field vector over [22m[34mF[0m or a vector over
  `Integers'.  In  the  last case, it is converted to [22m[34mF[0m or, if omitted, to the
  smallest Galois field possible.
  
  Every  string  in [22m[34mobj[0m 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 [22m[34mF[0m or, if [22m[34mF[0m 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. In fact, no finite field of size larger than
  11 arises in this fashion at all.
  
  Every  polynomial  in  [22m[34mobj[0m  is  converted  to  a codeword of length [22m[34mn[0m or, if
  omitted,  of  a  length  dictated  by  the degree of the polynomial. If [22m[34mF[0m is
  specified, a polynomial in [22m[34mobj[0m must be over [22m[34mF[0m.
  
  Every  element of [22m[34mobj[0m that is already a codeword is changed to a codeword of
  length  [22m[34mn[0m.  If  no  [22m[34mn[0m  was  specified,  the codeword doesn't change. If [22m[34mF[0m is
  specified, the codeword must have base field [22m[34mF[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> c := Codeword([0,1,1,1,0]);[0m
    [22m[35m[ 0 1 1 1 0 ][0m
    [22m[35mgap> VectorCodeword( c ); [0m
    [22m[35m[ 0*Z(2), Z(2)^0, Z(2)^0, Z(2)^0, 0*Z(2) ][0m
    [22m[35mgap> c2 := Codeword([0,1,1,1,0], GF(3));[0m
    [22m[35m[ 0 1 1 1 0 ][0m
    [22m[35mgap> VectorCodeword( c2 );[0m
    [22m[35m[ 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, 0*Z(3) ][0m
    [22m[35mgap> Codeword([c, c2, "0110"]);[0m
    [22m[35m[ [ 0 1 1 1 0 ], [ 0 1 1 1 0 ], [ 0 1 1 0 ] ][0m
    [22m[35mgap> p := UnivariatePolynomial(GF(2), [Z(2)^0, 0*Z(2), Z(2)^0]);[0m
    [22m[35mZ(2)^0+x_1^2[0m
    [22m[35mgap> Codeword(p);[0m
    [22m[35mx^2 + 1 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  This  command  can  also be called using the syntax [22m[32mCodeword(obj,C)[0m. In this
  format,  the  elements  of [22m[34mobj[0m are converted to elements of the same ambient
  vector  space  as the elements of a code [22m[34mC[0m. The command [22m[32mCodeword(c,C)[0m is the
  same  as  calling [22m[32mCodeword(c,n,F)[0m, where [22m[34mn[0m is the word length of [22m[34mC[0m and the [22m[34mF[0m
  is the ground field of [22m[34mC[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := WholeSpaceCode(7,GF(5));[0m
    [22m[35ma cyclic [7,7,1]0 whole space code over GF(5)[0m
    [22m[35mgap> Codeword(["0220110", [1,1,1]], C);[0m
    [22m[35m[ [ 0 2 2 0 1 1 0 ], [ 1 1 1 0 0 0 0 ] ][0m
    [22m[35mgap> Codeword(["0220110", [1,1,1]], 7, GF(5));[0m
    [22m[35m[ [ 0 2 2 0 1 1 0 ], [ 1 1 1 0 0 0 0 ] ] [0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(3));[0m
    [22m[35ma linear [10,5,1..3]3..5 random linear code over GF(3)[0m
    [22m[35mgap> Codeword("1000000000",C);[0m
    [22m[35m[ 1 0 0 0 0 0 0 0 0 0 ][0m
    [22m[35mgap> Codeword("1000000000",10,GF(3));[0m
    [22m[35m[ 1 0 0 0 0 0 0 0 0 0 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.1-2 CodewordNr[0m
  
  [1m[34m> CodewordNr( [0m[22m[34mC, list[0m[1m[34m ) ____________________________________________[0mfunction
  
  [22m[32mCodewordNr[0m  returns a list of codewords of [22m[34mC[0m. [22m[34mlist[0m may be a list of integers
  or a single integer. For each integer of [22m[34mlist[0m, the corresponding codeword of
  [22m[34mC[0m  is  returned.  The  correspondence  of  a  number  i  with  a codeword is
  determined  as  follows:  if  a list of elements of [22m[34mC[0m is available, the i^th
  element  is taken. Otherwise, it is calculated by multiplication of the i^th
  information  vector  by  the generator matrix or generator polynomial, where
  the  information  vectors  are ordered lexicographically. In particular, the
  returned  codeword(s) could be a vector or a polynomial. So [22m[32mCodewordNr(C, i)[0m
  is  equal  to [22m[32mAsSSortedList(C)[i][0m, described in the next chapter. The latter
  function  first calculates the set of all the elements of C and then returns
  the  i^th  element  of that set, whereas the former only calculates the i^th
  codeword.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> B := BinaryGolayCode();[0m
    [22m[35ma cyclic [23,12,7]3 binary Golay code over GF(2)[0m
    [22m[35mgap> c := CodewordNr(B, 4);[0m
    [22m[35mx^22 + x^20 + x^17 + x^14 + x^13 + x^12 + x^11 + x^10[0m
    [22m[35mgap> R := ReedSolomonCode(2,2);[0m
    [22m[35ma cyclic [2,1,2]1 Reed-Solomon code over GF(3)[0m
    [22m[35mgap> AsSSortedList(R);[0m
    [22m[35m[ [ 0 0 ], [ 1 1 ], [ 2 2 ] ][0m
    [22m[35mgap> CodewordNr(R, [1,3]);[0m
    [22m[35m[ [ 0 0 ], [ 2 2 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.1-3 IsCodeword[0m
  
  [1m[34m> IsCodeword( [0m[22m[34mobj[0m[1m[34m ) ________________________________________________[0mfunction
  
  [22m[32mIsCodeword[0m  returns `true' if [22m[34mobj[0m, which can be an object of arbitrary type,
  is  of  the codeword type and `false' otherwise. The function will signal an
  error if [22m[34mobj[0m is an unbound variable.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> IsCodeword(1);[0m
    [22m[35mfalse[0m
    [22m[35mgap> IsCodeword(ReedMullerCode(2,3));[0m
    [22m[35mfalse[0m
    [22m[35mgap> IsCodeword("11111");[0m
    [22m[35mfalse[0m
    [22m[35mgap> IsCodeword(Codeword("11111"));[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m3.2 Comparisons of Codewords[0m
  
  [1m[4m[31m3.2-1 =[0m
  
  [1m[34m> =( [0m[22m[34mc1, c2[0m[1m[34m ) ______________________________________________________[0mfunction
  
  The equality operator [22m[32mc1 = c2[0m evaluates to `true' if the codewords [22m[34mc1[0m and [22m[34mc2[0m
  are  equal,  and  to `false' otherwise. Note that codewords are equal if and
  only  if  their  base  vectors  are equal. Whether they are represented as a
  vector or polynomial has nothing to do with the comparison.
  
  Comparing codewords with objects of other types is not recommended, although
  it  is  possible.  If  [22m[34mc2[0m  is  the  codeword,  the  other object [22m[34mc1[0m is first
  converted  to  a  codeword,  after which comparison is possible. This way, a
  codeword  can be compared with a vector, polynomial, or string. If [22m[34mc1[0m is the
  codeword,  then  problems may arise if [22m[34mc2[0m is a polynomial. In that case, the
  comparison  always  yields  a  `false', because the polynomial comparison is
  called.
  
  The  equality operator is also denoted [22m[32mEQ[0m, and [22m[32mEQ(c1,c2)[0m is the same as [22m[32mc1 =
  c2[0m. There is also an inequality operator, < >, or [22m[32mnot EQ[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> P := UnivariatePolynomial(GF(2), Z(2)*[1,0,0,1]);[0m
    [22m[35mZ(2)^0+x_1^3[0m
    [22m[35mgap> c := Codeword(P, GF(2));[0m
    [22m[35mx^3 + 1[0m
    [22m[35mgap> P = c;        # codeword operation[0m
    [22m[35mtrue[0m
    [22m[35mgap> c2 := Codeword("1001", GF(2));[0m
    [22m[35m[ 1 0 0 1 ][0m
    [22m[35mgap> c = c2;[0m
    [22m[35mtrue [0m
    [22m[35mgap> C:=HammingCode(3);[0m
    [22m[35ma linear [7,4,3]1 Hamming (3,2) code over GF(2)[0m
    [22m[35mgap> c1:=Random(C);[0m
    [22m[35m[ 1 0 0 1 1 0 0 ][0m
    [22m[35mgap> c2:=Random(C);[0m
    [22m[35m[ 0 1 0 0 1 0 1 ][0m
    [22m[35mgap> EQ(c1,c2);[0m
    [22m[35mfalse[0m
    [22m[35mgap> not EQ(c1,c2);[0m
    [22m[35mtrue[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m3.3 Arithmetic Operations for Codewords[0m
  
  [1m[4m[31m3.3-1 +[0m
  
  [1m[34m> +( [0m[22m[34mc1, c2[0m[1m[34m ) ______________________________________________________[0mfunction
  
  The  following  operations  are always available for codewords. The operands
  must  have  a  common base field, and must have the same length. No implicit
  conversions are performed.
  
  The operator [22m[32m+[0m evaluates to the sum of the codewords [22m[34mc1[0m and [22m[34mc2[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(3));[0m
    [22m[35ma linear [10,5,1..3]3..5 random linear code over GF(3)[0m
    [22m[35mgap> c:=Random(C);[0m
    [22m[35m[ 1 0 2 2 2 2 1 0 2 0 ][0m
    [22m[35mgap> Codeword(c+"2000000000");[0m
    [22m[35m[ 0 0 2 2 2 2 1 0 2 0 ][0m
    [22m[35mgap> Codeword(c+"1000000000");[0m
  [22m[35m------------------------------------------------------------------[0m
  
  The  last  command  returns  a  [1mGAP[0m  ERROR  since the `codeword' which [1mGUAVA[0m
  associates to "1000000000" belongs to GF(2) and not GF(3).
  
  [1m[4m[31m3.3-2 -[0m
  
  [1m[34m> -( [0m[22m[34mc1, c2[0m[1m[34m ) ______________________________________________________[0mfunction
  
  Similar  to  addition:  the  operator  [22m[32m-[0m  evaluates to the difference of the
  codewords [22m[34mc1[0m and [22m[34mc2[0m.
  
  [1m[4m[31m3.3-3 +[0m
  
  [1m[34m> +( [0m[22m[34mv, C[0m[1m[34m ) ________________________________________________________[0mfunction
  
  The  operator  [22m[32mv+C[0m  evaluates  to  the  coset  code of code [22m[34mC[0m after adding a
  `codeword'  [22m[34mv[0m to all codewords in [22m[34mC[0m. Note that if c in C then mathematically
  c+C=C but [1mGUAVA[0m only sees them equal as [22m[36msets[0m. See [1m[34mCosetCode[0m ([1m6.1-16[0m).
  
  Note that the command [22m[32mC+v[0m returns the same output as the command [22m[32mv+C[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5);[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> c:=Random(C);[0m
    [22m[35m[ 0 0 0 0 0 0 0 0 0 0 ][0m
    [22m[35mgap> c+C;[0m
    [22m[35m[ add. coset of a  [10,5,?] randomly generated code over GF(2) ][0m
    [22m[35mgap> c+C=C;[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsLinearCode(c+C);[0m
    [22m[35mfalse[0m
    [22m[35mgap> v:=Codeword("100000000");[0m
    [22m[35m[ 1 0 0 0 0 0 0 0 0 ][0m
    [22m[35mgap> v+C;[0m
    [22m[35m[ add. coset of a  [10,5,?] randomly generated code over GF(2) ][0m
    [22m[35mgap> C=v+C;[0m
    [22m[35mfalse[0m
    [22m[35mgap> C := GeneratorMatCode( [ [1, 0,0,0], [0, 1,0,0] ], GF(2) );[0m
    [22m[35ma linear [4,2,1]1 code defined by generator matrix over GF(2)[0m
    [22m[35mgap> Elements(C);[0m
    [22m[35m[ [ 0 0 0 0 ], [ 0 1 0 0 ], [ 1 0 0 0 ], [ 1 1 0 0 ] ][0m
    [22m[35mgap> v:=Codeword("0011");[0m
    [22m[35m[ 0 0 1 1 ][0m
    [22m[35mgap> C+v;[0m
    [22m[35m[ add. coset of a linear [4,2,4]1 code defined by generator matrix over GF(2) ][0m
    [22m[35mgap> Elements(C+v);[0m
    [22m[35m[ [ 0 0 1 1 ], [ 0 1 1 1 ], [ 1 0 1 1 ], [ 1 1 1 1 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  In general, the operations just described can also be performed on codewords
  expressed   as  vectors,  strings  or  polynomials,  although  this  is  not
  recommended.  The  vector,  string  or  polynomial  is  first converted to a
  codeword,  after  which  the  normal  operation is performed. For this to go
  right,  make  sure  that at least one of the operands is a codeword. Further
  more, it will not work when the right operand is a polynomial. In that case,
  the  polynomial operations ([22m[32mFiniteFieldPolynomialOps[0m) are called, instead of
  the codeword operations ([22m[32mCodewordOps[0m).
  
  Some other code-oriented operations with codewords are described in [1m4.2[0m.
  
  
  [1m[4m[31m3.4 Functions that Convert Codewords to Vectors or Polynomials[0m
  
  [1m[4m[31m3.4-1 VectorCodeword[0m
  
  [1m[34m> VectorCodeword( [0m[22m[34mobj[0m[1m[34m ) ____________________________________________[0mfunction
  
  Here  [22m[34mobj[0m  can be a code word or a list of code words. This function returns
  the corresponding vectors over a finite field.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> a := Codeword("011011");; [0m
    [22m[35mgap> VectorCodeword(a);[0m
    [22m[35m[ 0*Z(2), Z(2)^0, Z(2)^0, 0*Z(2), Z(2)^0, Z(2)^0 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.4-2 PolyCodeword[0m
  
  [1m[34m> PolyCodeword( [0m[22m[34mobj[0m[1m[34m ) ______________________________________________[0mfunction
  
  [22m[32mPolyCodeword[0m  returns  a  polynomial  or a list of polynomials over a Galois
  field,  converted  from  [22m[34mobj[0m. The object [22m[34mobj[0m can be a codeword, or a list of
  codewords.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> a := Codeword("011011");; [0m
    [22m[35mgap> PolyCodeword(a);[0m
    [22m[35mx_1+x_1^2+x_1^4+x_1^5[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m3.5 Functions that Change the Display Form of a Codeword[0m
  
  [1m[4m[31m3.5-1 TreatAsVector[0m
  
  [1m[34m> TreatAsVector( [0m[22m[34mobj[0m[1m[34m ) _____________________________________________[0mfunction
  
  [22m[32mTreatAsVector[0m  adapts  the codewords in [22m[34mobj[0m to make sure they are printed as
  vectors.  [22m[34mobj[0m may be a codeword or a list of codewords. Elements of [22m[34mobj[0m that
  are  not codewords are ignored. After this function is called, the codewords
  will  be  treated as vectors. The vector representation is obtained by using
  the coefficient list of the polynomial.
  
  Note  that  this  [22m[36monly[0m  changes the way a codeword is [22m[36mprinted[0m. [22m[32mTreatAsVector[0m
  returns  nothing,  it  is  called  only  for  its  side effect. The function
  [22m[32mVectorCodeword[0m converts codewords to vectors (see [1m[34mVectorCodeword[0m ([1m3.4-1[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> B := BinaryGolayCode();[0m
    [22m[35ma cyclic [23,12,7]3 binary Golay code over GF(2)[0m
    [22m[35mgap> c := CodewordNr(B, 4);[0m
    [22m[35mx^22 + x^20 + x^17 + x^14 + x^13 + x^12 + x^11 + x^10[0m
    [22m[35mgap> TreatAsVector(c);[0m
    [22m[35mgap> c;[0m
    [22m[35m[ 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 1 0 1 ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.5-2 TreatAsPoly[0m
  
  [1m[34m> TreatAsPoly( [0m[22m[34mobj[0m[1m[34m ) _______________________________________________[0mfunction
  
  [22m[32mTreatAsPoly[0m  adapts  the  codewords  in [22m[34mobj[0m to make sure they are printed as
  polynomials.  [22m[34mobj[0m  may be a codeword or a list of codewords. Elements of [22m[34mobj[0m
  that  are  not  codewords  are  ignored.  After this function is called, the
  codewords  will  be  treated  as  polynomials.  The finite field vector that
  defines  the  codeword  is  used  as  a  coefficient  list of the polynomial
  representation,  where the first element of the vector is the coefficient of
  degree zero, the second element is the coefficient of degree one, etc, until
  the last element, which is the coefficient of highest degree.
  
  Note  that  this  [22m[36monly[0m  changes  the  way a codeword is [22m[36mprinted[0m. [22m[32mTreatAsPoly[0m
  returns  nothing,  it  is  called  only  for  its  side effect. The function
  [22m[32mPolyCodeword[0m converts codewords to polynomials (see [1m[34mPolyCodeword[0m ([1m3.4-2[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> a := Codeword("00001",GF(2));[0m
    [22m[35m[ 0 0 0 0 1 ][0m
    [22m[35mgap> TreatAsPoly(a); a;[0m
    [22m[35mx^4[0m
    [22m[35mgap> b := NullWord(6,GF(4));[0m
    [22m[35m[ 0 0 0 0 0 0 ][0m
    [22m[35mgap> TreatAsPoly(b); b;[0m
    [22m[35m0 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m3.6 Other Codeword Functions[0m
  
  [1m[4m[31m3.6-1 NullWord[0m
  
  [1m[34m> NullWord( [0m[22m[34mn, F[0m[1m[34m ) _________________________________________________[0mfunction
  
  Other  uses:  [22m[32mNullWord(  n  )[0m  (default F=GF(2)) and [22m[32mNullWord( C )[0m. [22m[32mNullWord[0m
  returns a codeword of length [22m[34mn[0m over the field [22m[34mF[0m of only zeros. The integer [22m[34mn[0m
  must  be  greater  then  zero.  If only a code [22m[34mC[0m is specified, [22m[32mNullWord[0m will
  return a null word with both the word length and the Galois field of [22m[34mC[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> NullWord(8);[0m
    [22m[35m[ 0 0 0 0 0 0 0 0 ][0m
    [22m[35mgap> Codeword("0000") = NullWord(4);[0m
    [22m[35mtrue[0m
    [22m[35mgap> NullWord(5,GF(16));[0m
    [22m[35m[ 0 0 0 0 0 ][0m
    [22m[35mgap> NullWord(ExtendedTernaryGolayCode());[0m
    [22m[35m[ 0 0 0 0 0 0 0 0 0 0 0 0 ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.6-2 DistanceCodeword[0m
  
  [1m[34m> DistanceCodeword( [0m[22m[34mc1, c2[0m[1m[34m ) _______________________________________[0mfunction
  
  [22m[32mDistanceCodeword[0m  returns the Hamming distance from [22m[34mc1[0m to [22m[34mc2[0m. Both variables
  must  be  codewords  with  equal word length over the same Galois field. The
  Hamming  distance  between  two  words is the number of places in which they
  differ. As a result, [22m[32mDistanceCodeword[0m always returns an integer between zero
  and the word length of the codewords.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> a := Codeword([0, 1, 2, 0, 1, 2]);; b := NullWord(6, GF(3));;[0m
    [22m[35mgap> DistanceCodeword(a, b);[0m
    [22m[35m4[0m
    [22m[35mgap> DistanceCodeword(b, a);[0m
    [22m[35m4[0m
    [22m[35mgap> DistanceCodeword(a, a);[0m
    [22m[35m0 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.6-3 Support[0m
  
  [1m[34m> Support( [0m[22m[34mc[0m[1m[34m ) _____________________________________________________[0mfunction
  
  [22m[32mSupport[0m  returns  a set of integers indicating the positions of the non-zero
  entries in a codeword [22m[34mc[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> a := Codeword("012320023002");; Support(a);[0m
    [22m[35m[ 2, 3, 4, 5, 8, 9, 12 ][0m
    [22m[35mgap> Support(NullWord(7));[0m
    [22m[35m[  ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  The  support  of a list with codewords can be calculated by taking the union
  of  the  individual supports. The weight of the support is the length of the
  set.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> L := Codeword(["000000", "101010", "222000"], GF(3));;[0m
    [22m[35mgap> S := Union(List(L, i -> Support(i)));[0m
    [22m[35m[ 1, 2, 3, 5 ][0m
    [22m[35mgap> Length(S);[0m
    [22m[35m4 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m3.6-4 WeightCodeword[0m
  
  [1m[34m> WeightCodeword( [0m[22m[34mc[0m[1m[34m ) ______________________________________________[0mfunction
  
  [22m[32mWeightCodeword[0m  returns  the  weight of a codeword c, the number of non-zero
  entries  in [22m[34mc[0m. As a result, [22m[32mWeightCodeword[0m always returns an integer between
  zero and the word length of the codeword.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> WeightCodeword(Codeword("22222"));[0m
    [22m[35m5[0m
    [22m[35mgap> WeightCodeword(NullWord(3));[0m
    [22m[35m0[0m
    [22m[35mgap> C := HammingCode(3);[0m
    [22m[35ma linear [7,4,3]1 Hamming (3,2) code over GF(2)[0m
    [22m[35mgap> Minimum(List(AsSSortedList(C){[2..Size(C)]}, WeightCodeword ) );[0m
    [22m[35m3 [0m
  [22m[35m------------------------------------------------------------------[0m
  
