  
  [1m[4m[31m5. Generating Codes[0m
  
  In this chapter we describe functions for generating codes.
  
  Section [1m5.1[0m describes functions for generating unrestricted codes.
  
  Section [1m5.2[0m describes functions for generating linear codes.
  
  Section  [1m5.3[0m  describes  functions  for constructing certain covering codes,
  such as the Gabidulin codes.
  
  Section [1m5.4[0m describes functions for constructing the Golay codes.
  
  Section [1m5.5[0m describes functions for generating cyclic codes.
  
  Section  [1m5.6[0m  describes  functions  for  generating codes as the image of an
  evaluation  map  applied  to  a space of functions. For example, generalized
  Reed-Solomon codes and toric codes are described there.
  
  
  [1m[4m[31m5.1 Generating Unrestricted Codes[0m
  
  In this section we start with functions that creating code from user defined
  matrices   or  special  matrices  (see  [1m[34mElementsCode[0m  ([1m5.1-1[0m),  [1m[34mHadamardCode[0m
  ([1m5.1-2[0m),  [1m[34mConferenceCode[0m  ([1m5.1-3[0m)  and  [1m[34mMOLSCode[0m  ([1m5.1-4[0m)).  These codes are
  unrestricted codes; they may later be discovered to be linear or cyclic.
  
  The  next  functions  generate random codes (see [1m[34mRandomCode[0m ([1m5.1-5[0m)) and the
  Nordstrom-Robinson code (see [1m[34mNordstromRobinsonCode[0m ([1m5.1-6[0m)), respectively.
  
  Finally,  we  describe  two functions for generating Greedy codes. These are
  codes  that  contructed  by gathering codewords from a space (see [1m[34mGreedyCode[0m
  ([1m5.1-7[0m) and [1m[34mLexiCode[0m ([1m5.1-8[0m)).
  
  [1m[4m[31m5.1-1 ElementsCode[0m
  
  [1m[34m> ElementsCode( [0m[22m[34mL[, name,] F[0m[1m[34m ) _____________________________________[0mfunction
  
  [22m[32mElementsCode[0m  creates an unrestricted code of the list of elements [22m[34mL[0m, in the
  field  [22m[34mF[0m.  [22m[34mL[0m  must  be a list of vectors, strings, polynomials or codewords.
  [22m[34mname[0m can contain a short description of the code.
  
  If  [22m[34mL[0m  contains a codeword more than once, it is removed from the list and a
  [1mGAP[0m set is returned.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> M := Z(3)^0 * [ [1, 0, 1, 1], [2, 2, 0, 0], [0, 1, 2, 2] ];;[0m
    [22m[35mgap> C := ElementsCode( M, "example code", GF(3) );[0m
    [22m[35ma (4,3,1..4)2 example code over GF(3)[0m
    [22m[35mgap> MinimumDistance( C );[0m
    [22m[35m4[0m
    [22m[35mgap> AsSSortedList( C );[0m
    [22m[35m[ [ 0 1 2 2 ], [ 1 0 1 1 ], [ 2 2 0 0 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.1-2 HadamardCode[0m
  
  [1m[34m> HadamardCode( [0m[22m[34mH[, t][0m[1m[34m ) ___________________________________________[0mfunction
  
  The four forms this command can take are [22m[32mHadamardCode(H,t)[0m, [22m[32mHadamardCode(H)[0m,
  [22m[32mHadamardCode(n,t)[0m, and [22m[32mHadamardCode(n)[0m.
  
  In  the case when the arguments [22m[34mH[0m and [22m[34mt[0m are both given, [22m[32mHadamardCode[0m returns
  a  Hadamard  code of the t^th kind from the Hadamard matrix [22m[34mH[0m In case only [22m[34mH[0m
  is given, t = 3 is used.
  
  By definition, a Hadamard matrix is a square matrix [22m[34mH[0m with H* H^T = -n* I_n,
  where n is the size of [22m[34mH[0m. The entries of [22m[34mH[0m are either 1 or -1.
  
  The  matrix [22m[34mH[0m is first transformed into a binary matrix A_n by replacing the
  1's by 0's and the -1's by 1s).
  
  The  Hadamard matrix of the [22m[36mfirst kind[0m (t=1) is created by using the rows of
  A_n  as  elements,  after deleting the first column. This is a (n-1, n, n/2)
  code.  We  use  this  code for creating the Hadamard code of the [22m[36msecond kind[0m
  (t=2), by adding all the complements of the already existing codewords. This
  results  in  a  (n-1,  2n,  n/2 -1) code. The [22m[36mthird kind[0m (t=3) is created by
  using  the  rows  of A_n (without cutting a column) and their complements as
  elements.  This  way,  we  have  an  (n, 2n, n/2)-code. The returned code is
  generally an unrestricted code, but for n = 2^r, the code is linear.
  
  The  command  [22m[32mHadamardCode(n,t)[0m  returns a Hadamard code with parameter [22m[34mn[0m of
  the t^th kind. For the command [22m[32mHadamardCode(n)[0m, t=3 is used.
  
  When  called  in  these  forms, [22m[32mHadamardCode[0m first creates a Hadamard matrix
  (see  [1m[34mHadamardMat[0m ([1m7.3-4[0m)), of size [22m[34mn[0m and then follows the same procedure as
  described  above.  Therefore  the same restrictions with respect to [22m[34mn[0m as for
  Hadamard matrices hold.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> H4 := [[1,1,1,1],[1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]];;[0m
    [22m[35mgap> HadamardCode( H4, 1 );[0m
    [22m[35ma (3,4,2)1 Hadamard code of order 4 over GF(2)[0m
    [22m[35mgap> HadamardCode( H4, 2 );[0m
    [22m[35ma (3,8,1)0 Hadamard code of order 4 over GF(2)[0m
    [22m[35mgap> HadamardCode( H4 );[0m
    [22m[35ma (4,8,2)1 Hadamard code of order 4 over GF(2) [0m
    [22m[35mgap> H4 := [[1,1,1,1],[1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]];;[0m
    [22m[35mgap> C := HadamardCode( 4 );[0m
    [22m[35ma (4,8,2)1 Hadamard code of order 4 over GF(2)[0m
    [22m[35mgap> C = HadamardCode( H4 );[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.1-3 ConferenceCode[0m
  
  [1m[34m> ConferenceCode( [0m[22m[34mH[0m[1m[34m ) ______________________________________________[0mfunction
  
  [22m[32mConferenceCode[0m  returns  a  code  of length n-1 constructed from a symmetric
  'conference  matrix' [22m[34mH[0m. A [22m[36mconference matrix[0m [22m[34mH[0m is a symmetric matrix of order
  n,  which  satisfies  H*  H^T  =  ((n-1)*  I,  with n = 2 mod 4. The rows of
  frac12(H+I+J),  frac12(-H+I+J),  plus the zero and all-ones vectors form the
  elements of a binary non-linear (n-1, 2n, (n-2)/2) code.
  
  [1mGUAVA[0m constructs a symmetric conference matrix of order n+1 (n= 1 mod 4) and
  uses  the  rows  of  that  matrix,  plus  the  zero and all-ones vectors, to
  construct a binary non-linear (n, 2(n+1), (n-1)/2)-code.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> H6 := [[0,1,1,1,1,1],[1,0,1,-1,-1,1],[1,1,0,1,-1,-1],[0m
    [22m[35m> [1,-1,1,0,1,-1],[1,-1,-1,1,0,1],[1,1,-1,-1,1,0]];;[0m
    [22m[35mgap> C1 := ConferenceCode( H6 );[0m
    [22m[35ma (5,12,2)1..4 conference code over GF(2)[0m
    [22m[35mgap> IsLinearCode( C1 );[0m
    [22m[35mfalse [0m
    [22m[35mgap> C2 := ConferenceCode( 5 );[0m
    [22m[35ma (5,12,2)1..4 conference code over GF(2)[0m
    [22m[35mgap> AsSSortedList( C2 );[0m
    [22m[35m[ [ 0 0 0 0 0 ], [ 0 0 1 1 1 ], [ 0 1 0 1 1 ], [ 0 1 1 0 1 ], [ 0 1 1 1 0 ], [0m
    [22m[35m  [ 1 0 0 1 1 ], [ 1 0 1 0 1 ], [ 1 0 1 1 0 ], [ 1 1 0 0 1 ], [ 1 1 0 1 0 ], [0m
    [22m[35m  [ 1 1 1 0 0 ], [ 1 1 1 1 1 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.1-4 MOLSCode[0m
  
  [1m[34m> MOLSCode( [0m[22m[34m[n,] q[0m[1m[34m ) _______________________________________________[0mfunction
  
  [22m[32mMOLSCode[0m  returns an (n, q^2, n-1) code over GF(q). The code is created from
  n-2  'Mutually  Orthogonal  Latin  Squares'  (MOLS)  of  size q times q. The
  default  for  [22m[34mn[0m  is  4. [1mGUAVA[0m can construct a MOLS code for n-2 <= q. Here [22m[34mq[0m
  must  be  a  prime  power,  q  >  2.  If  there are no n-2 MOLS, an error is
  signalled.
  
  Since  each  of  the  n-2 MOLS is a qtimes q matrix, we can create a code of
  size  q^2  by  listing in each code element the entries that are in the same
  position  in  each  of the MOLS. We precede each of these lists with the two
  coordinates that specify this position, making the word length become n.
  
  The MOLS codes are MDS codes (see [1m[34mIsMDSCode[0m ([1m3.3-7[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C1 := MOLSCode( 6, 5 );[0m
    [22m[35ma (6,25,5)3..4 code generated by 4 MOLS of order 5 over GF(5)[0m
    [22m[35mgap> mols := List( [1 .. WordLength(C1) - 2 ], function( nr )[0m
    [22m[35m>       local ls, el;[0m
    [22m[35m>       ls := NullMat( Size(LeftActingDomain(C1)), Size(LeftActingDomain(C1)) );[0m
    [22m[35m>       for el in VectorCodeword( AsSSortedList( C1 ) ) do[0m
    [22m[35m>          ls[IntFFE(el[1])+1][IntFFE(el[2])+1] := el[nr + 2];[0m
    [22m[35m>       od;[0m
    [22m[35m>       return ls;[0m
    [22m[35m>    end );;[0m
    [22m[35mgap> AreMOLS( mols );[0m
    [22m[35mtrue[0m
    [22m[35mgap> C2 := MOLSCode( 11 );[0m
    [22m[35ma (4,121,3)2 code generated by 2 MOLS of order 11 over GF(11) [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.1-5 RandomCode[0m
  
  [1m[34m> RandomCode( [0m[22m[34mn, M, F[0m[1m[34m ) ____________________________________________[0mfunction
  
  [22m[32mRandomCode[0m  returns  a random unrestricted code of size [22m[34mM[0m with word length [22m[34mn[0m
  over  [22m[34mF[0m. [22m[34mM[0m must be less than or equal to the number of elements in the space
  GF(q)^n.
  
  The   function   [22m[32mRandomLinearCode[0m   returns   a   random  linear  code  (see
  [1m[34mRandomLinearCode[0m ([1m5.2-11[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C1 := RandomCode( 6, 10, GF(8) );[0m
    [22m[35ma (6,10,1..6)4..6 random unrestricted code over GF(8)[0m
    [22m[35mgap> MinimumDistance(C1);[0m
    [22m[35m3[0m
    [22m[35mgap> C2 := RandomCode( 6, 10, GF(8) );[0m
    [22m[35ma (6,10,1..6)4..6 random unrestricted code over GF(8)[0m
    [22m[35mgap> C1 = C2;[0m
    [22m[35mfalse [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.1-6 NordstromRobinsonCode[0m
  
  [1m[34m> NordstromRobinsonCode( [0m[22m[34m[0m[1m[34m ) ________________________________________[0mfunction
  
  [22m[32mNordstromRobinsonCode[0m  returns a Nordstrom-Robinson code, the best code with
  word  length  n=16 and minimum distance d=6 over GF(2). This is a non-linear
  (16, 256, 6) code.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := NordstromRobinsonCode();[0m
    [22m[35ma (16,256,6)4 Nordstrom-Robinson code over GF(2)[0m
    [22m[35mgap> OptimalityCode( C );[0m
    [22m[35m0 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.1-7 GreedyCode[0m
  
  [1m[34m> GreedyCode( [0m[22m[34mL, d, F[0m[1m[34m ) ____________________________________________[0mfunction
  
  [22m[32mGreedyCode[0m  returns  a  Greedy  code  with design distance [22m[34md[0m over the finite
  field  [22m[34mF[0m.  The code is constructed using the greedy algorithm on the list of
  vectors  [22m[34mL[0m. (The greedy algorithm checks each vector in [22m[34mL[0m and adds it to the
  code  if  its distance to the current code is greater than or equal to [22m[34md[0m. It
  is obvious that the resulting code has a minimum distance of at least [22m[34md[0m.
  
  Greedy codes are often linear codes.
  
  The  function  [22m[32mLexiCode[0m  creates  a  greedy  code from a basis instead of an
  enumerated list (see [1m[34mLexiCode[0m ([1m5.1-8[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C1 := GreedyCode( Tuples( AsSSortedList( GF(2) ), 5 ), 3, GF(2) );[0m
    [22m[35ma (5,4,3..5)2 Greedy code, user defined basis over GF(2)[0m
    [22m[35mgap> C2 := GreedyCode( Permuted( Tuples( AsSSortedList( GF(2) ), 5 ),[0m
    [22m[35m>                         (1,4) ), 3, GF(2) );[0m
    [22m[35ma (5,4,3..5)2 Greedy code, user defined basis over GF(2)[0m
    [22m[35mgap> C1 = C2;[0m
    [22m[35mfalse [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.1-8 LexiCode[0m
  
  [1m[34m> LexiCode( [0m[22m[34mn, d, F[0m[1m[34m ) ______________________________________________[0mfunction
  
  In  this  format,  [22m[32mLexicode[0m  returns  a  lexicode with word length [22m[34mn[0m, design
  distance [22m[34md[0m over [22m[34mF[0m. The code is constructed using the greedy algorithm on the
  lexicographically ordered list of all vectors of length [22m[34mn[0m over [22m[34mF[0m. Every time
  a  vector is found that has a distance to the current code of at least [22m[34md[0m, it
  is  added  to  the  code.  This  results,  obviously, in a code with minimum
  distance greater than or equal to [22m[34md[0m.
  
  Another syntax which one can use is [22m[32mLexiCode( B, d, F )[0m. When called in this
  format,  [22m[32mLexiCode[0m  uses  the  basis  [22m[34mB[0m instead of the standard basis. [22m[34mB[0m is a
  matrix of vectors over [22m[34mF[0m. The code is constructed using the greedy algorithm
  on  the list of vectors spanned by [22m[34mB[0m, ordered lexicographically with respect
  to [22m[34mB[0m.
  
  Note that binary lexicodes are always linear.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := LexiCode( 4, 3, GF(5) );[0m
    [22m[35ma (4,17,3..4)2..4 lexicode over GF(5) [0m
    [22m[35mgap> B := [ [Z(2)^0, 0*Z(2), 0*Z(2)], [Z(2)^0, Z(2)^0, 0*Z(2)] ];;[0m
    [22m[35mgap> C := LexiCode( B, 2, GF(2) );[0m
    [22m[35ma linear [3,1,2]1..2 lexicode over GF(2) [0m
  [22m[35m------------------------------------------------------------------[0m
  
  The  function  [22m[32mGreedyCode[0m  creates a greedy code that is not restricted to a
  lexicographical order (see [1m[34mGreedyCode[0m ([1m5.1-7[0m)).
  
  
  [1m[4m[31m5.2 Generating Linear Codes[0m
  
  In  this  section  we  describe  functions  for constructing linear codes. A
  linear code always has a generator or check matrix.
  
  The  first  two  functions  generate  linear codes from the generator matrix
  ([1m[34mGeneratorMatCode[0m  ([1m5.2-1[0m))  or  check  matrix  ([1m[34mCheckMatCode[0m  ([1m5.2-3[0m)). All
  linear codes can be constructed with these functions.
  
  The  next functions we describe generate some well-known codes, like Hamming
  codes  ([1m[34mHammingCode[0m ([1m5.2-4[0m)), Reed-Muller codes ([1m[34mReedMullerCode[0m ([1m5.2-5[0m)) and
  the    extended    Golay    codes   ([1m[34mExtendedBinaryGolayCode[0m   ([1m5.4-2[0m)   and
  [1m[34mExtendedTernaryGolayCode[0m ([1m5.4-4[0m)).
  
  A  large and powerful family of codes are alternant codes. They are obtained
  by  a  small  modification  of  the  parity  check matrix of a BCH code (see
  [1m[34mAlternantCode[0m  ([1m5.2-6[0m), [1m[34mGoppaCode[0m ([1m5.2-7[0m), [1m[34mGeneralizedSrivastavaCode[0m ([1m5.2-8[0m)
  and [1m[34mSrivastavaCode[0m ([1m5.2-9[0m)).
  
  Finally,  we  describe  a  function  for generating random linear codes (see
  [1m[34mRandomLinearCode[0m ([1m5.2-11[0m)).
  
  [1m[4m[31m5.2-1 GeneratorMatCode[0m
  
  [1m[34m> GeneratorMatCode( [0m[22m[34mG[, name,] F[0m[1m[34m ) _________________________________[0mfunction
  
  [22m[32mGeneratorMatCode[0m  returns a linear code with generator matrix [22m[34mG[0m. [22m[34mG[0m must be a
  matrix  over  finite  field  [22m[34mF[0m.  [22m[34mname[0m can contain a short description of the
  code.  The  generator  matrix  is the basis of the elements of the code. The
  resulting code has word length n, dimension k if [22m[34mG[0m is a k times n-matrix. If
  GF(q)  is  the  field  of the code, the size of the code will be q^k. Before
  printing the information [n,k,d_1..d_2]r_1..r_2 about the code to the screen
  using  [22m[32mViewObj[0m  (an  undocumented  internal  [1mGUAVA[0m command), upper and lower
  estimates  for  the minimum distance and covering radius are computed. These
  estimates  are obtained as follows: first, if n and q are not too big, [1mGUAVA[0m
  searches  though  the  tables in the `tbl' subdirectory for best-known upper
  bounds.   This   can   be  time-consuming.  Otherwise,  [1mGUAVA[0m  simply  calls
  [22m[32mBoundsMinimumDistance[0m and [22m[32mBoundsCoveringRadius[0m.
  
  If  the generator matrix does not have full row rank, the linearly dependent
  rows are removed. This is done by the [1mGAP[0m function [22m[32mBaseMat[0m and results in an
  equal  code.  The  generator  matrix  can  be  retrieved  with  the function
  [22m[32mGeneratorMat[0m (see [1m[34mGeneratorMat[0m ([1m3.7-1[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> G := Z(3)^0 * [[1,0,1,2,0],[0,1,2,1,1],[0,0,1,2,1]];;[0m
    [22m[35mgap> C1 := GeneratorMatCode( G, GF(3) );[0m
    [22m[35ma linear [5,3,1..2]1..2 code defined by generator matrix over GF(3)[0m
    [22m[35mgap> C2 := GeneratorMatCode( IdentityMat( 5, GF(2) ), GF(2) );[0m
    [22m[35ma linear [5,5,1]0 code defined by generator matrix over GF(2)[0m
    [22m[35mgap> GeneratorMatCode( List( AsSSortedList( NordstromRobinsonCode() ),[0m
    [22m[35m> x -> VectorCodeword( x ) ), GF( 2 ) );[0m
    [22m[35ma linear [16,11,1..4]2 code defined by generator matrix over GF(2)[0m
    [22m[35m# This is the smallest linear code that contains the N-R code [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.2-2 GeneratorMatCodeNC[0m
  
  [1m[34m> GeneratorMatCodeNC( [0m[22m[34mG, F[0m[1m[34m ) _______________________________________[0mfunction
  
  [22m[32mGeneratorMatCodeNC[0m  returns  a  linear  code C with generator matrix [22m[34mG[0m. This
  command is the same as [22m[32mGeneratorMatCode[0m, except that (1) it does not compute
  upper  and  lower  bounds for the minimum distance or covering radius for C,
  and  (2)  it  does  not allow for an optional argument [22m[34mname[0m. This command is
  much faster than [22m[32mGeneratorMatCode[0m in some cases.
  
  [1m[4m[31m5.2-3 CheckMatCode[0m
  
  [1m[34m> CheckMatCode( [0m[22m[34mH[, name,] F[0m[1m[34m ) _____________________________________[0mfunction
  
  [22m[32mCheckMatCode[0m  returns  a linear code with check matrix [22m[34mH[0m. [22m[34mH[0m must be a matrix
  over Galois field [22m[34mF[0m. [22m[34m[name.[0m can contain a short description of the code. The
  parity  check  matrix  is  the transposed of the nullmatrix of the generator
  matrix of the code. Therefore, c* H^T = 0 where c is an element of the code.
  If  [22m[34mH[0m  is  a  rtimes  n-matrix, the code has word length n, redundancy r and
  dimension n-r.
  
  If the check matrix does not have full row rank, the linearly dependent rows
  are  removed.  This  is  done by the [1mGAP[0m function [22m[32mBaseMat[0m. and results in an
  equal  code.  The  check  matrix can be retrieved with the function [22m[32mCheckMat[0m
  (see [1m[34mCheckMat[0m ([1m3.7-2[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> G := Z(3)^0 * [[1,0,1,2,0],[0,1,2,1,1],[0,0,1,2,1]];;[0m
    [22m[35mgap> C1 := CheckMatCode( G, GF(3) );[0m
    [22m[35ma linear [5,2,1..2]2..3 code defined by check matrix over GF(3)[0m
    [22m[35mgap> CheckMat(C1);[0m
    [22m[35m[ [ Z(3)^0, 0*Z(3), Z(3)^0, Z(3), 0*Z(3) ],[0m
    [22m[35m  [ 0*Z(3), Z(3)^0, Z(3), Z(3)^0, Z(3)^0 ],[0m
    [22m[35m  [ 0*Z(3), 0*Z(3), Z(3)^0, Z(3), Z(3)^0 ] ][0m
    [22m[35mgap> C2 := CheckMatCode( IdentityMat( 5, GF(2) ), GF(2) );[0m
    [22m[35ma cyclic [5,0,5]5 code defined by check matrix over GF(2)[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.2-4 HammingCode[0m
  
  [1m[34m> HammingCode( [0m[22m[34mr, F[0m[1m[34m ) ______________________________________________[0mfunction
  
  [22m[32mHammingCode[0m  returns a Hamming code with redundancy [22m[34mr[0m over [22m[34mF[0m. A Hamming code
  is a single-error-correcting code. The parity check matrix of a Hamming code
  has  all  nonzero  vectors  of  length  [22m[34mr[0m  in  its  columns,  except  for  a
  multiplication  factor.  The  decoding  algorithm  of  the Hamming code (see
  [1m[34mDecode[0m ([1m3.10-1[0m)) makes use of this property.
  
  If  q  is  the  size  of  its field [22m[34mF[0m, the returned Hamming code is a linear
  [(q^r-1)/(q-1), (q^r-1)/(q-1) - r, 3] code.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C1 := HammingCode( 4, GF(2) );[0m
    [22m[35ma linear [15,11,3]1 Hamming (4,2) code over GF(2)[0m
    [22m[35mgap> C2 := HammingCode( 3, GF(9) );[0m
    [22m[35ma linear [91,88,3]1 Hamming (3,9) code over GF(9) [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.2-5 ReedMullerCode[0m
  
  [1m[34m> ReedMullerCode( [0m[22m[34mr, k[0m[1m[34m ) ___________________________________________[0mfunction
  
  [22m[32mReedMullerCode[0m  returns a binary 'Reed-Muller code' [22m[34mR(r, k)[0m with dimension [22m[34mk[0m
  and  order [22m[34mr[0m. This is a code with length 2^k and minimum distance 2^k-r (see
  for  example,  section 1.10 in [HP03]). By definition, the r^th order binary
  Reed-Muller code of length n=2^m, for 0 <= r <= m, is the set of all vectors
  f, where f is a Boolean function which is a polynomial of degree at most r.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> ReedMullerCode( 1, 3 );[0m
    [22m[35ma linear [8,4,4]2 Reed-Muller (1,3) code over GF(2) [0m
  [22m[35m------------------------------------------------------------------[0m
  
  See  [1m[34mGeneralizedReedMuller[0m  ([1m???GeneralizedReedMuller???[0m) for a more general
  construction.
  
  [1m[4m[31m5.2-6 AlternantCode[0m
  
  [1m[34m> AlternantCode( [0m[22m[34mr, Y[, alpha,] F[0m[1m[34m ) ________________________________[0mfunction
  
  [22m[32mAlternantCode[0m  returns  an  'alternant code', with parameters [22m[34mr[0m, [22m[34mY[0m and [22m[34malpha[0m
  (optional).  [22m[34mF[0m  denotes  the  (finite)  base  field.  Here,  [22m[34mr[0m is the design
  redundancy  of the code. [22m[34mY[0m and [22m[34malpha[0m are both vectors of length [22m[34mn[0m from which
  the  parity  check  matrix  is  constructed.  The  check matrix has the form
  H=([a_i^j  y_i]),  where  0 <= j<= r-1, 1 <= i<= n, and where [...] is as in
  [1m[34mVerticalConversionFieldMat[0m  ([1m7.3-9[0m)).  If  no [22m[34malpha[0m is specified, the vector
  [1,  a,  a^2, .., a^n-1] is used, where a is a primitive element of a Galois
  field [22m[34mF[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> Y := [ 1, 1, 1, 1, 1, 1, 1];; a := PrimitiveUnityRoot( 2, 7 );;[0m
    [22m[35mgap> alpha := List( [0..6], i -> a^i );;[0m
    [22m[35mgap> C := AlternantCode( 2, Y, alpha, GF(8) );[0m
    [22m[35ma linear [7,3,3..4]3..4 alternant code over GF(8) [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.2-7 GoppaCode[0m
  
  [1m[34m> GoppaCode( [0m[22m[34mG, L[0m[1m[34m ) ________________________________________________[0mfunction
  
  [22m[32mGoppaCode[0m   returns   a  Goppa  code  [22m[34mC[0m  from  Goppa  polynomial  [22m[34mg[0m,  having
  coefficients in a Galois Field GF(q). [22m[34mL[0m must be a list of elements in GF(q),
  that  are not roots of [22m[34mg[0m. The word length of the code is equal to the length
  of  [22m[34mL[0m.  The  parity check matrix has the form H=([a_i^j / G(a_i)])_0 <= j <=
  deg(g)-1,    a_i    in   L,   where   a_iin   L   and   [...]   is   as   in
  [1m[34mVerticalConversionFieldMat[0m  ([1m7.3-9[0m), so H has entries in GF(q), q=p^m. It is
  known  that d(C)>= deg(g)+1, with a better bound in the binary case provided
  g  has  no  multiple roots. See Huffman and Pless [HP03] section 13.2.2, and
  MacWilliams and Sloane [MS83] section 12.3, for more details.
  
  One  can  also  call  [22m[32mGoppaCode[0m using the syntax [22m[32mGoppaCode(g,n)[0m. When called
  with  parameter  [22m[34mn[0m,  [1mGUAVA[0m  constructs  a  list  L of length [22m[34mn[0m, such that no
  element of [22m[34mL[0m is a root of [22m[34mg[0m.
  
  This is a special case of an alternant code.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> x:=Indeterminate(GF(8),"x");[0m
    [22m[35mx[0m
    [22m[35mgap> L:=Elements(GF(8));[0m
    [22m[35m[ 0*Z(2), Z(2)^0, Z(2^3), Z(2^3)^2, Z(2^3)^3, Z(2^3)^4, Z(2^3)^5, Z(2^3)^6 ][0m
    [22m[35mgap> g:=x^2+x+1;[0m
    [22m[35mx^2+x+Z(2)^0[0m
    [22m[35mgap> C:=GoppaCode(g,L);[0m
    [22m[35ma linear [8,2,5]3 Goppa code over GF(2)[0m
    [22m[35mgap> xx := Indeterminate( GF(2), "xx" );; [0m
    [22m[35mgap> gg := xx^2 + xx + 1;; L := AsSSortedList( GF(8) );;[0m
    [22m[35mgap> C1 := GoppaCode( gg, L );[0m
    [22m[35ma linear [8,2,5]3 Goppa code over GF(2) [0m
    [22m[35mgap> y := Indeterminate( GF(2), "y" );; [0m
    [22m[35mgap> h := y^2 + y + 1;;[0m
    [22m[35mgap> C2 := GoppaCode( h, 8 );[0m
    [22m[35ma linear [8,2,5]3 Goppa code over GF(2) [0m
    [22m[35mgap> C1=C2;[0m
    [22m[35mtrue[0m
    [22m[35mgap> C=C1;[0m
    [22m[35mtrue[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.2-8 GeneralizedSrivastavaCode[0m
  
  [1m[34m> GeneralizedSrivastavaCode( [0m[22m[34ma, w, z[, t,] F[0m[1m[34m ) _____________________[0mfunction
  
  [22m[32mGeneralizedSrivastavaCode[0m   returns   a  generalized  Srivastava  code  with
  parameters  [22m[34ma[0m, [22m[34mw[0m, [22m[34mz[0m, [22m[34mt[0m. a = a_1, ..., a_n and w = w_1, ..., w_s are lists of
  n+s  distinct  elements  of  F=GF(q^m),  z  is a list of length n of nonzero
  elements  of GF(q^m). The parameter [22m[34mt[0m determines the designed distance: d >=
  st + 1. The check matrix of this code is the form
  
  \[
       H=([\frac{z_i}{(a_i - w_j)^k}]),
  \]
  
  1<=  k<=  t, where [...] is as in [1m[34mVerticalConversionFieldMat[0m ([1m7.3-9[0m). We use
  this  definition  of  H  to  define  the  code.  The default for [22m[34mt[0m is 1. The
  original  Srivastava  codes  (see [1m[34mSrivastavaCode[0m ([1m5.2-9[0m)) are a special case
  t=1, z_i=a_i^mu, for some mu.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> a := Filtered( AsSSortedList( GF(2^6) ), e -> e in GF(2^3) );;[0m
    [22m[35mgap> w := [ Z(2^6) ];; z := List( [1..8], e -> 1 );;[0m
    [22m[35mgap> C := GeneralizedSrivastavaCode( a, w, z, 1, GF(64) );[0m
    [22m[35ma linear [8,2,2..5]3..4 generalized Srivastava code over GF(2) [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.2-9 SrivastavaCode[0m
  
  [1m[34m> SrivastavaCode( [0m[22m[34ma, w[, mu,] F[0m[1m[34m ) __________________________________[0mfunction
  
  SrivastavaCode   returns  a  Srivastava  code  with  parameters  [22m[34ma[0m,  [22m[34mw[0m  (and
  optionally  [22m[34mmu[0m).  a  =  a_1, ..., a_n and w = w_1, ..., w_s are lists of n+s
  distinct elements of F=GF(q^m). The default for [22m[34mmu[0m is 1. The Srivastava code
  is a generalized Srivastava code, in which z_i = a_i^mu for some [22m[34mmu[0m and t=1.
  
  J.  N.  Srivastava  introduced  this  code  in 1967, though his work was not
  published.  See  Helgert  [H72]  for  more details on the properties of this
  code.  Related  reference: G. Roelofsen, [1m[46mOn Goppa and Generalized Srivastava
  Codes[0m PhD thesis, Dept. Math. and Comp. Sci., Eindhoven Univ. of Technology,
  the Netherlands, 1982.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> a := AsSSortedList( GF(11) ){[2..8]};;[0m
    [22m[35mgap> w := AsSSortedList( GF(11) ){[9..10]};;[0m
    [22m[35mgap> C := SrivastavaCode( a, w, 2, GF(11) );[0m
    [22m[35ma linear [7,5,3]2 Srivastava code over GF(11)[0m
    [22m[35mgap> IsMDSCode( C );[0m
    [22m[35mtrue    # Always true if F is a prime field [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.2-10 CordaroWagnerCode[0m
  
  [1m[34m> CordaroWagnerCode( [0m[22m[34mn[0m[1m[34m ) ___________________________________________[0mfunction
  
  [22m[32mCordaroWagnerCode[0m  returns  a  binary Cordaro-Wagner code. This is a code of
  length  [22m[34mn[0m  and dimension 2 having the best possible minimum distance d. This
  code   is   just   a  little  bit  less  trivial  than  [22m[32mRepetitionCode[0m  (see
  [1m[34mRepetitionCode[0m ([1m5.5-10[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := CordaroWagnerCode( 11 );[0m
    [22m[35ma linear [11,2,7]5 Cordaro-Wagner code over GF(2)[0m
    [22m[35mgap> AsSSortedList(C);                 [0m
    [22m[35m[ [ 0 0 0 0 0 0 0 0 0 0 0 ], [ 0 0 0 0 1 1 1 1 1 1 1 ], [0m
    [22m[35m  [ 1 1 1 1 0 0 0 1 1 1 1 ], [ 1 1 1 1 1 1 1 0 0 0 0 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.2-11 RandomLinearCode[0m
  
  [1m[34m> RandomLinearCode( [0m[22m[34mn, k, F[0m[1m[34m ) ______________________________________[0mfunction
  
  [22m[32mRandomLinearCode[0m  returns a random linear code with word length [22m[34mn[0m, dimension
  [22m[34mk[0m  over  field [22m[34mF[0m. The method used is to first construct a ktimes n matrix of
  the  block  form  (I,A),  where  I  is a ktimes k identity matrix and A is a
  ktimes (n-k) matrix constructed using [22m[32mRandom(F)[0m repeatedly. Then the columns
  are permuted using a randomly selected element of [22m[32mSymmetricGroup(n)[0m.
  
  To  create  a  random  unrestricted  code,  use  [22m[32mRandomCode[0m  (see [1m[34mRandomCode[0m
  ([1m5.1-5[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := RandomLinearCode( 15, 4, GF(3) );[0m
    [22m[35ma  [15,4,?] randomly generated code over GF(3)[0m
    [22m[35mgap> Display(C);[0m
    [22m[35ma linear [15,4,1..6]6..10 random linear code over GF(3)[0m
  [22m[35m------------------------------------------------------------------[0m
  
  The  method [1mGUAVA[0m chooses to output the result of a [22m[32mRandomLinearCode[0m command
  is  different  than  other  codes.  For  example,  the bounds on the minimum
  distance  is not displayed. Howeer, you can use the [22m[32mDisplay[0m command to print
  this  information. This new display method was added in version 1.9 to speed
  up  the  command  (if n is about 80 and k about 40, for example, the time it
  took  to look up and/or calculate the bounds on the minimum distance was too
  long).
  
  [1m[4m[31m5.2-12 OptimalityCode[0m
  
  [1m[34m> OptimalityCode( [0m[22m[34mC[0m[1m[34m ) ______________________________________________[0mfunction
  
  In  general  this  command  is no longer accurate, since the tables have not
  been      updated      since      1998.      See      the      web      site
  [34mhttp://www.win.tue.nl/~aeb/voorlincod.html[0m for more recent data.
  
  [22m[32mOptimalityCode[0m returns the difference between the smallest known upper bound
  and  the  actual  size  of  the  code.  Note  that the value of the function
  [22m[32mUpperBound[0m  is  not  always  equal to the actual upper bound A(n,d) thus the
  result may not be equal to 0 even if the code is optimal!
  
  [22m[32mOptimalityLinearCode[0m is similar but applies only to linear codes.
  
  [1m[4m[31m5.2-13 BestKnownLinearCode[0m
  
  [1m[34m> BestKnownLinearCode( [0m[22m[34mn, k, F[0m[1m[34m ) ___________________________________[0mfunction
  
  In  general  this  command  is no longer accurate, since the tables have not
  been      updated      since      1998.      See      the      web      site
  [34mhttp://www.win.tue.nl/~aeb/voorlincod.html[0m for more recent data.
  
  [22m[32mBestKnownLinearCode[0m  returns  the  best  known  (as  of 1998) linear code of
  length  [22m[34mn[0m,  dimension [22m[34mk[0m over field [22m[34mF[0m. The function uses the tables described
  in section [1m[34mBoundsMinimumDistance[0m ([1m7.1-12[0m) to construct this code.
  
  This command can also be called using the syntax [22m[32mBestKnownLinearCode( rec )[0m,
  where  [22m[34mrec[0m must be a record containing the fields `lowerBound', `upperBound'
  and  `construction'.  It  uses  the information in this field to construct a
  code.   This   form   is  meant  to  be  used  together  with  the  function
  [22m[32mBoundsMinimumDistance[0m  (see  [1m[34mBoundsMinimumDistance[0m  ([1m7.1-12[0m)), if the bounds
  are already calculated.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C1 := BestKnownLinearCode( 23, 12, GF(2) );[0m
    [22m[35ma cyclic [23,12,7]3 binary Golay code over GF(2)[0m
    [22m[35mgap> C1 = BinaryGolayCode();[0m
    [22m[35mtrue[0m
    [22m[35mgap> Display( BestKnownLinearCode( 8, 4, GF(4) ) );[0m
    [22m[35ma linear [8,4,4]2..3 U U+V construction code of[0m
    [22m[35mU: a cyclic [4,3,2]1 dual code of[0m
    [22m[35m   a cyclic [4,1,4]3 repetition code over GF(4)[0m
    [22m[35mV: a cyclic [4,1,4]3 repetition code over GF(4)[0m
    [22m[35mgap> C := BestKnownLinearCode(131,47);[0m
    [22m[35ma linear [131,47,28..32]23..68 shortened code [0m
    [22m[35mgap> bounds := BoundsMinimumDistance( 20, 17, GF(4) );[0m
    [22m[35mrec( n := 20, k := 17, q := 4, [0m
    [22m[35m  references := rec( HM := [ "%T this reference is unknown, for more info", [0m
    [22m[35m          "%T contact A.E. Brouwer (aeb@cwi.nl)" ] ), [0m
    [22m[35m  construction := [ [Operation "ShortenedCode"], [0m
    [22m[35m      [ [ [Operation "HammingCode"], [ 3, 4 ] ], [ 1 ] ] ], lowerBound := 3, [0m
    [22m[35m  lowerBoundExplanation := [ "Lb(20,17)=3, by shortening of:", [0m
    [22m[35m      "Lb(21,18)=3, reference: HM" ], upperBound := 3, [0m
    [22m[35m  upperBoundExplanation := [0m
    [22m[35m    [ "Ub(20,17)=3, otherwise construction B would contradict:", [0m
    [22m[35m      "Ub(3,1)=3, repetition code" ] )[0m
    [22m[35mgap> C := BestKnownLinearCode( bounds );[0m
    [22m[35ma linear [20,17,3]2 shortened code[0m
    [22m[35mgap> C = BestKnownLinearCode( 20, 17, GF(4) );[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m5.3 Gabidulin Codes[0m
  
  These  five  binary,  linear codes are derived from an article by Gabidulin,
  Davydov  and  Tombak [GDT91]. All these codes are defined by check matrices.
  Exact  definitions  can  be  found  in  the article. The Gabidulin code, the
  enlarged Gabidulin code, the Davydov code, the Tombak code, and the enlarged
  Tombak  code, correspond with theorem 1, 2, 3, 4, and 5, respectively in the
  article.
  
  Like the Hamming codes, these codes have fixed minimum distance and covering
  radius, but can be arbitrarily long.
  
  [1m[4m[31m5.3-1 GabidulinCode[0m
  
  [1m[34m> GabidulinCode( [0m[22m[34mm, w1, w2[0m[1m[34m ) _______________________________________[0mfunction
  
  [22m[32mGabidulinCode[0m  yields a code of length 5 . 2^m-2-1, redundancy 2m-1, minimum
  distance 3 and covering radius 2. [22m[34mw1[0m and [22m[34mw2[0m should be elements of GF(2^m-2).
  
  [1m[4m[31m5.3-2 EnlargedGabidulinCode[0m
  
  [1m[34m> EnlargedGabidulinCode( [0m[22m[34mm, w1, w2, e[0m[1m[34m ) ____________________________[0mfunction
  
  [22m[32mEnlargedGabidulinCode[0m  yields  a  code  of length 7. 2^m-2-2, redundancy 2m,
  minimum  distance  3  and  covering  radius  2.  [22m[34mw1[0m  and  [22m[34mw2[0m are elements of
  GF(2^m-2). [22m[34me[0m is an element of GF(2^m).
  
  [1m[4m[31m5.3-3 DavydovCode[0m
  
  [1m[34m> DavydovCode( [0m[22m[34mr, v, ei, ej[0m[1m[34m ) ______________________________________[0mfunction
  
  [22m[32mDavydovCode[0m  yields  a code of length 2^v + 2^r-v - 3, redundancy [22m[34mr[0m, minimum
  distance  4 and covering radius 2. [22m[34mv[0m is an integer between 2 and r-2. [22m[34mei[0m and
  [22m[34mej[0m are elements of GF(2^v) and GF(2^r-v), respectively.
  
  [1m[4m[31m5.3-4 TombakCode[0m
  
  [1m[34m> TombakCode( [0m[22m[34mm, e, beta, gamma, w1, w2[0m[1m[34m ) __________________________[0mfunction
  
  [22m[32mTombakCode[0m  yields  a  code of length 15 * 2^m-3 - 3, redundancy 2m, minimum
  distance 4 and covering radius 2. [22m[34me[0m is an element of GF(2^m). [22m[34mbeta[0m and [22m[34mgamma[0m
  are elements of GF(2^m-1). [22m[34mw1[0m and [22m[34mw2[0m are elements of GF(2^m-3).
  
  [1m[4m[31m5.3-5 EnlargedTombakCode[0m
  
  [1m[34m> EnlargedTombakCode( [0m[22m[34mm, e, beta, gamma, w1, w2, u[0m[1m[34m ) _______________[0mfunction
  
  [22m[32mEnlargedTombakCode[0m  yields a code of length 23 * 2^m-4 - 3, redundancy 2m-1,
  minimum  distance 4 and covering radius 2. The parameters [22m[34mm[0m, [22m[34me[0m, [22m[34mbeta[0m, [22m[34mgamma[0m,
  [22m[34mw1[0m and [22m[34mw2[0m are defined as in [22m[32mTombakCode[0m. [22m[34mu[0m is an element of GF(2^m-1).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> GabidulinCode( 4, Z(4)^0, Z(4)^1 );[0m
    [22m[35ma linear [19,12,3]2 Gabidulin code (m=4) over GF(2)[0m
    [22m[35mgap> EnlargedGabidulinCode( 4, Z(4)^0, Z(4)^1, Z(16)^11 );[0m
    [22m[35ma linear [26,18,3]2 enlarged Gabidulin code (m=4) over GF(2)[0m
    [22m[35mgap> DavydovCode( 6, 3, Z(8)^1, Z(8)^5 );[0m
    [22m[35ma linear [13,7,4]2 Davydov code (r=6, v=3) over GF(2)[0m
    [22m[35mgap> TombakCode( 5, Z(32)^6, Z(16)^14, Z(16)^10, Z(4)^0, Z(4)^1 );[0m
    [22m[35ma linear [57,47,4]2 Tombak code (m=5) over GF(2)[0m
    [22m[35mgap> EnlargedTombakCode( 6, Z(32)^6, Z(16)^14, Z(16)^10,[0m
    [22m[35m> Z(4)^0, Z(4)^0, Z(32)^23 );[0m
    [22m[35ma linear [89,78,4]2 enlarged Tombak code (m=6) over GF(2)[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m5.4 Golay Codes[0m
  
  "  The  Golay  code  is  probably  the  most important of all codes for both
  practical  and  theoretical  reasons.  "  ([MS83],  pg.  64). Though born in
  Switzerland, M. J. E. Golay (1902-1989) worked for the US Army Labs for most
  of  his  career.  For more information on his life, see his obit in the June
  1990 IEEE Information Society Newsletter.
  
  [1m[4m[31m5.4-1 BinaryGolayCode[0m
  
  [1m[34m> BinaryGolayCode( [0m[22m[34m[0m[1m[34m ) ______________________________________________[0mfunction
  
  [22m[32mBinaryGolayCode[0m  returns  a  binary  Golay code. This is a perfect [23,12,7]
  code.    It    is    also    cyclic,    and    has    generator   polynomial
  g(x)=1+x^2+x^4+x^5+x^6+x^10+x^11.  Extending it results in an extended Golay
  code  (see  [1m[34mExtendedBinaryGolayCode[0m ([1m5.4-2[0m)). There's also the ternary Golay
  code (see [1m[34mTernaryGolayCode[0m ([1m5.4-3[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=BinaryGolayCode();[0m
    [22m[35ma cyclic [23,12,7]3 binary Golay code over GF(2)[0m
    [22m[35mgap> ExtendedBinaryGolayCode() = ExtendedCode(BinaryGolayCode());[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsPerfectCode(C);[0m
    [22m[35mtrue [0m
    [22m[35mgap> IsCyclicCode(C);[0m
    [22m[35mtrue[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.4-2 ExtendedBinaryGolayCode[0m
  
  [1m[34m> ExtendedBinaryGolayCode( [0m[22m[34m[0m[1m[34m ) ______________________________________[0mfunction
  
  [22m[32mExtendedBinaryGolayCode[0m  returns  an  extended  binary Golay code. This is a
  [24,12,8]  code. Puncturing in the last position results in a perfect binary
  Golay code (see [1m[34mBinaryGolayCode[0m ([1m5.4-1[0m)). The code is self-dual.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := ExtendedBinaryGolayCode();[0m
    [22m[35ma linear [24,12,8]4 extended binary Golay code over GF(2)[0m
    [22m[35mgap> IsSelfDualCode(C);[0m
    [22m[35mtrue[0m
    [22m[35mgap> P := PuncturedCode(C);[0m
    [22m[35ma linear [23,12,7]3 punctured code[0m
    [22m[35mgap> P = BinaryGolayCode();[0m
    [22m[35mtrue [0m
    [22m[35mgap> IsCyclicCode(C);[0m
    [22m[35mfalse[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.4-3 TernaryGolayCode[0m
  
  [1m[34m> TernaryGolayCode( [0m[22m[34m[0m[1m[34m ) _____________________________________________[0mfunction
  
  [22m[32mTernaryGolayCode[0m  returns  a  ternary Golay code. This is a perfect [11,6,5]
  code.    It    is    also    cyclic,    and    has    generator   polynomial
  g(x)=2+x^2+2x^3+x^4+x^5. Extending it results in an extended Golay code (see
  [1m[34mExtendedTernaryGolayCode[0m  ([1m5.4-4[0m)).  There's also the binary Golay code (see
  [1m[34mBinaryGolayCode[0m ([1m5.4-1[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=TernaryGolayCode();[0m
    [22m[35ma cyclic [11,6,5]2 ternary Golay code over GF(3)[0m
    [22m[35mgap> ExtendedTernaryGolayCode() = ExtendedCode(TernaryGolayCode());[0m
    [22m[35mtrue [0m
    [22m[35mgap> IsCyclicCode(C);[0m
    [22m[35mtrue[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.4-4 ExtendedTernaryGolayCode[0m
  
  [1m[34m> ExtendedTernaryGolayCode( [0m[22m[34m[0m[1m[34m ) _____________________________________[0mfunction
  
  [22m[32mExtendedTernaryGolayCode[0m  returns  an extended ternary Golay code. This is a
  [12,6,6]  code. Puncturing this code results in a perfect ternary Golay code
  (see [1m[34mTernaryGolayCode[0m ([1m5.4-3[0m)). The code is self-dual.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := ExtendedTernaryGolayCode();[0m
    [22m[35ma linear [12,6,6]3 extended ternary Golay code over GF(3)[0m
    [22m[35mgap> IsSelfDualCode(C);[0m
    [22m[35mtrue[0m
    [22m[35mgap> P := PuncturedCode(C);[0m
    [22m[35ma linear [11,6,5]2 punctured code[0m
    [22m[35mgap> P = TernaryGolayCode();[0m
    [22m[35mtrue [0m
    [22m[35mgap> IsCyclicCode(C);[0m
    [22m[35mfalse[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m5.5 Generating Cyclic Codes[0m
  
  The  elements  of  a  cyclic  code  C  are  all multiples of a ('generator')
  polynomial g(x), where calculations are carried out modulo x^n-1. Therefore,
  as  polynomials  in x, the elements always have degree less than n. A cyclic
  code is an ideal in the ring F[x]/(x^n-1) of polynomials modulo x^n - 1. The
  unique  monic  polynomial  of  least  degree  that generates C is called the
  [22m[36mgenerator polynomial[0m of C. It is a divisor of the polynomial x^n-1.
  
  The  [22m[36mcheck  polynomial[0m is the polynomial h(x) with g(x)h(x)=x^n-1. Therefore
  it is also a divisor of x^n-1. The check polynomial has the property that
  
  \[
       c(x)h(x) \equiv 0 \pmod{x^n-1},
  \]
  
  for every codeword c(x)in C.
  
  The  first  two functions described below generate cyclic codes from a given
  generator  or  check  polynomial.  All cyclic codes can be constructed using
  these functions.
  
  Two  of  the  Golay  codes already described are cyclic (see [1m[34mBinaryGolayCode[0m
  ([1m5.4-1[0m)  and  [1m[34mTernaryGolayCode[0m ([1m5.4-3[0m)). For example, the [1mGUAVA[0m record for a
  binary Golay code contains the generator polynomial:
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := BinaryGolayCode();[0m
    [22m[35ma cyclic [23,12,7]3 binary Golay code over GF(2)[0m
    [22m[35mgap> NamesOfComponents(C);[0m
    [22m[35m[ "LeftActingDomain", "GeneratorsOfLeftOperatorAdditiveGroup", "WordLength",[0m
    [22m[35m  "GeneratorMat", "GeneratorPol", "Dimension", "Redundancy", "Size", "name",[0m
    [22m[35m  "lowerBoundMinimumDistance", "upperBoundMinimumDistance", "WeightDistribution",[0m
    [22m[35m  "boundsCoveringRadius", "MinimumWeightOfGenerators", [0m
    [22m[35m  "UpperBoundOptimalMinimumDistance" ][0m
    [22m[35mgap> C!.GeneratorPol;[0m
    [22m[35mx_1^11+x_1^10+x_1^6+x_1^5+x_1^4+x_1^2+Z(2)^0[0m
  [22m[35m------------------------------------------------------------------[0m
  
  Then  functions that generate cyclic codes from a prescribed set of roots of
  the  generator  polynomial  are  described,  including  the  BCH  codes (see
  [1m[34mRootsCode[0m  ([1m5.5-3[0m),  [1m[34mBCHCode[0m  ([1m5.5-4[0m),  [1m[34mReedSolomonCode[0m  ([1m5.5-5[0m)  and [1m[34mQRCode[0m
  ([1m5.5-6[0m)).
  
  Finally  we describe the trivial codes (see [1m[34mWholeSpaceCode[0m ([1m5.5-8[0m), [1m[34mNullCode[0m
  ([1m5.5-9[0m),  [1m[34mRepetitionCode[0m  ([1m5.5-10[0m)), and the command [22m[32mCyclicCodes[0m which lists
  all cyclic codes ([1m[34mCyclicCodes[0m ([1m5.5-11[0m)).
  
  [1m[4m[31m5.5-1 GeneratorPolCode[0m
  
  [1m[34m> GeneratorPolCode( [0m[22m[34mg, n[, name,] F[0m[1m[34m ) ______________________________[0mfunction
  
  [22m[32mGeneratorPolCode[0m  creates  a cyclic code with a generator polynomial [22m[34mg[0m, word
  length [22m[34mn[0m, over [22m[34mF[0m. [22m[34mname[0m can contain a short description of the code.
  
  If [22m[34mg[0m is not a divisor of x^n-1, it cannot be a generator polynomial. In that
  case,  a code is created with generator polynomial gcd( g, x^n-1 ), i.e. the
  greatest common divisor of [22m[34mg[0m and x^n-1. This is a valid generator polynomial
  that generates the ideal (g). See [1m[34mGenerating Cyclic Codes[0m ([1m5.5[0m).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> x:= Indeterminate( GF(2) );; P:= x^2+1;[0m
    [22m[35mZ(2)^0+x^2[0m
    [22m[35mgap> C1 := GeneratorPolCode(P, 7, GF(2));[0m
    [22m[35ma cyclic [7,6,1..2]1 code defined by generator polynomial over GF(2)[0m
    [22m[35mgap> GeneratorPol( C1 );[0m
    [22m[35mZ(2)^0+x[0m
    [22m[35mgap> C2 := GeneratorPolCode( x+1, 7, GF(2)); [0m
    [22m[35ma cyclic [7,6,1..2]1 code defined by generator polynomial over GF(2)[0m
    [22m[35mgap> GeneratorPol( C2 );[0m
    [22m[35mZ(2)^0+x[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.5-2 CheckPolCode[0m
  
  [1m[34m> CheckPolCode( [0m[22m[34mh, n[, name,] F[0m[1m[34m ) __________________________________[0mfunction
  
  [22m[32mCheckPolCode[0m creates a cyclic code with a check polynomial [22m[34mh[0m, word length [22m[34mn[0m,
  over [22m[34mF[0m. [22m[34mname[0m can contain a short description of the code (as a string).
  
  If  [22m[34mh[0m  is  not  a divisor of x^n-1, it cannot be a check polynomial. In that
  case,  a  code  is  created  with check polynomial gcd( h, x^n-1 ), i.e. the
  greatest  common  divisor  of  [22m[34mh[0m and x^n-1. This is a valid check polynomial
  that yields the same elements as the ideal (h). See [1m5.5[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap>  x:= Indeterminate( GF(3) );; P:= x^2+2;[0m
    [22m[35m-Z(3)^0+x_1^2[0m
    [22m[35mgap> H := CheckPolCode(P, 7, GF(3));[0m
    [22m[35ma cyclic [7,1,7]4 code defined by check polynomial over GF(3)[0m
    [22m[35mgap> CheckPol(H);[0m
    [22m[35m-Z(3)^0+x_1[0m
    [22m[35mgap> Gcd(P, X(GF(3))^7-1);[0m
    [22m[35m-Z(3)^0+x_1[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.5-3 RootsCode[0m
  
  [1m[34m> RootsCode( [0m[22m[34mn, list[0m[1m[34m ) _____________________________________________[0mfunction
  
  This  is  the  generalization of the BCH, Reed-Solomon and quadratic residue
  codes (see [1m[34mBCHCode[0m ([1m5.5-4[0m), [1m[34mReedSolomonCode[0m ([1m5.5-5[0m) and [1m[34mQRCode[0m ([1m5.5-6[0m)). The
  user  can  give  a  length  of the code [22m[34mn[0m and a prescribed set of zeros. The
  argument  [22m[34mlist[0m  must  be  a valid list of primitive n^th roots of unity in a
  splitting  field  GF(q^m).  The resulting code will be over the field GF(q).
  The function will return the largest possible cyclic code for which the list
  [22m[34mlist[0m  is a subset of the roots of the code. From this list, [1mGUAVA[0m calculates
  the entire set of roots.
  
  This  command can also be called with the syntax [22m[32mRootsCode( n, list, q )[0m. In
  this  second form, the second argument is a list of integers, ranging from 0
  to  n-1.  The  resulting code will be over a field GF(q). [1mGUAVA[0m calculates a
  primitive  n^th  root  of  unity, alpha, in the extension field of GF(q). It
  uses  the  set  of  the  powers  of alpha in the list as a prescribed set of
  zeros.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> a := PrimitiveUnityRoot( 3, 14 );[0m
    [22m[35mZ(3^6)^52[0m
    [22m[35mgap> C1 := RootsCode( 14, [ a^0, a, a^3 ] );[0m
    [22m[35ma cyclic [14,7,3..6]3..7 code defined by roots over GF(3)[0m
    [22m[35mgap> MinimumDistance( C1 );[0m
    [22m[35m4[0m
    [22m[35mgap> b := PrimitiveUnityRoot( 2, 15 );[0m
    [22m[35mZ(2^4)[0m
    [22m[35mgap> C2 := RootsCode( 15, [ b, b^2, b^3, b^4 ] );[0m
    [22m[35ma cyclic [15,7,5]3..5 code defined by roots over GF(2)[0m
    [22m[35mgap> C2 = BCHCode( 15, 5, GF(2) );[0m
    [22m[35mtrue [0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.5-4 BCHCode[0m
  
  [1m[34m> BCHCode( [0m[22m[34mn[, b,] delta, F[0m[1m[34m ) ______________________________________[0mfunction
  
  The function [22m[32mBCHCode[0m returns a 'Bose-Chaudhuri-Hockenghem code' (or [22m[36mBCH code[0m
  for  short). This is the largest possible cyclic code of length [22m[34mn[0m over field
  [22m[34mF[0m, whose generator polynomial has zeros
  
  \[
       a^{b},a^{b+1}, ..., a^{b+delta-2},
  \]
  
  where  a is a primitive n^th root of unity in the splitting field GF(q^m), [22m[34mb[0m
  is  an  integer  0<=  b<=  n-delta+1  and m is the multiplicative order of q
  modulo   [22m[34mn[0m.  (The  integers  b,...,b+delta-2  typically  lie  in  the  range
  1,...,n-1.)  Default  value for [22m[34mb[0m is 1, though the algorithm allows b=0. The
  length  [22m[34mn[0m  of the code and the size q of the field must be relatively prime.
  The  generator  polynomial  is  equal  to  the  least common multiple of the
  minimal polynomials of
  
  \[
       a^{b}, a^{b+1}, ..., a^{b+delta-2}.
  \]
  
  The  set  of zeroes of the generator polynomial is equal to the union of the
  sets
  
  \[
       \{a^x\ |\ x \in C_k\},
  \]
  
  where  C_k  is the k^th cyclotomic coset of q modulo n and b<= k<= b+delta-2
  (see [1m[34mCyclotomicCosets[0m ([1m7.5-13[0m)).
  
  Special cases are b=1 (resulting codes are called 'narrow-sense' BCH codes),
  and  n=q^m-1  (known as 'primitive' BCH codes). [1mGUAVA[0m calculates the largest
  value  of  d  for which the BCH code with designed distance d coincides with
  the  BCH  code  with  designed distance [22m[34mdelta[0m. This distance d is called the
  [22m[36mBose  distance[0m of the code. The true minimum distance of the code is greater
  than or equal to the Bose distance.
  
  Printed  are the designed distance (to be precise, the Bose distance) d, and
  the starting power b.
  
  The  Sugiyama  decoding  algorithm  has  been implemented for this code (see
  [1m[34mDecode[0m ([1m3.10-1[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C1 := BCHCode( 15, 3, 5, GF(2) );[0m
    [22m[35ma cyclic [15,5,7]5 BCH code, delta=7, b=1 over GF(2)[0m
    [22m[35mgap> DesignedDistance( C1 );[0m
    [22m[35m7[0m
    [22m[35mgap> C2 := BCHCode( 23, 2, GF(2) );[0m
    [22m[35ma cyclic [23,12,5..7]3 BCH code, delta=5, b=1 over GF(2)[0m
    [22m[35mgap> DesignedDistance( C2 );       [0m
    [22m[35m5[0m
    [22m[35mgap> MinimumDistance(C2);[0m
    [22m[35m7 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  See [1m[34mRootsCode[0m ([1m5.5-3[0m) for a more general construction.
  
  [1m[4m[31m5.5-5 ReedSolomonCode[0m
  
  [1m[34m> ReedSolomonCode( [0m[22m[34mn, d[0m[1m[34m ) __________________________________________[0mfunction
  
  [22m[32mReedSolomonCode[0m returns a 'Reed-Solomon code' of length [22m[34mn[0m, designed distance
  [22m[34md[0m.  This  code  is  a  primitive narrow-sense BCH code over the field GF(q),
  where  q=n+1.  The  dimension  of  an  RS  code  is  n-d+1. According to the
  Singleton  bound  (see  [1m[34mUpperBoundSingleton[0m ([1m7.1-1[0m)) the dimension cannot be
  greater  than this, so the true minimum distance of an RS code is equal to [22m[34md[0m
  and the code is maximum distance separable (see [1m[34mIsMDSCode[0m ([1m3.3-7[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C1 := ReedSolomonCode( 3, 2 );[0m
    [22m[35ma cyclic [3,2,2]1 Reed-Solomon code over GF(4)[0m
    [22m[35mgap> IsCyclicCode(C1);[0m
    [22m[35mtrue[0m
    [22m[35mgap> C2 := ReedSolomonCode( 4, 3 );[0m
    [22m[35ma cyclic [4,2,3]2 Reed-Solomon code over GF(5)[0m
    [22m[35mgap> RootsOfCode( C2 );[0m
    [22m[35m[ Z(5), Z(5)^2 ][0m
    [22m[35mgap> IsMDSCode(C2);[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  See [1m[34mGeneralizedReedSolomonCode[0m ([1m5.6-2[0m) for a more general construction.
  
  [1m[4m[31m5.5-6 QRCode[0m
  
  [1m[34m> QRCode( [0m[22m[34mn, F[0m[1m[34m ) ___________________________________________________[0mfunction
  
  [22m[32mQRCode[0m  returns a quadratic residue code. If [22m[34mF[0m is a field GF(q), then q must
  be  a  quadratic  residue modulo [22m[34mn[0m. That is, an x exists with x^2 = q mod n.
  Both  [22m[34mn[0m and q must be primes. Its generator polynomial is the product of the
  polynomials  x-a^i. a is a primitive n^th root of unity, and i is an integer
  in the set of quadratic residues modulo [22m[34mn[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C1 := QRCode( 7, GF(2) );[0m
    [22m[35ma cyclic [7,4,3]1 quadratic residue code over GF(2)[0m
    [22m[35mgap> IsEquivalent( C1, HammingCode( 3, GF(2) ) );[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsCyclicCode(C1);[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsCyclicCode(HammingCode( 3, GF(2) ));[0m
    [22m[35mfalse[0m
    [22m[35mgap> C2 := QRCode( 11, GF(3) );[0m
    [22m[35ma cyclic [11,6,4..5]2 quadratic residue code over GF(3)[0m
    [22m[35mgap> C2 = TernaryGolayCode();[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.5-7 FireCode[0m
  
  [1m[34m> FireCode( [0m[22m[34mg, b[0m[1m[34m ) _________________________________________________[0mfunction
  
  [22m[32mFireCode[0m  constructs  a  (binary)  Fire code. [22m[34mg[0m is a primitive polynomial of
  degree  m,  and a factor of x^r-1. [22m[34mb[0m an integer 0 <= b <= m not divisible by
  r,  that  determines  the  burst  length of a single error burst that can be
  corrected.  The  argument  [22m[34mg[0m  can be a polynomial with base ring GF(2), or a
  list  of  coefficients  in  GF(2).  The  generator polynomial of the code is
  defined as the product of [22m[34mg[0m and x^2b-1+1.
  
  Here  is  the  general  definition  of 'Fire code', named after P. Fire, who
  introduced  these  codes  in 1959 in order to correct burst errors. First, a
  definition.  If  F=GF(q)  and  fin  F[x]  then  we  say  f  has  [22m[36morder[0m  e if
  f(x)|(x^e-1).  A [22m[36mFire code[0m is a cyclic code over F with generator polynomial
  g(x)=  (x^2t-1-1)p(x),  where  p(x)  does  not divide x^2t-1-1 and satisfies
  deg(p(x))>=  t.  The  length of such a code is the order of g(x). Non-binary
  Fire codes have not been implemented.
  
  .
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> x:= Indeterminate( GF(2) );; G:= x^3+x^2+1;[0m
    [22m[35mZ(2)^0+x^2+x^3[0m
    [22m[35mgap> Factors( G );[0m
    [22m[35m[ Z(2)^0+x^2+x^3 ][0m
    [22m[35mgap> C := FireCode( G, 3 );[0m
    [22m[35ma cyclic [35,27,1..4]2..6 3 burst error correcting fire code over GF(2)[0m
    [22m[35mgap> MinimumDistance( C );[0m
    [22m[35m4     # Still it can correct bursts of length 3 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.5-8 WholeSpaceCode[0m
  
  [1m[34m> WholeSpaceCode( [0m[22m[34mn, F[0m[1m[34m ) ___________________________________________[0mfunction
  
  [22m[32mWholeSpaceCode[0m  returns the cyclic whole space code of length [22m[34mn[0m over [22m[34mF[0m. This
  code  consists  of all polynomials of degree less than [22m[34mn[0m and coefficients in
  [22m[34mF[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := WholeSpaceCode( 5, GF(3) );[0m
    [22m[35ma cyclic [5,5,1]0 whole space code over GF(3)[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.5-9 NullCode[0m
  
  [1m[34m> NullCode( [0m[22m[34mn, F[0m[1m[34m ) _________________________________________________[0mfunction
  
  [22m[32mNullCode[0m  returns  the  zero-dimensional nullcode with length [22m[34mn[0m over [22m[34mF[0m. This
  code has only one word: the all zero word. It is cyclic though!
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := NullCode( 5, GF(3) );[0m
    [22m[35ma cyclic [5,0,5]5 nullcode over GF(3)[0m
    [22m[35mgap> AsSSortedList( C );[0m
    [22m[35m[ [ 0 0 0 0 0 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.5-10 RepetitionCode[0m
  
  [1m[34m> RepetitionCode( [0m[22m[34mn, F[0m[1m[34m ) ___________________________________________[0mfunction
  
  [22m[32mRepetitionCode[0m  returns  the  cyclic repetition code of length [22m[34mn[0m over [22m[34mF[0m. The
  code  has  as  many  elements  as  [22m[34mF[0m,  because  each  codeword consists of a
  repetition of one of these elements.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := RepetitionCode( 3, GF(5) );[0m
    [22m[35ma cyclic [3,1,3]2 repetition code over GF(5)[0m
    [22m[35mgap> AsSSortedList( C );[0m
    [22m[35m[ [ 0 0 0 ], [ 1 1 1 ], [ 2 2 2 ], [ 4 4 4 ], [ 3 3 3 ] ][0m
    [22m[35mgap> IsPerfectCode( C );[0m
    [22m[35mfalse[0m
    [22m[35mgap> IsMDSCode( C );[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.5-11 CyclicCodes[0m
  
  [1m[34m> CyclicCodes( [0m[22m[34mn, F[0m[1m[34m ) ______________________________________________[0mfunction
  
  [22m[32mCyclicCodes[0m  returns  a  list  of  all  cyclic  codes of length [22m[34mn[0m over [22m[34mF[0m. It
  constructs  all  possible  generator  polynomials from the factors of x^n-1.
  Each  combination  of  these  factors  yields  a  generator polynomial after
  multiplication.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> CyclicCodes(3,GF(3));[0m
    [22m[35m[ a cyclic [3,3,1]0 enumerated code over GF(3), [0m
    [22m[35ma cyclic [3,2,1..2]1 enumerated code over GF(3), [0m
    [22m[35ma cyclic [3,1,3]2 enumerated code over GF(3), [0m
    [22m[35ma cyclic [3,0,3]3 enumerated code over GF(3) ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.5-12 NrCyclicCodes[0m
  
  [1m[34m> NrCyclicCodes( [0m[22m[34mn, F[0m[1m[34m ) ____________________________________________[0mfunction
  
  The function [22m[32mNrCyclicCodes[0m calculates the number of cyclic codes of length [22m[34mn[0m
  over field [22m[34mF[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> NrCyclicCodes( 23, GF(2) );[0m
    [22m[35m8[0m
    [22m[35mgap> codelist := CyclicCodes( 23, GF(2) );[0m
    [22m[35m[ a cyclic [23,23,1]0 enumerated code over GF(2), [0m
    [22m[35m  a cyclic [23,22,1..2]1 enumerated code over GF(2), [0m
    [22m[35m  a cyclic [23,11,1..8]4..7 enumerated code over GF(2), [0m
    [22m[35m  a cyclic [23,0,23]23 enumerated code over GF(2), [0m
    [22m[35m  a cyclic [23,11,1..8]4..7 enumerated code over GF(2), [0m
    [22m[35m  a cyclic [23,12,1..7]3 enumerated code over GF(2), [0m
    [22m[35m  a cyclic [23,1,23]11 enumerated code over GF(2), [0m
    [22m[35m  a cyclic [23,12,1..7]3 enumerated code over GF(2) ][0m
    [22m[35mgap> BinaryGolayCode() in codelist;[0m
    [22m[35mtrue[0m
    [22m[35mgap> RepetitionCode( 23, GF(2) ) in codelist;[0m
    [22m[35mtrue[0m
    [22m[35mgap> CordaroWagnerCode( 23 ) in codelist;[0m
    [22m[35mfalse    # This code is not cyclic [0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m5.6 Evaluation Codes[0m
  
  [1m[4m[31m5.6-1 EvaluationCode[0m
  
  [1m[34m> EvaluationCode( [0m[22m[34mP, L, R[0m[1m[34m ) ________________________________________[0mfunction
  
  Input:  [22m[34mF[0m  is  a  finite  field,  [22m[34mL[0m  is  a  list  of  rational  functions in
  R=F[x_1,...,x_r],  [22m[34mP[0m  is  a  list  of  n  points  in F^r at which all of the
  functions in [22m[34mL[0m are defined.
  Output: The 'evaluation code' C, which is the image of the evalation map
  
  \[
       Eval_P:span(L)\rightarrow F^n,
  \]
  
  given  by  flongmapsto  (f(p_1),...,f(p_n)), where P=p_1,...,p_n and f in L.
  The generator matrix of C is G=(f_i(p_j))_f_iin L,p_jin P.
  
  This command returns a "record" object [22m[32mC[0m with several extra components (type
  [22m[32mNamesOfComponents(C)[0m  to  see  them  all):  [22m[32mC!.points[0m  (namely  [22m[34mP[0m), [22m[32mC!.basis[0m
  (namely [22m[34mL[0m), and [22m[32mC!.ring[0m (namely [22m[34mR[0m).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);[0m
    [22m[35mGF(11)[0m
    [22m[35mgap> R := PolynomialRing(F,["x","y"]);[0m
    [22m[35mPolynomialRing(..., [ x, y ])[0m
    [22m[35mgap> indets := IndeterminatesOfPolynomialRing(R);;[0m
    [22m[35mgap> x:=indets[1];; y:=indets[2];;[0m
    [22m[35mgap> L:=[x^2*y,x*y,x^5,x^4,x^3,x^2,x,x^0];;[0m
    [22m[35mgap> Pts:=[ [ Z(11)^9, Z(11) ], [ Z(11)^8, Z(11) ], [ Z(11)^7, 0*Z(11) ],[0m
    [22m[35m   [ Z(11)^6, 0*Z(11) ], [ Z(11)^5, 0*Z(11) ], [ Z(11)^4, 0*Z(11) ],[0m
    [22m[35m   [ Z(11)^3, Z(11) ], [ Z(11)^2, 0*Z(11) ], [ Z(11), 0*Z(11) ], [ Z(11)^0, 0*Z(11) ],[0m
    [22m[35m   [ 0*Z(11), Z(11) ] ];;[0m
    [22m[35mgap> C:=EvaluationCode(Pts,L,R);[0m
    [22m[35ma linear [11,8,1..3]2..3  evaluation code over GF(11)[0m
    [22m[35mgap> MinimumDistance(C);[0m
    [22m[35m3[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.6-2 GeneralizedReedSolomonCode[0m
  
  [1m[34m> GeneralizedReedSolomonCode( [0m[22m[34mP, k, R[0m[1m[34m ) ____________________________[0mfunction
  
  Input:  R=F[x],  where  [22m[34mF[0m is a finite field, [22m[34mk[0m is a positive integer, [22m[34mP[0m is a
  list of n points in F.
  Output: The C which is the image of the evaluation map
  
  \[
       Eval_P:F[x]_k\rightarrow F^n,
  \]
  
  given  by flongmapsto (f(p_1),...,f(p_n)), where P=p_1,...,p_nsubset F and f
  ranges over the space F[x]_k of all polynomials of degree less than k.
  
  This command returns a "record" object [22m[32mC[0m with several extra components (type
  [22m[32mNamesOfComponents(C)[0m  to  see  them  all):  [22m[32mC!.points[0m  (namely [22m[34mP[0m), [22m[32mC!.degree[0m
  (namely [22m[34mk[0m), and [22m[32mC!.ring[0m (namely [22m[34mR[0m).
  
  This code can be decoded using [22m[32mDecodeword[0m, which applies the special decoder
  method (the interpolation method), or using [22m[32mGeneralizedReedSolomonDecoderGao[0m
  which  applies  an algorithm of S. Gao (see [1m[34mGeneralizedReedSolomonDecoderGao[0m
  ([1m3.10-3[0m)).  This  code  has  a  special  decoder record which implements the
  interpolation  algorithm  described  in  section 5.2 of Justesen and Hoholdt
  [JH04]. See [1m[34mDecode[0m ([1m3.10-1[0m) and [1m[34mDecodeword[0m ([1m3.10-2[0m) for more details.
  
  The     weighted     version     has    implemented    with    the    option
  [22m[32mGeneralizedReedSolomonCode(P,k,R,wts)[0m,  where  wts  =  [v_1,  ..., v_n] is a
  sequence  of  n  non-zero  elements from the base field F of [22m[34mR[0m. See also the
  generalized Reed--Solomon code GRS_k(P, V) described in [MS83], p.303.
  
  [22m[36mWork  in progress[0m: The list-decoding algorithm of Sudan-Guraswami (described
  in    section    12.1    of    [JH04])    should    be    implemented.   See
  [1m[34mGeneralizedReedSolomonListDecoder[0m ([1m3.10-4[0m).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> R:=PolynomialRing(GF(11),["t"]);[0m
    [22m[35mGF(11)[t][0m
    [22m[35mgap> P:=List([1,3,4,5,7],i->Z(11)^i);[0m
    [22m[35m[ Z(11), Z(11)^3, Z(11)^4, Z(11)^5, Z(11)^7 ][0m
    [22m[35mgap> C:=GeneralizedReedSolomonCode(P,3,R);[0m
    [22m[35ma linear [5,3,1..3]2  generalized Reed-Solomon code over GF(11)[0m
    [22m[35mgap> MinimumDistance(C);[0m
    [22m[35m3[0m
    [22m[35mgap> V:=[Z(11)^0,Z(11)^0,Z(11)^0,Z(11)^0,Z(11)];[0m
    [22m[35m[ Z(11)^0, Z(11)^0, Z(11)^0, Z(11)^0, Z(11) ][0m
    [22m[35mgap> C:=GeneralizedReedSolomonCode(P,3,R,V);[0m
    [22m[35ma linear [5,3,1..3]2  weighted generalized Reed-Solomon code over GF(11)[0m
    [22m[35mgap> MinimumDistance(C);[0m
    [22m[35m3[0m
  [22m[35m------------------------------------------------------------------[0m
  
  See [1m[34mEvaluationCode[0m ([1m5.6-1[0m) for a more general construction.
  
  [1m[4m[31m5.6-3 GeneralizedReedMullerCode[0m
  
  [1m[34m> GeneralizedReedMullerCode( [0m[22m[34mPts, r, F[0m[1m[34m ) ___________________________[0mfunction
  
  [22m[32mGeneralizedReedMullerCode[0m  returns  a 'Reed-Muller code' C with length |Pts|
  and  order  r.  One  considers (a) a basis of monomials for the vector space
  over  F=GF(q)  of all polynomials in F[x_1,...,x_d] of degree at most r, and
  (b)  a  set  Pts  of  points  in F^d. The generator matrix of the associated
  [22m[36mReed-Muller  code[0m  C  is G=(f(p))_fin B,p in Pts. This code C is constructed
  using the command [22m[32mGeneralizedReedMullerCode(Pts,r,F)[0m. When Pts is the set of
  all  q^d  points in F^d then the command [22m[32mGeneralizedReedMuller(d,r,F)[0m yields
  the code. When Pts is the set of all (q-1)^d points with no coordinate equal
  to  0  then  this  is  can  be constructed using the [22m[32mToricCode[0m command (as a
  special case).
  
  This command returns a "record" object [22m[32mC[0m with several extra components (type
  [22m[32mNamesOfComponents(C)[0m  to see them all): [22m[32mC!.points[0m (namely [22m[34mPts[0m) and [22m[32mC!.degree[0m
  (namely [22m[34mr[0m).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> Pts:=ToricPoints(2,GF(5));[0m
    [22m[35m[ [ Z(5)^0, Z(5)^0 ], [ Z(5)^0, Z(5) ], [ Z(5)^0, Z(5)^2 ], [ Z(5)^0, Z(5)^3 ],[0m
    [22m[35m  [ Z(5), Z(5)^0 ], [ Z(5), Z(5) ], [ Z(5), Z(5)^2 ], [ Z(5), Z(5)^3 ],[0m
    [22m[35m  [ Z(5)^2, Z(5)^0 ], [ Z(5)^2, Z(5) ], [ Z(5)^2, Z(5)^2 ], [ Z(5)^2, Z(5)^3 ],[0m
    [22m[35m  [ Z(5)^3, Z(5)^0 ], [ Z(5)^3, Z(5) ], [ Z(5)^3, Z(5)^2 ], [ Z(5)^3, Z(5)^3 ] ][0m
    [22m[35mgap> C:=GeneralizedReedMullerCode(Pts,2,GF(5));[0m
    [22m[35ma linear [16,6,1..11]6..10  generalized Reed-Muller code over GF(5)[0m
  [22m[35m------------------------------------------------------------------[0m
  
  See [1m[34mEvaluationCode[0m ([1m5.6-1[0m) for a more general construction.
  
  [1m[4m[31m5.6-4 AffinePointsOnCurve[0m
  
  [1m[34m> AffinePointsOnCurve( [0m[22m[34mf, R, E[0m[1m[34m ) ___________________________________[0mfunction
  
  [22m[32mAffinePointsOnCurve(f,R,E)[0m   returns  the  points  (x,y)  in  E^2  satisying
  f(x,y)=0, where [22m[34mf[0m is an element of R=F[x,y].
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);;[0m
    [22m[35mgap> R := PolynomialRing(F,["x","y"]);[0m
    [22m[35mPolynomialRing(..., [ x, y ])[0m
    [22m[35mgap> indets := IndeterminatesOfPolynomialRing(R);;[0m
    [22m[35mgap> x:=indets[1];; y:=indets[2];;[0m
    [22m[35mgap> P:=AffinePointsOnCurve(y^2-x^11+x,R,F);[0m
    [22m[35m[ [ Z(11)^9, 0*Z(11) ], [ Z(11)^8, 0*Z(11) ], [ Z(11)^7, 0*Z(11) ], [0m
    [22m[35m  [ Z(11)^6, 0*Z(11) ], [ Z(11)^5, 0*Z(11) ], [ Z(11)^4, 0*Z(11) ], [0m
    [22m[35m  [ Z(11)^3, 0*Z(11) ], [ Z(11)^2, 0*Z(11) ], [ Z(11), 0*Z(11) ], [0m
    [22m[35m  [ Z(11)^0, 0*Z(11) ], [ 0*Z(11), 0*Z(11) ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.6-5 OnePointAGCode[0m
  
  [1m[34m> OnePointAGCode( [0m[22m[34mf, P, m, R[0m[1m[34m ) _____________________________________[0mfunction
  
  Input:  [22m[34mf[0m  is  a  polynomial  in R=F[x,y], where [22m[34mF[0m is a finite field, [22m[34mm[0m is a
  positive  integer  (the multiplicity of the `point at infinity' infty on the
  curve f(x,y)=0), [22m[34mP[0m is a list of n points on the curve over F.
  Output: The C which is the image of the evaluation map
  
  \[
       Eval_P:L(m \cdot \infty)\rightarrow F^n,
  \]
  
  given  by flongmapsto (f(p_1),...,f(p_n)), where p_i in P. Here L(m * infty)
  denotes  the  Riemann-Roch space of the divisor m * infty on the curve. This
  has a basis consisting of monomials x^iy^j, where (i,j) range over a polygon
  depending on m and f(x,y). For more details on the Riemann-Roch space of the
  divisor m * infty see Proposition III.10.5 in Stichtenoth [S93].
  
  This command returns a "record" object [22m[32mC[0m with several extra components (type
  [22m[32mNamesOfComponents(C)[0m to see them all): [22m[32mC!.points[0m (namely [22m[34mP[0m), [22m[32mC!.multiplicity[0m
  (namely [22m[34mm[0m), [22m[32mC!.curve[0m (namely [22m[34mf[0m) and [22m[32mC!.ring[0m (namely [22m[34mR[0m).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);[0m
    [22m[35mGF(11)[0m
    [22m[35mgap> R := PolynomialRing(F,["x","y"]);[0m
    [22m[35mPolynomialRing(..., [ x, y ])[0m
    [22m[35mgap> indets := IndeterminatesOfPolynomialRing(R);[0m
    [22m[35m[ x, y ][0m
    [22m[35mgap> x:=indets[1]; y:=indets[2];[0m
    [22m[35mx[0m
    [22m[35my[0m
    [22m[35mgap> P:=AffinePointsOnCurve(y^2-x^11+x,R,F);;[0m
    [22m[35mgap> C:=OnePointAGCode(y^2-x^11+x,P,15,R);[0m
    [22m[35ma linear [11,8,1..0]2..3  one-point AG code over GF(11)[0m
    [22m[35mgap> MinimumDistance(C);[0m
    [22m[35m4[0m
    [22m[35mgap> Pts:=List([1,2,4,6,7,8,9,10,11],i->P[i]);;[0m
    [22m[35mgap> C:=OnePointAGCode(y^2-x^11+x,PT,10,R);[0m
    [22m[35ma linear [9,6,1..4]2..3 one-point AG code over GF(11)[0m
    [22m[35mgap> MinimumDistance(C);[0m
    [22m[35m4[0m
  [22m[35m------------------------------------------------------------------[0m
  
  See [1m[34mEvaluationCode[0m ([1m5.6-1[0m) for a more general construction.
  
  [1m[4m[31m5.6-6 ToricPoints[0m
  
  [1m[34m> ToricPoints( [0m[22m[34mn, F[0m[1m[34m ) ______________________________________________[0mfunction
  
  [22m[32mToricPoints(n,F)[0m returns the points in (F^times)^n.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> ToricPoints(2,GF(5));[0m
    [22m[35m[ [ Z(5)^0, Z(5)^0 ], [ Z(5)^0, Z(5) ], [ Z(5)^0, Z(5)^2 ], [0m
    [22m[35m  [ Z(5)^0, Z(5)^3 ], [ Z(5), Z(5)^0 ], [ Z(5), Z(5) ], [ Z(5), Z(5)^2 ], [0m
    [22m[35m  [ Z(5), Z(5)^3 ], [ Z(5)^2, Z(5)^0 ], [ Z(5)^2, Z(5) ], [ Z(5)^2, Z(5)^2 ], [0m
    [22m[35m  [ Z(5)^2, Z(5)^3 ], [ Z(5)^3, Z(5)^0 ], [ Z(5)^3, Z(5) ], [0m
    [22m[35m  [ Z(5)^3, Z(5)^2 ], [ Z(5)^3, Z(5)^3 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m5.6-7 ToricCode[0m
  
  [1m[34m> ToricCode( [0m[22m[34mL, F[0m[1m[34m ) ________________________________________________[0mfunction
  
  This  function returns the toric codes as in D. Joyner [J04] (see also J. P.
  Hansen [H99]). This is a truncated (generalized) Reed-Muller code. Here [22m[34mL[0m is
  a  list of integral vectors and [22m[34mF[0m is the finite field. The size of [22m[34mF[0m must be
  different from 2.
  
  This  command  returns  a  record  object  [22m[32mC[0m  with  an extra component (type
  [22m[32mNamesOfComponents(C)[0m to see them all): [22m[32mC!.exponents[0m (namely [22m[34mL[0m).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=ToricCode([[1,0],[3,4]],GF(3));[0m
    [22m[35ma linear [4,1,4]2 toric code over GF(3)[0m
    [22m[35mgap> Display(GeneratorMat(C));[0m
    [22m[35m 1 1 2 2[0m
    [22m[35mgap> Elements(C);[0m
    [22m[35m[ [ 0 0 0 0 ], [ 1 1 2 2 ], [ 2 2 1 1 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  See [1m[34mEvaluationCode[0m ([1m5.6-1[0m) for a more general construction.
  
