  
  [1m[4m[31m7. Bounds on codes, special matrices and miscellaneous functions[0m
  
  In  this chapter we describe functions that determine bounds on the size and
  minimum  distance of codes (Section [1m7.1[0m), functions that determine bounds on
  the  size  and  covering  radius of codes (Section [1m7.2[0m), functions that work
  with  special  matrices [1mGUAVA[0m needs for several codes (see Section [1m7.3[0m), and
  constructing codes or performing calculations with codes (see Section [1m7.5[0m).
  
  
  [1m[4m[31m7.1 Distance bounds on codes[0m
  
  This  section  describes  the  functions  that calculate estimates for upper
  bounds  on  the  size  and minimum distance of codes. Several algorithms are
  known to compute a largest number of words a code can have with given length
  and  minimum  distance.  It  is important however to understand that in some
  cases  the  true upper bound is unknown. A code which has a size equalto the
  calculated  upper  bound may not have been found. However, codes that have a
  larger size do not exist.
  
  A  second  way  to obtain bounds is a table. In [1mGUAVA[0m, an extensive table is
  implemented for linear codes over GF(2), GF(3) and GF(4). It contains bounds
  on  the  minimum  distance  for  given word length and dimension. For binary
  codes,  it  contains  entries for word length less than or equal to 257. For
  codes over GF(3) and GF(4), it contains entries for word length less than or
  equal  to  130.  These  tables  have not been maintained since 1998. For the
  latest information, please see A. E. Brouwer's tables [B05] on the internet.
  
  Firstly,  we  describe  functions  that compute specific upper bounds on the
  code  size  (see  [1m[34mUpperBoundSingleton[0m  ([1m7.1-1[0m),  [1m[34mUpperBoundHamming[0m  ([1m7.1-2[0m),
  [1m[34mUpperBoundJohnson[0m   ([1m7.1-3[0m),   [1m[34mUpperBoundPlotkin[0m   ([1m7.1-4[0m),  [1m[34mUpperBoundElias[0m
  ([1m7.1-5[0m) and [1m[34mUpperBoundGriesmer[0m ([1m7.1-6[0m)).
  
  Next  we  describe  a function that computes [1mGUAVA[0m's best upper bound on the
  code size (see [1m[34mUpperBound[0m ([1m7.1-8[0m)).
  
  Then  we  describe two functions that compute a lower and upper bound on the
  minimum  distance  of  a  code  (see  [1m[34mLowerBoundMinimumDistance[0m  ([1m7.1-9[0m) and
  [1m[34mUpperBoundMinimumDistance[0m ([1m7.1-12[0m)).
  
  Finally,  we describe a function that returns a lower and upper bound on the
  minimum  distance  with given parameters and a description of how the bounds
  were obtained (see [1m[34mBoundsMinimumDistance[0m ([1m7.1-13[0m)).
  
  [1m[4m[31m7.1-1 UpperBoundSingleton[0m
  
  [1m[34m> UpperBoundSingleton( [0m[22m[34mn, d, q[0m[1m[34m ) ___________________________________[0mfunction
  
  [22m[32mUpperBoundSingleton[0m  returns  the  Singleton  bound  for a code of length [22m[34mn[0m,
  minimum  distance  [22m[34md[0m  over  a  field  of  size [22m[34mq[0m. This bound is based on the
  shortening  of  codes.  By  shortening  an  (n,  M,  d)  code  d-1 times, an
  (n-d+1,M,1)  code  results,  with  M <= q^n-d+1 (see [1m[34mShortenedCode[0m ([1m6.1-9[0m)).
  Thus
  
  \[
       M \leq q^{n-d+1}.
  \]
  
  Codes  that  meet  this  bound  are  called  [22m[36mmaximum distance separable[0m (see
  [1m[34mIsMDSCode[0m ([1m4.3-7[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> UpperBoundSingleton(4, 3, 5);[0m
    [22m[35m25[0m
    [22m[35mgap> C := ReedSolomonCode(4,3);; Size(C);[0m
    [22m[35m25[0m
    [22m[35mgap> IsMDSCode(C);[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-2 UpperBoundHamming[0m
  
  [1m[34m> UpperBoundHamming( [0m[22m[34mn, d, q[0m[1m[34m ) _____________________________________[0mfunction
  
  The  Hamming bound (also known as the [22m[36msphere packing bound[0m) returns an upper
  bound on the size of a code of length [22m[34mn[0m, minimum distance [22m[34md[0m, over a field of
  size [22m[34mq[0m. The Hamming bound is obtained by dividing the contents of the entire
  space  GF(q)^n  by the contents of a ball with radius lfloor(d-1) / 2rfloor.
  As  all these balls are disjoint, they can never contain more than the whole
  vector space.
  
  \[
       M \leq {q^n \over V(n,e)},
  \]
  
  where  M  is  the  maxmimum  number  of codewords and V(n,e) is equal to the
  contents  of  a  ball of radius e (see [1m[34mSphereContent[0m ([1m7.5-5[0m)). This bound is
  useful  for  small  values  of  [22m[34md[0m. Codes for which equality holds are called
  [22m[36mperfect[0m (see [1m[34mIsPerfectCode[0m ([1m4.3-6[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> UpperBoundHamming( 15, 3, 2 );[0m
    [22m[35m2048[0m
    [22m[35mgap> C := HammingCode( 4, GF(2) );[0m
    [22m[35ma linear [15,11,3]1 Hamming (4,2) code over GF(2)[0m
    [22m[35mgap> Size( C );[0m
    [22m[35m2048 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-3 UpperBoundJohnson[0m
  
  [1m[34m> UpperBoundJohnson( [0m[22m[34mn, d[0m[1m[34m ) ________________________________________[0mfunction
  
  The  Johnson  bound  is  an  improved  version  of  the  Hamming  bound (see
  [1m[34mUpperBoundHamming[0m  ([1m7.1-2[0m)). In addition to the Hamming bound, it takes into
  account  the  elements of the space outside the balls of radius e around the
  elements of the code. The Johnson bound only works for binary codes.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> UpperBoundJohnson( 13, 5 );[0m
    [22m[35m77[0m
    [22m[35mgap> UpperBoundHamming( 13, 5, 2);[0m
    [22m[35m89   # in this case the Johnson bound is better [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-4 UpperBoundPlotkin[0m
  
  [1m[34m> UpperBoundPlotkin( [0m[22m[34mn, d, q[0m[1m[34m ) _____________________________________[0mfunction
  
  The  function  [22m[32mUpperBoundPlotkin[0m  calculates the sum of the distances of all
  ordered  pairs  of  different  codewords.  It  is based on the fact that the
  minimum  distance  is  at  most  equal to the average distance. It is a good
  bound if the weights of the codewords do not differ much. It results in:
  
  \[
       M \leq {d \over {d-(1-1/q)n}},
  \]
  
  where  M  is the maximum number of codewords. In this case, [22m[34md[0m must be larger
  than (1-1/q)n, but by shortening the code, the case d < (1-1/q)n is covered.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> UpperBoundPlotkin( 15, 7, 2 );[0m
    [22m[35m32[0m
    [22m[35mgap> C := BCHCode( 15, 7, GF(2) );[0m
    [22m[35ma cyclic [15,5,7]5 BCH code, delta=7, b=1 over GF(2)[0m
    [22m[35mgap> Size(C);[0m
    [22m[35m32[0m
    [22m[35mgap> WeightDistribution(C);[0m
    [22m[35m[ 1, 0, 0, 0, 0, 0, 0, 15, 15, 0, 0, 0, 0, 0, 0, 1 ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-5 UpperBoundElias[0m
  
  [1m[34m> UpperBoundElias( [0m[22m[34mn, d, q[0m[1m[34m ) _______________________________________[0mfunction
  
  The   Elias   bound   is   an   improvement   of   the  Plotkin  bound  (see
  [1m[34mUpperBoundPlotkin[0m  ([1m7.1-4[0m))  for  large codes. Subcodes are used to decrease
  the  size  of  the  code, in this case the subcode of all codewords within a
  certain  ball.  This  bound  is useful for large codes with relatively small
  minimum distances.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> UpperBoundPlotkin( 16, 3, 2 );[0m
    [22m[35m12288[0m
    [22m[35mgap> UpperBoundElias( 16, 3, 2 );[0m
    [22m[35m10280 [0m
    [22m[35mgap> UpperBoundElias( 20, 10, 3 );[0m
    [22m[35m16255[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-6 UpperBoundGriesmer[0m
  
  [1m[34m> UpperBoundGriesmer( [0m[22m[34mn, d, q[0m[1m[34m ) ____________________________________[0mfunction
  
  The  Griesmer  bound  is  valid  only  for  linear  codes. It is obtained by
  counting  the number of equal symbols in each row of the generator matrix of
  the  code.  By  omitting  the  coordinates  in which all rows have a zero, a
  smaller  code  results.  The  Griesmer  bound  is obtained by repeating this
  proces until a trivial code is left in the end.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> UpperBoundGriesmer( 13, 5, 2 );[0m
    [22m[35m64[0m
    [22m[35mgap> UpperBoundGriesmer( 18, 9, 2 );[0m
    [22m[35m8        # the maximum number of words for a linear code is 8[0m
    [22m[35mgap> Size( PuncturedCode( HadamardCode( 20, 1 ) ) );[0m
    [22m[35m20       # this non-linear code has 20 elements [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-7 IsGriesmerCode[0m
  
  [1m[34m> IsGriesmerCode( [0m[22m[34mC[0m[1m[34m ) ______________________________________________[0mfunction
  
  [22m[32mIsGriesmerCode[0m  returns  `true'  if  a linear code [22m[34mC[0m is a Griesmer code, and
  `false' otherwise. A code is called [22m[36mGriesmer[0m if its length satisfies
  
  \[
       n = g[k,d] = \sum_{i=0}^{k-1} \lceil \frac{d}{q^i} \rceil.
  \]
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> IsGriesmerCode( HammingCode( 3, GF(2) ) );[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsGriesmerCode( BCHCode( 17, 2, GF(2) ) );[0m
    [22m[35mfalse [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-8 UpperBound[0m
  
  [1m[34m> UpperBound( [0m[22m[34mn, d, q[0m[1m[34m ) ____________________________________________[0mfunction
  
  [22m[32mUpperBound[0m  returns the best known upper bound A(n,d) for the size of a code
  of  length  [22m[34mn[0m,  minimum  distance  [22m[34md[0m  over  a  field of size [22m[34mq[0m. The function
  [22m[32mUpperBound[0m  first  checks  for  trivial  cases (like d=1 or n=d), and if the
  value  is in the built-in table. Then it calculates the minimum value of the
  upper   bound  using  the  methods  of  Singleton  (see  [1m[34mUpperBoundSingleton[0m
  ([1m7.1-1[0m)),    Hamming   (see   [1m[34mUpperBoundHamming[0m   ([1m7.1-2[0m)),   Johnson   (see
  [1m[34mUpperBoundJohnson[0m  ([1m7.1-3[0m)),  Plotkin  (see  [1m[34mUpperBoundPlotkin[0m  ([1m7.1-4[0m)) and
  Elias (see [1m[34mUpperBoundElias[0m ([1m7.1-5[0m)). If the code is binary, A(n, 2* ell-1) =
  A(n+1,2*  ell),  so  the [22m[32mUpperBound[0m takes the minimum of the values obtained
  from all methods for the parameters (n, 2*ell-1) and (n+1, 2* ell).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> UpperBound( 10, 3, 2 );[0m
    [22m[35m85[0m
    [22m[35mgap> UpperBound( 25, 9, 8 );[0m
    [22m[35m1211778792827540 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-9 LowerBoundMinimumDistance[0m
  
  [1m[34m> LowerBoundMinimumDistance( [0m[22m[34mC[0m[1m[34m ) ___________________________________[0mfunction
  
  In  this  form,  [22m[32mLowerBoundMinimumDistance[0m  returns  a  lower  bound for the
  minimum distance of code [22m[34mC[0m.
  
  This  command can also be called using the syntax [22m[32mLowerBoundMinimumDistance(
  n, k, F )[0m. In this form, [22m[32mLowerBoundMinimumDistance[0m returns a lower bound for
  the  minimum distance of the best known linear code of length [22m[34mn[0m, dimension [22m[34mk[0m
  over field [22m[34mF[0m. It uses the mechanism explained in section [1m7.1-13[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := BCHCode( 45, 7 );[0m
    [22m[35ma cyclic [45,23,7..9]6..16 BCH code, delta=7, b=1 over GF(2)[0m
    [22m[35mgap> LowerBoundMinimumDistance( C );[0m
    [22m[35m7     # designed distance is lower bound for minimum distance [0m
    [22m[35mgap> LowerBoundMinimumDistance( 45, 23, GF(2) );[0m
    [22m[35m10 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-10 LowerBoundGilbertVarshamov[0m
  
  [1m[34m> LowerBoundGilbertVarshamov( [0m[22m[34mn, d, q[0m[1m[34m ) ____________________________[0mfunction
  
  This  is  the  lower  bound due (independently) to Gilbert and Varshamov. It
  says  that  for each [22m[34mn[0m and [22m[34md[0m, there exists a linear code having length n and
  minimum distance d at least of size q^n-1/ SphereContent(n-1,d-2,GF(q)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> LowerBoundGilbertVarshamov(3,2,2);[0m
    [22m[35m4[0m
    [22m[35mgap> LowerBoundGilbertVarshamov(3,3,2);[0m
    [22m[35m1[0m
    [22m[35mgap> LowerBoundMinimumDistance(3,3,2);[0m
    [22m[35m1[0m
    [22m[35mgap> LowerBoundMinimumDistance(3,2,2);[0m
    [22m[35m2[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-11 LowerBoundSpherePacking[0m
  
  [1m[34m> LowerBoundSpherePacking( [0m[22m[34mn, d, q[0m[1m[34m ) _______________________________[0mfunction
  
  This  is  the  lower  bound due (independently) to Gilbert and Varshamov. It
  says  that  for  each [22m[34mn[0m and [22m[34mr[0m, there exists an unrestricted code at least of
  size q^n/ SphereContent(n,d,GF(q)) minimum distance d.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> LowerBoundSpherePacking(3,2,2);[0m
    [22m[35m2[0m
    [22m[35mgap> LowerBoundSpherePacking(3,3,2);[0m
    [22m[35m1[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-12 UpperBoundMinimumDistance[0m
  
  [1m[34m> UpperBoundMinimumDistance( [0m[22m[34mC[0m[1m[34m ) ___________________________________[0mfunction
  
  In  this  form,  [22m[32mUpperBoundMinimumDistance[0m  returns  an  upper bound for the
  minimum distance of code [22m[34mC[0m. For unrestricted codes, it just returns the word
  length.  For  linear codes, it takes the minimum of the possibly known value
  from the method of construction, the weight of the generators, and the value
  from the table (see [1m7.1-13[0m).
  
  This  command can also be called using the syntax [22m[32mUpperBoundMinimumDistance(
  n,  k,  F  )[0m. In this form, [22m[32mUpperBoundMinimumDistance[0m returns an upper bound
  for  the  minimum  distance  of  the  best  known  linear  code of length [22m[34mn[0m,
  dimension [22m[34mk[0m over field [22m[34mF[0m. It uses the mechanism explained in section [1m7.1-13[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := BCHCode( 45, 7 );;[0m
    [22m[35mgap> UpperBoundMinimumDistance( C );[0m
    [22m[35m9 [0m
    [22m[35mgap> UpperBoundMinimumDistance( 45, 23, GF(2) );[0m
    [22m[35m11 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.1-13 BoundsMinimumDistance[0m
  
  [1m[34m> BoundsMinimumDistance( [0m[22m[34mn, k, F[0m[1m[34m ) _________________________________[0mfunction
  
  The  function  [22m[32mBoundsMinimumDistance[0m  calculates a lower and upper bound for
  the minimum distance of an optimal linear code with word length [22m[34mn[0m, dimension
  [22m[34mk[0m  over  field  [22m[34mF[0m.  The function returns a record with the two bounds and an
  explanation  for  each  bound.  The function [22m[32mDisplay[0m can be used to show the
  explanations.
  
  The  values  for  the lower and upper bound are obtained from a table. [1mGUAVA[0m
  has  tables containing lower and upper bounds for q=2 (n <= 257), 3, 4 (n <=
  130). (Current as of 1998 - now out of date.) These tables were derived from
  the table of Brouwer. (See [B05], [34mhttp://www.win.tue.nl/~aeb/voorlincod.html[0m
  for  the  most recent data.) For codes over other fields and for larger word
  lengths, trivial bounds are used.
  
  The  resulting  record  can be used in the function [22m[32mBestKnownLinearCode[0m (see
  [1m[34mBestKnownLinearCode[0m  ([1m5.2-14[0m))  to  construct  a  code with minimum distance
  equal to the lower bound.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> bounds := BoundsMinimumDistance( 7, 3 );; DisplayBoundsInfo( bounds );[0m
    [22m[35man optimal linear [7,3,d] code over GF(2) has d=4[0m
    [22m[35m------------------------------------------------------------------------------[0m
    [22m[35mLb(7,3)=4, by shortening of:[0m
    [22m[35mLb(8,4)=4, u u+v construction of C1 and C2:[0m
    [22m[35mLb(4,3)=2, dual of the repetition code[0m
    [22m[35mLb(4,1)=4, repetition code[0m
    [22m[35m------------------------------------------------------------------------------[0m
    [22m[35mUb(7,3)=4, Griesmer bound[0m
    [22m[35m# The lower bound is equal to the upper bound, so a code with[0m
    [22m[35m# these parameters is optimal.[0m
    [22m[35mgap> C := BestKnownLinearCode( bounds );; Display( C );[0m
    [22m[35ma linear [7,3,4]2..3 shortened code of[0m
    [22m[35ma linear [8,4,4]2 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]2 repetition code over GF(2)[0m
    [22m[35mV: a cyclic [4,1,4]2 repetition code over GF(2)[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m7.2 Covering radius bounds on codes[0m
  
  [1m[4m[31m7.2-1 BoundsCoveringRadius[0m
  
  [1m[34m> BoundsCoveringRadius( [0m[22m[34mC[0m[1m[34m ) ________________________________________[0mfunction
  
  [22m[32mBoundsCoveringRadius[0m  returns  a  list  of integers. The first entry of this
  list  is  the maximum of some lower bounds for the covering radius of [22m[34mC[0m, the
  last entry the minimum of some upper bounds of [22m[34mC[0m.
  
  If  the  covering  radius  of  [22m[34mC[0m  is  known, a list of length 1 is returned.
  [22m[32mBoundsCoveringRadius[0m       makes       use       of       the      functions
  [22m[32mGeneralLowerBoundCoveringRadius[0m and [22m[32mGeneralUpperBoundCoveringRadius[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> BoundsCoveringRadius( BCHCode( 17, 3, GF(2) ) );[0m
    [22m[35m[ 3 .. 4 ][0m
    [22m[35mgap> BoundsCoveringRadius( HammingCode( 5, GF(2) ) );[0m
    [22m[35m[ 1 ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-2 IncreaseCoveringRadiusLowerBound[0m
  
  [1m[34m> IncreaseCoveringRadiusLowerBound( [0m[22m[34mC[, stopdist][,][startword][0m[1m[34m ) __[0mfunction
  
  [22m[32mIncreaseCoveringRadiusLowerBound[0m  tries  to  increase the lower bound of the
  covering  radius  of  [22m[34mC[0m. It does this by means of a probabilistic algorithm.
  This  algorithm  takes  a  random  word  in  GF(q)^n  (or [22m[34mstartword[0m if it is
  specified),  and, by changing random coordinates, tries to get as far from [22m[34mC[0m
  as  possible.  If  changing  a  coordinate  finds  a  word that has a larger
  distance  to  the  code than the previous one, the change is made permanent,
  and  the  algorithm starts all over again. If changing a coordinate does not
  find  a  coset leader that is further away from the code, then the change is
  made  permanent with a chance of 1 in 100, if it gets the word closer to the
  code,  or  with a chance of 1 in 10, if the word stays at the same distance.
  Otherwise, the algorithm starts again with the same word as before.
  
  If  the  algorithm  did  not allow changes that decrease the distance to the
  code,  it  might  get  stuck  in  a  sub-optimal situation (the coset leader
  corresponding  to such a situation - i.e. no coordinate of this coset leader
  can  be changed in such a way that we get at a larger distance from the code
  - is called an [22m[36morphan[0m).
  
  If  the  algorithm  finds  a word that has distance [22m[34mstopdist[0m to the code, it
  ends and returns that word, which can be used for further investigations.
  
  The  variable  [22m[34mInfoCoveringRadius[0m  can  be set to [22m[34mPrint[0m to print the maximum
  distance  reached  so  far every 1000 runs. The algorithm can be interrupted
  with  [1m[46mctrl-C[0m,  allowing the user to look at the word that is currently being
  examined  (called  `current'), or to change the chances that the new word is
  made  permanent  (these are called `staychance' and `downchance'). If one of
  these variables is i, then it corresponds with a i in 100 chance.
  
  At  the moment, the algorithm is only useful for codes with small dimension,
  where  small means that the elements of the code fit in the memory. It works
  with  larger  codes,  however,  but  when  you  use  it for codes with large
  dimension,  you  should  be [22m[36mvery[0m patient. If running the algorithm quits [1mGAP[0m
  (due  to memory problems), you can change the global variable [22m[34mCRMemSize[0m to a
  lower  value.  This  might  cause  the  algorithm to run slower, but without
  quitting  [1mGAP[0m.  The  only  way to find out the best value of [22m[34mCRMemSize[0m is by
  experimenting.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(2));[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> IncreaseCoveringRadiusLowerBound(C,10);[0m
    [22m[35mNumber of runs: 1000  best distance so far: 3[0m
    [22m[35mNumber of runs: 2000  best distance so far: 3[0m
    [22m[35mNumber of changes: 100[0m
    [22m[35mNumber of runs: 3000  best distance so far: 3[0m
    [22m[35mNumber of runs: 4000  best distance so far: 3[0m
    [22m[35mNumber of runs: 5000  best distance so far: 3[0m
    [22m[35mNumber of runs: 6000  best distance so far: 3[0m
    [22m[35mNumber of runs: 7000  best distance so far: 3[0m
    [22m[35mNumber of changes: 200[0m
    [22m[35mNumber of runs: 8000  best distance so far: 3[0m
    [22m[35mNumber of runs: 9000  best distance so far: 3[0m
    [22m[35mNumber of runs: 10000  best distance so far: 3[0m
    [22m[35mNumber of changes: 300[0m
    [22m[35mNumber of runs: 11000  best distance so far: 3[0m
    [22m[35mNumber of runs: 12000  best distance so far: 3[0m
    [22m[35mNumber of runs: 13000  best distance so far: 3[0m
    [22m[35mNumber of changes: 400[0m
    [22m[35mNumber of runs: 14000  best distance so far: 3[0m
    [22m[35muser interrupt at... [0m
    [22m[35m#[0m
    [22m[35m# used ctrl-c to break out of execution[0m
    [22m[35m#[0m
    [22m[35m... called from [0m
    [22m[35mIncreaseCoveringRadiusLowerBound( code, -1, current ) called from[0m
    [22m[35m function( arguments ) called from read-eval-loop[0m
    [22m[35mEntering break read-eval-print loop ...[0m
    [22m[35myou can 'quit;' to quit to outer loop, or[0m
    [22m[35myou can 'return;' to continue[0m
    [22m[35mbrk> current;[0m
    [22m[35m[ Z(2)^0, Z(2)^0, Z(2)^0, Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0, 0*Z(2), Z(2)^0 ][0m
    [22m[35mbrk>[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-3 ExhaustiveSearchCoveringRadius[0m
  
  [1m[34m> ExhaustiveSearchCoveringRadius( [0m[22m[34mC[0m[1m[34m ) ______________________________[0mfunction
  
  [22m[32mExhaustiveSearchCoveringRadius[0m   does  an  exhaustive  search  to  find  the
  covering  radius of [22m[34mC[0m. Every time a coset leader of a coset with weight w is
  found, the function tries to find a coset leader of a coset with weight w+1.
  It  does this by enumerating all words of weight w+1, and checking whether a
  word is a coset leader. The start weight is the current known lower bound on
  the covering radius.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(2));[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> ExhaustiveSearchCoveringRadius(C);[0m
    [22m[35mTrying 3 ...[0m
    [22m[35m[ 3 .. 5 ][0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-4 GeneralLowerBoundCoveringRadius[0m
  
  [1m[34m> GeneralLowerBoundCoveringRadius( [0m[22m[34mC[0m[1m[34m ) _____________________________[0mfunction
  
  [22m[32mGeneralLowerBoundCoveringRadius[0m returns a lower bound on the covering radius
  of    [22m[34mC[0m.    It   uses   as   many   functions   which   names   start   with
  [22m[32mLowerBoundCoveringRadius[0m  as possible to find the best known lower bound (at
  least  that  [1mGUAVA[0m knows of) together with tables for the covering radius of
  binary linear codes with length not greater than 64.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(2));[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> GeneralLowerBoundCoveringRadius(C);[0m
    [22m[35m2[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-5 GeneralUpperBoundCoveringRadius[0m
  
  [1m[34m> GeneralUpperBoundCoveringRadius( [0m[22m[34mC[0m[1m[34m ) _____________________________[0mfunction
  
  [22m[32mGeneralUpperBoundCoveringRadius[0m  returns  an  upper  bound  on  the covering
  radius   of   [22m[34mC[0m.   It   uses  as  many  functions  which  names  start  with
  [22m[32mUpperBoundCoveringRadius[0m  as possible to find the best known upper bound (at
  least that [1mGUAVA[0m knows of).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(2));[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> GeneralUpperBoundCoveringRadius(C);[0m
    [22m[35m4[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-6 LowerBoundCoveringRadiusSphereCovering[0m
  
  [1m[34m> LowerBoundCoveringRadiusSphereCovering( [0m[22m[34mn, M[, F,] false[0m[1m[34m ) _______[0mfunction
  
  This     command     can     also     be    called    using    the    syntax
  [22m[32mLowerBoundCoveringRadiusSphereCovering(  n,  r,  [F,]  true  )[0m.  If the last
  argument of [22m[32mLowerBoundCoveringRadiusSphereCovering[0m is [22m[34mfalse[0m, then it returns
  a  lower  bound  for  the  covering radius of a code of size [22m[34mM[0m and length [22m[34mn[0m.
  Otherwise,  it  returns a lower bound for the size of a code of length [22m[34mn[0m and
  covering radius [22m[34mr[0m.
  
  [22m[34mF[0m  is  the  field  over  which  the  code is defined. If [22m[34mF[0m is omitted, it is
  assumed  that the code is over GF(2). The bound is computed according to the
  sphere covering bound:
  
  \[
       M \cdot V_q(n,r) \geq q^n
  \]
  
  where V_q(n,r) is the size of a sphere of radius r in GF(q)^n.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(2));[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> Size(C);[0m
    [22m[35m32[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35mgap> LowerBoundCoveringRadiusSphereCovering(10,32,GF(2),false);[0m
    [22m[35m2[0m
    [22m[35mgap> LowerBoundCoveringRadiusSphereCovering(10,3,GF(2),true);[0m
    [22m[35m6[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-7 LowerBoundCoveringRadiusVanWee1[0m
  
  [1m[34m> LowerBoundCoveringRadiusVanWee1( [0m[22m[34mn, M[, F,] false[0m[1m[34m ) ______________[0mfunction
  
  This     command     can     also     be    called    using    the    syntax
  [22m[32mLowerBoundCoveringRadiusVanWee1(  n, r, [F,] true )[0m. If the last argument of
  [22m[32mLowerBoundCoveringRadiusVanWee1[0m  is [22m[34mfalse[0m, then it returns a lower bound for
  the  covering radius of a code of size [22m[34mM[0m and length [22m[34mn[0m. Otherwise, it returns
  a lower bound for the size of a code of length [22m[34mn[0m and covering radius [22m[34mr[0m.
  
  [22m[34mF[0m  is  the  field  over  which  the  code is defined. If [22m[34mF[0m is omitted, it is
  assumed that the code is over GF(2).
  
  The Van Wee bound is an improvement of the sphere covering bound:
  
  \[
       M \cdot \left\{ V_q(n,r) - \frac{{n \choose
       r}}{\lceil\frac{n-r}{r+1}\rceil}
       \left(\left\lceil\frac{n+1}{r+1}\right\rceil -
       \frac{n+1}{r+1}\right) \right\} \geq q^n
  \]
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(2));[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> Size(C);[0m
    [22m[35m32[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35mgap> LowerBoundCoveringRadiusVanWee1(10,32,GF(2),false);[0m
    [22m[35m2[0m
    [22m[35mgap> LowerBoundCoveringRadiusVanWee1(10,3,GF(2),true);[0m
    [22m[35m6[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-8 LowerBoundCoveringRadiusVanWee2[0m
  
  [1m[34m> LowerBoundCoveringRadiusVanWee2( [0m[22m[34mn, M, false[0m[1m[34m ) ___________________[0mfunction
  
  This     command     can     also     be    called    using    the    syntax
  [22m[32mLowerBoundCoveringRadiusVanWee2(  n,  r  [,true]  )[0m. If the last argument of
  [22m[32mLowerBoundCoveringRadiusVanWee2[0m  is [22m[34mfalse[0m, then it returns a lower bound for
  the  covering radius of a code of size [22m[34mM[0m and length [22m[34mn[0m. Otherwise, it returns
  a lower bound for the size of a code of length [22m[34mn[0m and covering radius [22m[34mr[0m.
  
  This  bound  only  works  for  binary  codes.  It  is based on the following
  inequality:
  
  \[
       M \cdot \frac{\left( \left( V_2(n,2) - \frac{1}{2}(r+2)(r-1)
       \right) V_2(n,r) + \varepsilon V_2(n,r-2) \right)} {(V_2(n,2) -
       \frac{1}{2}(r+2)(r-1) + \varepsilon)} \geq 2^n,
  \]
  
  where
  
  \[
       \varepsilon = {r+2 \choose 2} \left\lceil {n-r+1 \choose 2} / {r+2
       \choose 2} \right\rceil - {n-r+1 \choose 2}.
  \]
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(2));[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> Size(C);[0m
    [22m[35m32[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35mgap> LowerBoundCoveringRadiusVanWee2(10,32,false);[0m
    [22m[35m2[0m
    [22m[35mgap> LowerBoundCoveringRadiusVanWee2(10,3,true);[0m
    [22m[35m7[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-9 LowerBoundCoveringRadiusCountingExcess[0m
  
  [1m[34m> LowerBoundCoveringRadiusCountingExcess( [0m[22m[34mn, M, false[0m[1m[34m ) ____________[0mfunction
  
  This command can also be called with [22m[32mLowerBoundCoveringRadiusCountingExcess(
  n,      r      [,true]      )[0m.      If      the     last     argument     of
  [22m[32mLowerBoundCoveringRadiusCountingExcess[0m  is  [22m[34mfalse[0m,  then  it returns a lower
  bound  for  the covering radius of a code of size [22m[34mM[0m and length [22m[34mn[0m. Otherwise,
  it  returns  a  lower  bound for the size of a code of length [22m[34mn[0m and covering
  radius [22m[34mr[0m.
  
  This  bound  only  works  for  binary  codes.  It  is based on the following
  inequality:
  
  \[
       M \cdot \left( \rho V_2(n,r) + \varepsilon V_2(n,r-1) \right) \geq
       (\rho + \varepsilon) 2^n,
  \]
  
  where
  
  \[
       \varepsilon = (r+1) \left\lceil\frac{n+1}{r+1}\right\rceil - (n+1)
  \]
  
  and
  
  \[
       \rho = \left\{ \begin{array}{l} n-3+\frac{2}{n}, \ \ \ \ \ \ {\rm
       if}\ r = 2\\ n-r-1 , \ \ \ \ \ \ {\rm if}\ r \geq 3 . \end{array}
       \right.
  \]
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(2));[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> Size(C);[0m
    [22m[35m32[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35mgap> LowerBoundCoveringRadiusCountingExcess(10,32,false);[0m
    [22m[35m0[0m
    [22m[35mgap> LowerBoundCoveringRadiusCountingExcess(10,3,true);[0m
    [22m[35m7[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-10 LowerBoundCoveringRadiusEmbedded1[0m
  
  [1m[34m> LowerBoundCoveringRadiusEmbedded1( [0m[22m[34mn, M, false[0m[1m[34m ) _________________[0mfunction
  
  This command can also be called with [22m[32mLowerBoundCoveringRadiusEmbedded1( n, r
  [,true]  )[0m.  If  the  last  argument of [22m[32mLowerBoundCoveringRadiusEmbedded1[0m is
  'false',  then it returns a lower bound for the covering radius of a code of
  size  [22m[34mM[0m  and length [22m[34mn[0m. Otherwise, it returns a lower bound for the size of a
  code of length [22m[34mn[0m and covering radius [22m[34mr[0m.
  
  This  bound  only  works  for  binary  codes.  It  is based on the following
  inequality:
  
  \[
       M \cdot \left( V_2(n,r) - {2r \choose r} \right) \geq 2^n - A( n,
       2r+1 ) {2r \choose r},
  \]
  
  where  A(n,d) denotes the maximal cardinality of a (binary) code of length n
  and  minimum  distance  d.  The  function [22m[32mUpperBound[0m is used to compute this
  value.
  
  Sometimes      [22m[32mLowerBoundCoveringRadiusEmbedded1[0m      is     better     than
  [22m[32mLowerBoundCoveringRadiusEmbedded2[0m, sometimes it is the other way around.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(10,5,GF(2));[0m
    [22m[35ma  [10,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> Size(C);[0m
    [22m[35m32[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35mgap> LowerBoundCoveringRadiusEmbedded1(10,32,false);[0m
    [22m[35m2[0m
    [22m[35mgap> LowerBoundCoveringRadiusEmbedded1(10,3,true);[0m
    [22m[35m7[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-11 LowerBoundCoveringRadiusEmbedded2[0m
  
  [1m[34m> LowerBoundCoveringRadiusEmbedded2( [0m[22m[34mn, M, false[0m[1m[34m ) _________________[0mfunction
  
  This command can also be called with [22m[32mLowerBoundCoveringRadiusEmbedded2( n, r
  [,true]  )[0m.  If  the  last  argument of [22m[32mLowerBoundCoveringRadiusEmbedded2[0m is
  'false',  then it returns a lower bound for the covering radius of a code of
  size  [22m[34mM[0m  and length [22m[34mn[0m. Otherwise, it returns a lower bound for the size of a
  code of length [22m[34mn[0m and covering radius [22m[34mr[0m.
  
  This  bound  only  works  for  binary  codes.  It  is based on the following
  inequality:
  
  \[
       M \cdot \left( V_2(n,r) - \frac{3}{2} {2r \choose r} \right) \geq
       2^n - 2A( n, 2r+1 ) {2r \choose r},
  \]
  
  where  A(n,d) denotes the maximal cardinality of a (binary) code of length n
  and  minimum  distance  d.  The  function [22m[32mUpperBound[0m is used to compute this
  value.
  
  Sometimes      [22m[32mLowerBoundCoveringRadiusEmbedded1[0m      is     better     than
  [22m[32mLowerBoundCoveringRadiusEmbedded2[0m, sometimes it is the other way around.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(15,5,GF(2));[0m
    [22m[35ma  [15,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> Size(C);[0m
    [22m[35m32[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m6[0m
    [22m[35mgap> LowerBoundCoveringRadiusEmbedded2(10,32,false);[0m
    [22m[35m2[0m
    [22m[35mgap> LowerBoundCoveringRadiusEmbedded2(10,3,true);[0m
    [22m[35m7[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-12 LowerBoundCoveringRadiusInduction[0m
  
  [1m[34m> LowerBoundCoveringRadiusInduction( [0m[22m[34mn, r[0m[1m[34m ) ________________________[0mfunction
  
  [22m[32mLowerBoundCoveringRadiusInduction[0m  returns  a  lower bound for the size of a
  code with length [22m[34mn[0m and covering radius [22m[34mr[0m.
  
  If n = 2r+2 and r >= 1, the returned value is 4.
  
  If n = 2r+3 and r >= 1, the returned value is 7.
  
  If n = 2r+4 and r >= 4, the returned value is 8.
  
  Otherwise, 0 is returned.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(15,5,GF(2));[0m
    [22m[35ma  [15,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m5[0m
    [22m[35mgap> LowerBoundCoveringRadiusInduction(15,6);[0m
    [22m[35m7[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-13 UpperBoundCoveringRadiusRedundancy[0m
  
  [1m[34m> UpperBoundCoveringRadiusRedundancy( [0m[22m[34mC[0m[1m[34m ) __________________________[0mfunction
  
  [22m[32mUpperBoundCoveringRadiusRedundancy[0m  returns  the redundancy of [22m[34mC[0m as an upper
  bound for the covering radius of [22m[34mC[0m. [22m[34mC[0m must be a linear code.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(15,5,GF(2));[0m
    [22m[35ma  [15,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m5[0m
    [22m[35mgap> UpperBoundCoveringRadiusRedundancy(C);[0m
    [22m[35m10[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-14 UpperBoundCoveringRadiusDelsarte[0m
  
  [1m[34m> UpperBoundCoveringRadiusDelsarte( [0m[22m[34mC[0m[1m[34m ) ____________________________[0mfunction
  
  [22m[32mUpperBoundCoveringRadiusDelsarte[0m  returns  an  upper  bound for the covering
  radius  of  [22m[34mC[0m. This upper bound is equal to the external distance of [22m[34mC[0m, this
  is the minimum distance of the dual code, if [22m[34mC[0m is a linear code.
  
  This is described in Theorem 11.3.3 of [HP03].
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(15,5,GF(2));[0m
    [22m[35ma  [15,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m5[0m
    [22m[35mgap> UpperBoundCoveringRadiusDelsarte(C);[0m
    [22m[35m13[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-15 UpperBoundCoveringRadiusStrength[0m
  
  [1m[34m> UpperBoundCoveringRadiusStrength( [0m[22m[34mC[0m[1m[34m ) ____________________________[0mfunction
  
  [22m[32mUpperBoundCoveringRadiusStrength[0m  returns  an  upper  bound for the covering
  radius of [22m[34mC[0m.
  
  First  the  code  is punctured at the zero coordinates (i.e. the coordinates
  where all codewords have a zero). If the remaining code has [22m[36mstrength[0m 1 (i.e.
  each  coordinate  contains  each  element  of  the  field an equal number of
  times),  then it returns fracq-1qm + (n-m) (where q is the size of the field
  and  m  is the length of punctured code), otherwise it returns n. This bound
  works for all codes.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(15,5,GF(2));[0m
    [22m[35ma  [15,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m5[0m
    [22m[35mgap> UpperBoundCoveringRadiusStrength(C);[0m
    [22m[35m7[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-16 UpperBoundCoveringRadiusGriesmerLike[0m
  
  [1m[34m> UpperBoundCoveringRadiusGriesmerLike( [0m[22m[34mC[0m[1m[34m ) ________________________[0mfunction
  
  This  function  returns  an  upper bound for the covering radius of [22m[34mC[0m, which
  must be linear, in a Griesmer-like fashion. It returns
  
  \[
       n - \sum_{i=1}^k \left\lceil \frac{d}{q^i} \right\rceil
  \]
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=RandomLinearCode(15,5,GF(2));[0m
    [22m[35ma  [15,5,?] randomly generated code over GF(2)[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m5[0m
    [22m[35mgap> UpperBoundCoveringRadiusGriesmerLike(C);[0m
    [22m[35m9[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.2-17 UpperBoundCoveringRadiusCyclicCode[0m
  
  [1m[34m> UpperBoundCoveringRadiusCyclicCode( [0m[22m[34mC[0m[1m[34m ) __________________________[0mfunction
  
  This  function  returns  an  upper bound for the covering radius of [22m[34mC[0m, which
  must be a cyclic code. It returns
  
  \[
       n - k + 1 - \left\lceil \frac{w(g(x))}{2} \right\rceil,
  \]
  
  where g(x) is the generator polynomial of [22m[34mC[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C:=CyclicCodes(15,GF(2))[3];[0m
    [22m[35ma cyclic [15,12,1..2]1..3 enumerated code over GF(2)[0m
    [22m[35mgap> CoveringRadius(C);[0m
    [22m[35m3[0m
    [22m[35mgap> UpperBoundCoveringRadiusCyclicCode(C);[0m
    [22m[35m3[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m7.3 Special matrices in [1mGUAVA[1m[4m[31m[0m
  
  This  section explains functions that work with special matrices [1mGUAVA[0m needs
  for several codes.
  
  Firstly,  we  describe  some  matrix generating functions (see [1m[34mKrawtchoukMat[0m
  ([1m7.3-1[0m), [1m[34mGrayMat[0m ([1m7.3-2[0m), [1m[34mSylvesterMat[0m ([1m7.3-3[0m), [1m[34mHadamardMat[0m ([1m7.3-4[0m) and [1m[34mMOLS[0m
  ([1m7.3-11[0m)).
  
  Next  we  describe  two functions regarding a standard form of matrices (see
  [1m[34mPutStandardForm[0m ([1m7.3-6[0m) and [1m[34mIsInStandardForm[0m ([1m7.3-7[0m)).
  
  Then  we  describe  functions that return a matrix after a manipulation (see
  [1m[34mPermutedCols[0m     ([1m7.3-8[0m),     [1m[34mVerticalConversionFieldMat[0m     ([1m7.3-9[0m)     and
  [1m[34mHorizontalConversionFieldMat[0m ([1m7.3-10[0m)).
  
  Finally,  we  describe  functions  that  do  some  tests  on  matrices  (see
  [1m[34mIsLatinSquare[0m ([1m7.3-12[0m) and [1m[34mAreMOLS[0m ([1m7.3-13[0m)).
  
  [1m[4m[31m7.3-1 KrawtchoukMat[0m
  
  [1m[34m> KrawtchoukMat( [0m[22m[34mn, q[0m[1m[34m ) ____________________________________________[0mfunction
  
  [22m[32mKrawtchoukMat[0m  returns the n+1 by n+1 matrix K=(k_ij) defined by k_ij=K_i(j)
  for i,j=0,...,n. K_i(j) is the Krawtchouk number (see [1m[34mKrawtchouk[0m ([1m7.5-6[0m)). [22m[34mn[0m
  must  be  a  positive  integer and [22m[34mq[0m a prime power. The Krawtchouk matrix is
  used in the [22m[36mMacWilliams identities[0m, defining the relation between the weight
  distribution  of  a  code  of  length [22m[34mn[0m over a field of size [22m[34mq[0m, and its dual
  code.  Each  call  to  [22m[32mKrawtchoukMat[0m  returns a new matrix, so it is safe to
  modify the result.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> PrintArray( KrawtchoukMat( 3, 2 ) );[0m
    [22m[35m[ [   1,   1,   1,   1 ],[0m
    [22m[35m  [   3,   1,  -1,  -3 ],[0m
    [22m[35m  [   3,  -1,  -1,   3 ],[0m
    [22m[35m  [   1,  -1,   1,  -1 ] ][0m
    [22m[35mgap> C := HammingCode( 3 );; a := WeightDistribution( C );[0m
    [22m[35m[ 1, 0, 0, 7, 7, 0, 0, 1 ][0m
    [22m[35mgap> n := WordLength( C );; q := Size( LeftActingDomain( C ) );;[0m
    [22m[35mgap> k := Dimension( C );;[0m
    [22m[35mgap> q^( -k ) * KrawtchoukMat( n, q ) * a;[0m
    [22m[35m[ 1, 0, 0, 0, 7, 0, 0, 0 ][0m
    [22m[35mgap> WeightDistribution( DualCode( C ) );[0m
    [22m[35m[ 1, 0, 0, 0, 7, 0, 0, 0 ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-2 GrayMat[0m
  
  [1m[34m> GrayMat( [0m[22m[34mn, F[0m[1m[34m ) __________________________________________________[0mfunction
  
  [22m[32mGrayMat[0m  returns a list of all different vectors (see [1mGAP[0m's [22m[32mVectors[0m command)
  of  length  [22m[34mn[0m  over  the  field [22m[34mF[0m, using Gray ordering. [22m[34mn[0m must be a positive
  integer.  This  order  has  the  property  that subsequent vectors differ in
  exactly  one  coordinate.  The  first vector is always the null vector. Each
  call to [22m[32mGrayMat[0m returns a new matrix, so it is safe to modify the result.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> GrayMat(3);[0m
    [22m[35m[ [ 0*Z(2), 0*Z(2), 0*Z(2) ], [ 0*Z(2), 0*Z(2), Z(2)^0 ],[0m
    [22m[35m  [ 0*Z(2), Z(2)^0, Z(2)^0 ], [ 0*Z(2), Z(2)^0, 0*Z(2) ],[0m
    [22m[35m  [ Z(2)^0, Z(2)^0, 0*Z(2) ], [ Z(2)^0, Z(2)^0, Z(2)^0 ],[0m
    [22m[35m  [ Z(2)^0, 0*Z(2), Z(2)^0 ], [ Z(2)^0, 0*Z(2), 0*Z(2) ] ][0m
    [22m[35mgap> G := GrayMat( 4, GF(4) );; Length(G);[0m
    [22m[35m256          # the length of a GrayMat is always q^n[0m
    [22m[35mgap> G[101] - G[100];[0m
    [22m[35m[ 0*Z(2), 0*Z(2), Z(2)^0, 0*Z(2) ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-3 SylvesterMat[0m
  
  [1m[34m> SylvesterMat( [0m[22m[34mn[0m[1m[34m ) ________________________________________________[0mfunction
  
  [22m[32mSylvesterMat[0m  returns  the  ntimes  n Sylvester matrix of order [22m[34mn[0m. This is a
  special  case  of  the Hadamard matrices (see [1m[34mHadamardMat[0m ([1m7.3-4[0m)). For this
  construction,  [22m[34mn[0m  must  be a power of 2. Each call to [22m[32mSylvesterMat[0m returns a
  new matrix, so it is safe to modify the result.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> PrintArray(SylvesterMat(2));[0m
    [22m[35m[ [   1,   1 ],[0m
    [22m[35m  [   1,  -1 ] ][0m
    [22m[35mgap> PrintArray( SylvesterMat(4) );[0m
    [22m[35m[ [   1,   1,   1,   1 ],[0m
    [22m[35m  [   1,  -1,   1,  -1 ],[0m
    [22m[35m  [   1,   1,  -1,  -1 ],[0m
    [22m[35m  [   1,  -1,  -1,   1 ] ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-4 HadamardMat[0m
  
  [1m[34m> HadamardMat( [0m[22m[34mn[0m[1m[34m ) _________________________________________________[0mfunction
  
  [22m[32mHadamardMat[0m returns a Hadamard matrix of order [22m[34mn[0m. This is an ntimes n matrix
  with  the  property  that  the  matrix multiplied by its transpose returns [22m[34mn[0m
  times  the  identity  matrix. This is only possible for n=1, n=2 or in cases
  where [22m[34mn[0m is a multiple of 4. If the matrix does not exist or is not known (as
  of  1998),  [22m[32mHadamardMat[0m  returns  an  error.  A large number of construction
  methods  is known to create these matrices for different orders. [22m[32mHadamardMat[0m
  makes   use   of   two  construction  methods  (among  which  the  Sylvester
  construction  --  see [1m[34mSylvesterMat[0m ([1m7.3-3[0m)). These methods cover most of the
  possible  Hadamard  matrices, although some special algorithms have not been
  implemented  yet.  The  following  orders  less  than 100 do not yet have an
  implementation for a Hadamard matrix in [1mGUAVA[0m: 28, 36, 52, 76, 92.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> C := HadamardMat(8);; PrintArray(C);[0m
    [22m[35m[ [   1,   1,   1,   1,   1,   1,   1,   1 ],[0m
    [22m[35m  [   1,  -1,   1,  -1,   1,  -1,   1,  -1 ],[0m
    [22m[35m  [   1,   1,  -1,  -1,   1,   1,  -1,  -1 ],[0m
    [22m[35m  [   1,  -1,  -1,   1,   1,  -1,  -1,   1 ],[0m
    [22m[35m  [   1,   1,   1,   1,  -1,  -1,  -1,  -1 ],[0m
    [22m[35m  [   1,  -1,   1,  -1,  -1,   1,  -1,   1 ],[0m
    [22m[35m  [   1,   1,  -1,  -1,  -1,  -1,   1,   1 ],[0m
    [22m[35m  [   1,  -1,  -1,   1,  -1,   1,   1,  -1 ] ][0m
    [22m[35mgap> C * TransposedMat(C) = 8 * IdentityMat( 8, 8 );[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-5 VandermondeMat[0m
  
  [1m[34m> VandermondeMat( [0m[22m[34mX, a[0m[1m[34m ) ___________________________________________[0mfunction
  
  The  function [22m[32mVandermondeMat[0m returns the (a+1)times n matrix of powers x_i^j
  where  [22m[34mX[0m  is  a  list  of  elements  of  a field, X= x_1,...,x_n, and [22m[34ma[0m is a
  non-negative integer.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> M:=VandermondeMat([Z(5),Z(5)^2,Z(5)^0,Z(5)^3],2);[0m
    [22m[35m[ [ Z(5)^0, Z(5), Z(5)^2 ], [ Z(5)^0, Z(5)^2, Z(5)^0 ],[0m
    [22m[35m  [ Z(5)^0, Z(5)^0, Z(5)^0 ], [ Z(5)^0, Z(5)^3, Z(5)^2 ] ][0m
    [22m[35mgap> Display(M);[0m
    [22m[35m 1 2 4[0m
    [22m[35m 1 4 1[0m
    [22m[35m 1 1 1[0m
    [22m[35m 1 3 4[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-6 PutStandardForm[0m
  
  [1m[34m> PutStandardForm( [0m[22m[34mM[, idleft][0m[1m[34m ) ___________________________________[0mfunction
  
  We  say  that  a  ktimes  n matrix is in [22m[36mstandard form[0m if it is equal to the
  block  matrix  (I  |  A),  for some ktimes (n-k) matrix A and where I is the
  ktimes  k  identity matrix. It follows from a basis result in linear algebra
  that,  after  a  possible  permutation  of the columns, using elementary row
  operations,  every  matrix  can be reduced to standard form. [22m[32mPutStandardForm[0m
  puts  a  matrix [22m[34mM[0m in standard form, and returns the permutation needed to do
  so.  [22m[34midleft[0m is a boolean that sets the position of the identity matrix in [22m[34mM[0m.
  (The default for [22m[34midleft[0m is `true'.) If [22m[34midleft[0m is set to `true', the identity
  matrix is put on the left side of [22m[34mM[0m. Otherwise, it is put at the right side.
  (This  option  is useful when putting a check matrix of a code into standard
  form.)  The  function [22m[32mBaseMat[0m also returns a similar standard form, but does
  not  apply  column  permutations. The rows of the matrix still span the same
  vector  space  after [22m[32mBaseMat[0m, but after calling [22m[32mPutStandardForm[0m, this is not
  necessarily true.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> M := Z(2)*[[1,0,0,1],[0,0,1,1]];; PrintArray(M);[0m
    [22m[35m[ [    Z(2),  0*Z(2),  0*Z(2),    Z(2) ],[0m
    [22m[35m  [  0*Z(2),  0*Z(2),    Z(2),    Z(2) ] ][0m
    [22m[35mgap> PutStandardForm(M);                   # identity at the left side[0m
    [22m[35m(2,3)[0m
    [22m[35mgap> PrintArray(M);[0m
    [22m[35m[ [    Z(2),  0*Z(2),  0*Z(2),    Z(2) ],[0m
    [22m[35m  [  0*Z(2),    Z(2),  0*Z(2),    Z(2) ] ][0m
    [22m[35mgap> PutStandardForm(M, false);            # identity at the right side[0m
    [22m[35m(1,4,3)[0m
    [22m[35mgap> PrintArray(M);[0m
    [22m[35m[ [  0*Z(2),    Z(2),    Z(2),  0*Z(2) ],[0m
    [22m[35m  [  0*Z(2),    Z(2),  0*Z(2),    Z(2) ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-7 IsInStandardForm[0m
  
  [1m[34m> IsInStandardForm( [0m[22m[34mM[, idleft][0m[1m[34m ) __________________________________[0mfunction
  
  [22m[32mIsInStandardForm[0m  determines  if  [22m[34mM[0m is in standard form. [22m[34midleft[0m is a boolean
  that   indicates   the   position  of  the  identity  matrix  in  [22m[34mM[0m,  as  in
  [22m[32mPutStandardForm[0m  (see  [1m[34mPutStandardForm[0m  ([1m7.3-6[0m)). [22m[32mIsInStandardForm[0m checks if
  the  identity  matrix  is  at  the left side of [22m[34mM[0m, otherwise if it is at the
  right side. The elements of [22m[34mM[0m may be elements of any field.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> IsInStandardForm(IdentityMat(7, GF(2)));[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsInStandardForm([[1, 1, 0], [1, 0, 1]], false);[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsInStandardForm([[1, 3, 2, 7]]);[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsInStandardForm(HadamardMat(4));[0m
    [22m[35mfalse [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-8 PermutedCols[0m
  
  [1m[34m> PermutedCols( [0m[22m[34mM, P[0m[1m[34m ) _____________________________________________[0mfunction
  
  [22m[32mPermutedCols[0m returns a matrix [22m[34mM[0m with a permutation [22m[34mP[0m applied to its columns.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> M := [[1,2,3,4],[1,2,3,4]];; PrintArray(M);[0m
    [22m[35m[ [  1,  2,  3,  4 ],[0m
    [22m[35m  [  1,  2,  3,  4 ] ][0m
    [22m[35mgap> PrintArray(PermutedCols(M, (1,2,3)));[0m
    [22m[35m[ [  3,  1,  2,  4 ],[0m
    [22m[35m  [  3,  1,  2,  4 ] ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-9 VerticalConversionFieldMat[0m
  
  [1m[34m> VerticalConversionFieldMat( [0m[22m[34mM, F[0m[1m[34m ) _______________________________[0mfunction
  
  [22m[32mVerticalConversionFieldMat[0m  returns the matrix [22m[34mM[0m with its elements converted
  from  a field F=GF(q^m), q prime, to a field GF(q). Each element is replaced
  by  its  representation  over  the  latter  field,  placed vertically in the
  matrix, using the GF(p)-vector space isomorphism
  
  \[
       [...] : GF(q)\rightarrow GF(p)^m,
  \]
  
  with q=p^m.
  
  If  [22m[34mM[0m  is  a  k by n matrix, the result is a k* m times n matrix, since each
  element of GF(q^m) can be represented in GF(q) using m elements.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> M := Z(9)*[[1,2],[2,1]];; PrintArray(M);[0m
    [22m[35m[ [    Z(3^2),  Z(3^2)^5 ],[0m
    [22m[35m  [  Z(3^2)^5,    Z(3^2) ] ][0m
    [22m[35mgap> DefaultField( Flat(M) );[0m
    [22m[35mGF(3^2)[0m
    [22m[35mgap> VCFM := VerticalConversionFieldMat( M, GF(9) );; PrintArray(VCFM);[0m
    [22m[35m[ [  0*Z(3),  0*Z(3) ],[0m
    [22m[35m  [  Z(3)^0,    Z(3) ],[0m
    [22m[35m  [  0*Z(3),  0*Z(3) ],[0m
    [22m[35m  [    Z(3),  Z(3)^0 ] ][0m
    [22m[35mgap> DefaultField( Flat(VCFM) );[0m
    [22m[35mGF(3) [0m
  [22m[35m------------------------------------------------------------------[0m
  
  A      similar     function     is     [22m[32mHorizontalConversionFieldMat[0m     (see
  [1m[34mHorizontalConversionFieldMat[0m ([1m7.3-10[0m)).
  
  [1m[4m[31m7.3-10 HorizontalConversionFieldMat[0m
  
  [1m[34m> HorizontalConversionFieldMat( [0m[22m[34mM, F[0m[1m[34m ) _____________________________[0mfunction
  
  [22m[32mHorizontalConversionFieldMat[0m   returns   the  matrix  [22m[34mM[0m  with  its  elements
  converted from a field F=GF(q^m), q prime, to a field GF(q). Each element is
  replaced by its representation over the latter field, placed horizontally in
  the matrix.
  
  If  [22m[34mM[0m  is a k times n matrix, the result is a ktimes mtimes n* m matrix. The
  new word length of the resulting code is equal to n* m, because each element
  of  GF(q^m)  can be represented in GF(q) using m elements. The new dimension
  is  equal  to ktimes m because the new matrix should be a basis for the same
  number of vectors as the old one.
  
  [22m[32mConversionFieldCode[0m  uses  horizontal  conversion  to  convert  a  code (see
  [1m[34mConversionFieldCode[0m ([1m6.1-14[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> M := Z(9)*[[1,2],[2,1]];; PrintArray(M);[0m
    [22m[35m[ [    Z(3^2),  Z(3^2)^5 ],[0m
    [22m[35m  [  Z(3^2)^5,    Z(3^2) ] ][0m
    [22m[35mgap> DefaultField( Flat(M) );[0m
    [22m[35mGF(3^2)[0m
    [22m[35mgap> HCFM := HorizontalConversionFieldMat(M, GF(9));; PrintArray(HCFM);[0m
    [22m[35m[ [  0*Z(3),  Z(3)^0,  0*Z(3),    Z(3) ],[0m
    [22m[35m  [  Z(3)^0,  Z(3)^0,    Z(3),    Z(3) ],[0m
    [22m[35m  [  0*Z(3),    Z(3),  0*Z(3),  Z(3)^0 ],[0m
    [22m[35m  [    Z(3),    Z(3),  Z(3)^0,  Z(3)^0 ] ][0m
    [22m[35mgap> DefaultField( Flat(HCFM) );[0m
    [22m[35mGF(3) [0m
  [22m[35m------------------------------------------------------------------[0m
  
  A      similar      function      is     [22m[32mVerticalConversionFieldMat[0m     (see
  [1m[34mVerticalConversionFieldMat[0m ([1m7.3-9[0m)).
  
  [1m[4m[31m7.3-11 MOLS[0m
  
  [1m[34m> MOLS( [0m[22m[34mq[, n][0m[1m[34m ) ___________________________________________________[0mfunction
  
  [22m[32mMOLS[0m  returns  a list of [22m[34mn[0m [22m[36mMutually Orthogonal Latin Squares[0m (MOLS). A [22m[36mLatin
  square[0m of order [22m[34mq[0m is a qtimes q matrix whose entries are from a set F_q of [22m[34mq[0m
  distinct  symbols  ([1mGUAVA[0m  uses the integers from 0 to [22m[34mq[0m) such that each row
  and each column of the matrix contains each symbol exactly once.
  
  A  set  of  Latin  squares  is a set of MOLS if and only if for each pair of
  Latin  squares  in  this set, every ordered pair of elements that are in the
  same position in these matrices occurs exactly once.
  
  [22m[34mn[0m must be less than [22m[34mq[0m. If [22m[34mn[0m is omitted, two MOLS are returned. If [22m[34mq[0m is not a
  prime  power,  at most 2 MOLS can be created. For all values of [22m[34mq[0m with q > 2
  and  q  <> 6, a list of MOLS can be constructed. However, [1mGUAVA[0m does not yet
  construct  MOLS  for  q= 2 mod 4. If it is not possible to construct [22m[34mn[0m MOLS,
  the function returns `false'.
  
  MOLS are used to create [22m[34mq[0m-ary codes (see [1m[34mMOLSCode[0m ([1m5.1-4[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> M := MOLS( 4, 3 );;PrintArray( M[1] );[0m
    [22m[35m[ [  0,  1,  2,  3 ],[0m
    [22m[35m  [  1,  0,  3,  2 ],[0m
    [22m[35m  [  2,  3,  0,  1 ],[0m
    [22m[35m  [  3,  2,  1,  0 ] ][0m
    [22m[35mgap> PrintArray( M[2] );[0m
    [22m[35m[ [  0,  2,  3,  1 ],[0m
    [22m[35m  [  1,  3,  2,  0 ],[0m
    [22m[35m  [  2,  0,  1,  3 ],[0m
    [22m[35m  [  3,  1,  0,  2 ] ][0m
    [22m[35mgap> PrintArray( M[3] );[0m
    [22m[35m[ [  0,  3,  1,  2 ],[0m
    [22m[35m  [  1,  2,  0,  3 ],[0m
    [22m[35m  [  2,  1,  3,  0 ],[0m
    [22m[35m  [  3,  0,  2,  1 ] ][0m
    [22m[35mgap> MOLS( 12, 3 );[0m
    [22m[35mfalse [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-12 IsLatinSquare[0m
  
  [1m[34m> IsLatinSquare( [0m[22m[34mM[0m[1m[34m ) _______________________________________________[0mfunction
  
  [22m[32mIsLatinSquare[0m determines if a matrix [22m[34mM[0m is a Latin square. For a Latin square
  of  size  ntimes  n,  each  row  and  each  column contains all the integers
  1,dots,n exactly once.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> IsLatinSquare([[1,2],[2,1]]);[0m
    [22m[35mtrue[0m
    [22m[35mgap> IsLatinSquare([[1,2,3],[2,3,1],[1,3,2]]);[0m
    [22m[35mfalse [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.3-13 AreMOLS[0m
  
  [1m[34m> AreMOLS( [0m[22m[34mL[0m[1m[34m ) _____________________________________________________[0mfunction
  
  [22m[32mAreMOLS[0m  determines  if  [22m[34mL[0m  is  a  list of mutually orthogonal Latin squares
  (MOLS).  For each pair of Latin squares in this list, the function checks if
  each  ordered  pair  of  elements  that  are  in  the same position in these
  matrices  occurs  exactly  once.  The  function  [22m[32mMOLS[0m creates MOLS (see [1m[34mMOLS[0m
  ([1m7.3-11[0m)).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> M := MOLS(4,2);[0m
    [22m[35m[ [ [ 0, 1, 2, 3 ], [ 1, 0, 3, 2 ], [ 2, 3, 0, 1 ], [ 3, 2, 1, 0 ] ],[0m
    [22m[35m  [ [ 0, 2, 3, 1 ], [ 1, 3, 2, 0 ], [ 2, 0, 1, 3 ], [ 3, 1, 0, 2 ] ] ][0m
    [22m[35mgap> AreMOLS(M);[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m7.4 Some functions related to the norm of a code[0m
  
  In  this  section,  some functions that can be used to compute the norm of a
  code  and  to  decide upon its normality are discussed. Typically, these are
  applied  to  binary  linear  codes.  The  definitions  of  this section were
  introduced in Graham and Sloane [GS85].
  
  [1m[4m[31m7.4-1 CoordinateNorm[0m
  
  [1m[34m> CoordinateNorm( [0m[22m[34mC, coord[0m[1m[34m ) _______________________________________[0mfunction
  
  [22m[32mCoordinateNorm[0m  returns  the  norm of [22m[34mC[0m with respect to coordinate [22m[34mcoord[0m. If
  C_a  =  c  in  C  | c_coord = a, then the norm of [22m[34mC[0m with respect to [22m[34mcoord[0m is
  defined as
  
  \[
       \max_{v \in GF(q)^n} \sum_{a=1}^q d(x,C_a),
  \]
  
  with the convention that d(x,C_a) = n if C_a is empty.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> CoordinateNorm( HammingCode( 3, GF(2) ), 3 );[0m
    [22m[35m3 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.4-2 CodeNorm[0m
  
  [1m[34m> CodeNorm( [0m[22m[34mC[0m[1m[34m ) ____________________________________________________[0mfunction
  
  [22m[32mCodeNorm[0m returns the norm of [22m[34mC[0m. The [22m[36mnorm[0m of a code is defined as the minimum
  of the norms for the respective coordinates of the code. In effect, for each
  coordinate  [22m[32mCoordinateNorm[0m  is  called,  and  the  minimum of the calculated
  numbers is returned.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> CodeNorm( HammingCode( 3, GF(2) ) );[0m
    [22m[35m3 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.4-3 IsCoordinateAcceptable[0m
  
  [1m[34m> IsCoordinateAcceptable( [0m[22m[34mC, coord[0m[1m[34m ) _______________________________[0mfunction
  
  [22m[32mIsCoordinateAcceptable[0m   returns   `true'   if  coordinate  [22m[34mcoord[0m  of  [22m[34mC[0m  is
  acceptable.  A  coordinate is called [22m[36macceptable[0m if the norm of the code with
  respect to that coordinate is not more than two times the covering radius of
  the code plus one.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> IsCoordinateAcceptable( HammingCode( 3, GF(2) ), 3 );[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.4-4 GeneralizedCodeNorm[0m
  
  [1m[34m> GeneralizedCodeNorm( [0m[22m[34mC, subcode1, subscode2, ..., subcodek[0m[1m[34m ) _____[0mfunction
  
  [22m[32mGeneralizedCodeNorm[0m returns the [22m[34mk[0m-norm of [22m[34mC[0m with respect to [22m[34mk[0m subcodes.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> c := RepetitionCode( 7, GF(2) );;[0m
    [22m[35mgap> ham := HammingCode( 3, GF(2) );;[0m
    [22m[35mgap> d := EvenWeightSubcode( ham );;[0m
    [22m[35mgap> e := ConstantWeightSubcode( ham, 3 );;[0m
    [22m[35mgap> GeneralizedCodeNorm( ham, c, d, e );[0m
    [22m[35m4 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.4-5 IsNormalCode[0m
  
  [1m[34m> IsNormalCode( [0m[22m[34mC[0m[1m[34m ) ________________________________________________[0mfunction
  
  [22m[32mIsNormalCode[0m  returns  `true' if [22m[34mC[0m is normal. A code is called [22m[36mnormal[0m if the
  norm  of the code is not more than two times the covering radius of the code
  plus  one.  Almost  all codes are normal, however some (non-linear) abnormal
  codes have been found.
  
  Often,  it  is  difficult  to  find out whether a code is normal, because it
  involves  computing  the  covering  radius.  However, [22m[32mIsNormalCode[0m uses much
  information  from the literature (in particular, [GS85]) about normality for
  certain code parameters.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> IsNormalCode( HammingCode( 3, GF(2) ) );[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m7.5 Miscellaneous functions[0m
  
  In  this  section  we describe several vector space functions [1mGUAVA[0m uses for
  constructing codes or performing calculations with codes.
  
  In  this  section, some new miscellaneous functions are described, including
  weight  enumerators,  the  MacWilliams-transform  and  affinity  and  almost
  affinity of codes.
  
  [1m[4m[31m7.5-1 CodeWeightEnumerator[0m
  
  [1m[34m> CodeWeightEnumerator( [0m[22m[34mC[0m[1m[34m ) ________________________________________[0mfunction
  
  [22m[32mCodeWeightEnumerator[0m returns a polynomial of the following form:
  
  \[
       f(x) = \sum_{i=0}^{n} A_i x^i,
  \]
  
  where A_i is the number of codewords in [22m[34mC[0m with weight i.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> CodeWeightEnumerator( ElementsCode( [ [ 0,0,0 ], [ 0,0,1 ],[0m
    [22m[35m> [ 0,1,1 ], [ 1,1,1 ] ], GF(2) ) );[0m
    [22m[35mx^3 + x^2 + x + 1[0m
    [22m[35mgap> CodeWeightEnumerator( HammingCode( 3, GF(2) ) );[0m
    [22m[35mx^7 + 7*x^4 + 7*x^3 + 1 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-2 CodeDistanceEnumerator[0m
  
  [1m[34m> CodeDistanceEnumerator( [0m[22m[34mC, w[0m[1m[34m ) ___________________________________[0mfunction
  
  [22m[32mCodeDistanceEnumerator[0m returns a polynomial of the following form:
  
  \[
       f(x) = \sum_{i=0}^{n} B_i x^i,
  \]
  
  where B_i is the number of codewords with distance i to [22m[34mw[0m.
  
  If  [22m[34mw[0m is a codeword, then [22m[32mCodeDistanceEnumerator[0m returns the same polynomial
  as [22m[32mCodeWeightEnumerator[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> CodeDistanceEnumerator( HammingCode( 3, GF(2) ),[0,0,0,0,0,0,1] );[0m
    [22m[35mx^6 + 3*x^5 + 4*x^4 + 4*x^3 + 3*x^2 + x[0m
    [22m[35mgap> CodeDistanceEnumerator( HammingCode( 3, GF(2) ),[1,1,1,1,1,1,1] );[0m
    [22m[35mx^7 + 7*x^4 + 7*x^3 + 1 # `[1,1,1,1,1,1,1]' $\in$ `HammingCode( 3, GF(2 ) )'[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-3 CodeMacWilliamsTransform[0m
  
  [1m[34m> CodeMacWilliamsTransform( [0m[22m[34mC[0m[1m[34m ) ____________________________________[0mfunction
  
  [22m[32mCodeMacWilliamsTransform[0m returns a polynomial of the following form:
  
  \[
       f(x) = \sum_{i=0}^{n} C_i x^i,
  \]
  
  where C_i is the number of codewords with weight i in the [22m[36mdual[0m code of [22m[34mC[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> CodeMacWilliamsTransform( HammingCode( 3, GF(2) ) );[0m
    [22m[35m7*x^4 + 1 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-4 CodeDensity[0m
  
  [1m[34m> CodeDensity( [0m[22m[34mC[0m[1m[34m ) _________________________________________________[0mfunction
  
  [22m[32mCodeDensity[0m returns the [22m[36mdensity[0m of [22m[34mC[0m. The density of a code is defined as
  
  \[
       \frac{M \cdot V_q(n,t)}{q^n},
  \]
  
  where  M is the size of the code, V_q(n,t) is the size of a sphere of radius
  t  in GF(q^n) (which may be computed using [22m[32mSphereContent[0m), t is the covering
  radius of the code and n is the length of the code.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> CodeDensity( HammingCode( 3, GF(2) ) );[0m
    [22m[35m1[0m
    [22m[35mgap> CodeDensity( ReedMullerCode( 1, 4 ) );[0m
    [22m[35m14893/2048 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-5 SphereContent[0m
  
  [1m[34m> SphereContent( [0m[22m[34mn, t, F[0m[1m[34m ) _________________________________________[0mfunction
  
  [22m[32mSphereContent[0m  returns the content of a ball of radius [22m[34mt[0m around an arbitrary
  element  of  the  vectorspace F^n. This is the cardinality of the set of all
  elements of F^n that are at distance (see [1m[34mDistanceCodeword[0m ([1m3.6-2[0m) less than
  or equal to [22m[34mt[0m from an element of F^n.
  
  In  the  context  of  codes,  the function is used to determine if a code is
  perfect.  A  code  is  [22m[36mperfect[0m  if  spheres of radius t around all codewords
  partition  the  whole  ambient vector space, where [22m[36mt[0m is the number of errors
  the code can correct.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> SphereContent( 15, 0, GF(2) );[0m
    [22m[35m1    # Only one word with distance 0, which is the word itself[0m
    [22m[35mgap> SphereContent( 11, 3, GF(4) );[0m
    [22m[35m4984[0m
    [22m[35mgap> C := HammingCode(5);[0m
    [22m[35ma linear [31,26,3]1 Hamming (5,2) code over GF(2)[0m
    [22m[35m#the minimum distance is 3, so the code can correct one error[0m
    [22m[35mgap> ( SphereContent( 31, 1, GF(2) ) * Size(C) ) = 2 ^ 31;[0m
    [22m[35mtrue [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-6 Krawtchouk[0m
  
  [1m[34m> Krawtchouk( [0m[22m[34mk, i, n, q[0m[1m[34m ) _________________________________________[0mfunction
  
  [22m[32mKrawtchouk[0m  returns the Krawtchouk number K_k(i). [22m[34mq[0m must be a prime power, [22m[34mn[0m
  must  be  a  positive integer, [22m[34mk[0m must be a non-negative integer less then or
  equal  to  [22m[34mn[0m  and  [22m[34mi[0m  can  be any integer. (See [1m[34mKrawtchoukMat[0m ([1m7.3-1[0m)). This
  number is the value at x=i of the polynomial
  
  \[
       K_k^{n,q}(x) =\sum_{j=0}^n (-1)^j(q-1)^{k-j}b(x,j)b(n-x,k-j),
  \]
  
  where  $b(v,u)=u!/(v!(v-u)!)$  is  the  binomial  coefficient  if  $u,v$ are
  integers. For more properties of these polynomials, see [MS83].
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> Krawtchouk( 2, 0, 3, 2);[0m
    [22m[35m3 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-7 PrimitiveUnityRoot[0m
  
  [1m[34m> PrimitiveUnityRoot( [0m[22m[34mF, n[0m[1m[34m ) _______________________________________[0mfunction
  
  [22m[32mPrimitiveUnityRoot[0m  returns  a  primitive [22m[34mn[0m-th root of unity in an extension
  field  of  [22m[34mF[0m. This is a finite field element a with the property a^n=1 in [22m[34mF[0m,
  and [22m[34mn[0m is the smallest integer such that this equality holds.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> PrimitiveUnityRoot( GF(2), 15 );[0m
    [22m[35mZ(2^4)[0m
    [22m[35mgap> last^15;[0m
    [22m[35mZ(2)^0[0m
    [22m[35mgap> PrimitiveUnityRoot( GF(8), 21 );[0m
    [22m[35mZ(2^6)^3 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-8 PrimitivePolynomialsNr[0m
  
  [1m[34m> PrimitivePolynomialsNr( [0m[22m[34mn, F[0m[1m[34m ) ___________________________________[0mfunction
  
  [22m[32mPrimitivePolynomialsNr[0m  returns  the  number of irreducible polynomials over
  F=GF(q)  of degree [22m[34mn[0m with (maximum) period q^n-1. (According to a theorem of
  S. Golomb, this is phi(p^n-1)/n.)
  
  See      also      the      [1mGAP[0m      function     [22m[32mRandomPrimitivePolynomial[0m,
  [1m[34mRandomPrimitivePolynomial[0m ([1m2.2-2[0m).
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> PrimitivePolynomialsNr(3,4);[0m
    [22m[35m12[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-9 IrreduciblePolynomialsNr[0m
  
  [1m[34m> IrreduciblePolynomialsNr( [0m[22m[34mn, F[0m[1m[34m ) _________________________________[0mfunction
  
  [22m[32mPrimitivePolynomialsNr[0m  returns  the  number of irreducible polynomials over
  F=GF(q) of degree [22m[34mn[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> IrreduciblePolynomialsNr(3,4);[0m
    [22m[35m20[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-10 MatrixRepresentationOfElement[0m
  
  [1m[34m> MatrixRepresentationOfElement( [0m[22m[34ma, F[0m[1m[34m ) ____________________________[0mfunction
  
  Here  [22m[34mF[0m  is  either a finite extension of the ``base field'' GF(p) or of the
  rationals Q}, and ain F. The command [22m[32mMatrixRepresentationOfElement[0m returns a
  matrix representation of [22m[34ma[0m over the base field.
  
  If  the  element  [22m[34ma[0m  is  defined  over  the  base  field then it returns the
  corresponding 1times 1 matrix.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> a:=Random(GF(4));[0m
    [22m[35m0*Z(2)[0m
    [22m[35mgap> M:=MatrixRepresentationOfElement(a,GF(4));; Display(M);[0m
    [22m[35m .[0m
    [22m[35mgap> a:=Random(GF(4));[0m
    [22m[35mZ(2^2)[0m
    [22m[35mgap> M:=MatrixRepresentationOfElement(a,GF(4));; Display(M);[0m
    [22m[35m . 1[0m
    [22m[35m 1 1[0m
    [22m[35mgap>[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-11 ReciprocalPolynomial[0m
  
  [1m[34m> ReciprocalPolynomial( [0m[22m[34mP[0m[1m[34m ) ________________________________________[0mfunction
  
  [22m[32mReciprocalPolynomial[0m  returns  the  [22m[36mreciprocal[0m  of  polynomial  [22m[34mP[0m. This is a
  polynomial  with coefficients of [22m[34mP[0m in the reverse order. So if P=a_0 + a_1 X
  +  ...  + a_n X^n, the reciprocal polynomial is P'=a_n + a_n-1 X + ... + a_0
  X^n.
  
  This command can also be called using the syntax [22m[32mReciprocalPolynomial( P , n
  )[0m.  In this form, the number of coefficients of [22m[34mP[0m is assumed to be less than
  or  equal  to  n+1  (with zero coefficients added in the highest degrees, if
  necessary). Therefore, the reciprocal polynomial also has degree n+1.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> P := UnivariatePolynomial( GF(3), Z(3)^0 * [1,0,1,2] );[0m
    [22m[35mZ(3)^0+x_1^2-x_1^3[0m
    [22m[35mgap> RecP := ReciprocalPolynomial( P );[0m
    [22m[35m-Z(3)^0+x_1+x_1^3[0m
    [22m[35mgap> ReciprocalPolynomial( RecP ) = P;[0m
    [22m[35mtrue [0m
    [22m[35mgap> P := UnivariatePolynomial( GF(3), Z(3)^0 * [1,0,1,2] );[0m
    [22m[35mZ(3)^0+x_1^2-x_1^3[0m
    [22m[35mgap> ReciprocalPolynomial( P, 6 );[0m
    [22m[35m-x_1^3+x_1^4+x_1^6[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-12 CyclotomicCosets[0m
  
  [1m[34m> CyclotomicCosets( [0m[22m[34mq, n[0m[1m[34m ) _________________________________________[0mfunction
  
  [22m[32mCyclotomicCosets[0m  returns  the cyclotomic cosets of q mod n. [22m[34mq[0m and [22m[34mn[0m must be
  relatively  prime.  Each  of  the elements of the returned list is a list of
  integers  that belong to one cyclotomic coset. A q-cyclotomic coset of s mod
  n  is  a  set  of  the  form  s,sq,sq^2,...,sq^r-1,  where r is the smallest
  positive  integer  such  that  sq^r-s is 0 mod n. In other words, each coset
  contains  all  multiplications  of  the coset representative by q mod n. The
  coset  representative  is  the  smallest  integer that isn't in the previous
  cosets.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> CyclotomicCosets( 2, 15 );[0m
    [22m[35m[ [ 0 ], [ 1, 2, 4, 8 ], [ 3, 6, 12, 9 ], [ 5, 10 ],[0m
    [22m[35m  [ 7, 14, 13, 11 ] ][0m
    [22m[35mgap> CyclotomicCosets( 7, 6 );[0m
    [22m[35m[ [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ] ] [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-13 WeightHistogram[0m
  
  [1m[34m> WeightHistogram( [0m[22m[34mC[, h][0m[1m[34m ) ________________________________________[0mfunction
  
  The  function  [22m[32mWeightHistogram[0m  plots  a histogram of weights in code [22m[34mC[0m. The
  maximum  length  of a column is [22m[34mh[0m. Default value for [22m[34mh[0m is 1/3 of the size of
  the  screen.  The  number  that  appears  at the top of the histogram is the
  maximum value of the list of weights.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> H := HammingCode(2, GF(5));[0m
    [22m[35ma linear [6,4,3]1 Hamming (2,5) code over GF(5)[0m
    [22m[35mgap> WeightDistribution(H);[0m
    [22m[35m[ 1, 0, 0, 80, 120, 264, 160 ][0m
    [22m[35mgap> WeightHistogram(H);[0m
    [22m[35m264----------------[0m
    [22m[35m               *[0m
    [22m[35m               *[0m
    [22m[35m               *[0m
    [22m[35m               *[0m
    [22m[35m               *  *[0m
    [22m[35m            *  *  *[0m
    [22m[35m         *  *  *  *[0m
    [22m[35m         *  *  *  *[0m
    [22m[35m+--------+--+--+--+--[0m
    [22m[35m0  1  2  3  4  5  6 [0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-14 MultiplicityInList[0m
  
  [1m[34m> MultiplicityInList( [0m[22m[34mL, a[0m[1m[34m ) _______________________________________[0mfunction
  
  This  is a very simple list command which returns how many times a occurs in
  L.  It returns 0 if a is not in L. (The [1mGAP[0m command [22m[32mCollected[0m does not quite
  handle this ``extreme" case.)
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> L:=[1,2,3,4,3,2,1,5,4,3,2,1];;[0m
    [22m[35mgap> MultiplicityInList(L,1);[0m
    [22m[35m3[0m
    [22m[35mgap> MultiplicityInList(L,6);[0m
    [22m[35m0[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-15 MostCommonInList[0m
  
  [1m[34m> MostCommonInList( [0m[22m[34mL[0m[1m[34m ) ____________________________________________[0mfunction
  
  Input: a list L
  
  Output: an a in L which occurs at least as much as any other in L
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> L:=[1,2,3,4,3,2,1,5,4,3,2,1];;[0m
    [22m[35mgap> MostCommonInList(L);[0m
    [22m[35m1[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-16 RotateList[0m
  
  [1m[34m> RotateList( [0m[22m[34mL[0m[1m[34m ) __________________________________________________[0mfunction
  
  Input: a list L
  
  Output: a list L' which is the cyclic rotation of L (to the right)
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> L:=[1,2,3,4];;[0m
    [22m[35mgap> RotateList(L);[0m
    [22m[35m[2,3,4,1][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.5-17 CirculantMatrix[0m
  
  [1m[34m> CirculantMatrix( [0m[22m[34mk, L[0m[1m[34m ) __________________________________________[0mfunction
  
  Input: integer k, a list L of length n
  
  Output: kxn matrix whose rows are cyclic rotations of the list L
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> k:=3; L:=[1,2,3,4];;[0m
    [22m[35mgap> M:=CirculantMatrix(k,L);;[0m
    [22m[35mgap> Display(M);[0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m7.6 Miscellaneous polynomial functions[0m
  
  In  this  section  we describe several multivariate polynomial [1mGAP[0m functions
  [1mGUAVA[0m uses for constructing codes or performing calculations with codes.
  
  [1m[4m[31m7.6-1 MatrixTransformationOnMultivariatePolynomial [0m
  
  [1m[34m> MatrixTransformationOnMultivariatePolynomial ( [0m[22m[34mA, f, R[0m[1m[34m ) _________[0mfunction
  
  [22m[34mA[0m is an ntimes n matrix with entries in a field F, [22m[34mR[0m is a polynomial ring of
  n  variables,  say  F[x_1,...,x_n],  and [22m[34mf[0m is a polynomial in [22m[34mR[0m. Returns the
  composition fcirc A.
  
  [1m[4m[31m7.6-2 DegreeMultivariatePolynomial[0m
  
  [1m[34m> DegreeMultivariatePolynomial( [0m[22m[34mf, R[0m[1m[34m ) _____________________________[0mfunction
  
  This  command  takes  two  arguments,  [22m[34mf[0m, a multivariate polynomial, and [22m[34mR[0m a
  polynomial  ring  over a field F containing [22m[34mf[0m, say R=F[x_1,x_2,...,x_n]. The
  output is simply the maximum degrees of all the monomials occurring in [22m[34mf[0m.
  
  This command can be used to compute the degree of an affine plane curve.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);;[0m
    [22m[35mgap> R2:=PolynomialRing(F,2);[0m
    [22m[35mPolynomialRing(..., [ x_1, x_2 ])[0m
    [22m[35mgap> vars:=IndeterminatesOfPolynomialRing(R2);;[0m
    [22m[35mgap> x:=vars[1];; y:=vars[2];;[0m
    [22m[35mgap> poly:=y^2-x*(x^2-1);;[0m
    [22m[35mgap> DegreeMultivariatePolynomial(poly,R2);[0m
    [22m[35m3[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.6-3 DegreesMultivariatePolynomial[0m
  
  [1m[34m> DegreesMultivariatePolynomial( [0m[22m[34mf, R[0m[1m[34m ) ____________________________[0mfunction
  
  Returns  a list of information about the multivariate polynomial [22m[34mf[0m. Nice for
  other programs but mostly unreadable by [1mGAP[0m users.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);;[0m
    [22m[35mgap> R2:=PolynomialRing(F,2);[0m
    [22m[35mPolynomialRing(..., [ x_1, x_2 ])[0m
    [22m[35mgap> vars:=IndeterminatesOfPolynomialRing(R2);;[0m
    [22m[35mgap> x:=vars[1];; y:=vars[2];;[0m
    [22m[35mgap> poly:=y^2-x*(x^2-1);;[0m
    [22m[35mgap> DegreesMultivariatePolynomial(poly,R2);[0m
    [22m[35m[ [ [ x_1, x_1, 1 ], [ x_1, x_2, 0 ] ], [ [ x_2^2, x_1, 0 ], [ x_2^2, x_2, 2 ] ],[0m
    [22m[35m  [ [ x_1^3, x_1, 3 ], [ x_1^3, x_2, 0 ] ] ][0m
    [22m[35mgap>[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.6-4 CoefficientMultivariatePolynomial[0m
  
  [1m[34m> CoefficientMultivariatePolynomial( [0m[22m[34mf, var, power, R[0m[1m[34m ) ____________[0mfunction
  
  The   command  [22m[32mCoefficientMultivariatePolynomial[0m  takes  four  arguments:  a
  multivariant  polynomial  [22m[34mf[0m,  a  variable  name [22m[34mvar[0m, an integer [22m[34mpower[0m, and a
  polynomial  ring  [22m[34mR[0m  containing  [22m[34mf[0m.  For  example,  if  [22m[34mf[0m  is a multivariate
  polynomial  in  R  = F[x_1,x_2,...,x_n] then [22m[34mvar[0m must be one of the x_i. The
  output is the coefficient of x_i^power in [22m[34mf[0m.
  
  (Not sure if F needs to be a field in fact ...)
  
  Related to the [1mGAP[0m command [22m[32mPolynomialCoefficientsPolynomial[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);;[0m
    [22m[35mgap> R2:=PolynomialRing(F,2);[0m
    [22m[35mPolynomialRing(..., [ x_1, x_2 ])[0m
    [22m[35mgap> vars:=IndeterminatesOfPolynomialRing(R2);;[0m
    [22m[35mgap> x:=vars[1];; y:=vars[2];;[0m
    [22m[35mgap> poly:=y^2-x*(x^2-1);;[0m
    [22m[35mgap> PolynomialCoefficientsOfPolynomial(poly,x);[0m
    [22m[35m[ x_2^2, Z(11)^0, 0*Z(11), -Z(11)^0 ][0m
    [22m[35mgap> PolynomialCoefficientsOfPolynomial(poly,y);[0m
    [22m[35m[ -x_1^3+x_1, 0*Z(11), Z(11)^0 ][0m
    [22m[35mgap> CoefficientMultivariatePolynomial(poly,y,0,R2);[0m
    [22m[35m-x_1^3+x_1[0m
    [22m[35mgap> CoefficientMultivariatePolynomial(poly,y,1,R2);[0m
    [22m[35m0*Z(11)[0m
    [22m[35mgap> CoefficientMultivariatePolynomial(poly,y,2,R2);[0m
    [22m[35mZ(11)^0[0m
    [22m[35mgap> CoefficientMultivariatePolynomial(poly,x,0,R2);[0m
    [22m[35mx_2^2[0m
    [22m[35mgap> CoefficientMultivariatePolynomial(poly,x,1,R2);[0m
    [22m[35mZ(11)^0[0m
    [22m[35mgap> CoefficientMultivariatePolynomial(poly,x,2,R2);[0m
    [22m[35m0*Z(11)[0m
    [22m[35mgap> CoefficientMultivariatePolynomial(poly,x,3,R2);[0m
    [22m[35m-Z(11)^0[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.6-5 SolveLinearSystem[0m
  
  [1m[34m> SolveLinearSystem( [0m[22m[34mL, vars[0m[1m[34m ) _____________________________________[0mfunction
  
  Input: [22m[34mL[0m is a list of linear forms in the variables [22m[34mvars[0m.
  
  Output: the solution of the system, if its unique.
  
  The  procedure  is  straightforward:  Find the associated matrix A, find the
  "constant vector" b, and solve A*v=b. No error checking is performed.
  
  Related to the [1mGAP[0m command [22m[32mSolutionMat( A, b )[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);;[0m
    [22m[35mgap> R2:=PolynomialRing(F,2);[0m
    [22m[35mPolynomialRing(..., [ x_1, x_2 ])[0m
    [22m[35mgap> vars:=IndeterminatesOfPolynomialRing(R2);;[0m
    [22m[35mgap> x:=vars[1];; y:=vars[2];;[0m
    [22m[35mgap> f:=3*y-3*x+1;; g:=-5*y+2*x-7;;[0m
    [22m[35mgap> soln:=SolveLinearSystem([f,g],[x,y]);[0m
    [22m[35m[ Z(11)^3, Z(11)^2 ][0m
    [22m[35mgap> Value(f,[x,y],soln); # checking okay[0m
    [22m[35m0*Z(11)[0m
    [22m[35mgap> Value(g,[x,y],col); # checking okay[0m
    [22m[35m0*Z(11)[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.6-6 GuavaVersion[0m
  
  [1m[34m> GuavaVersion( [0m[22m[34m[0m[1m[34m ) _________________________________________________[0mfunction
  
  Returns the current version of Guava. Same as [22m[32mguava_version()[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> GuavaVersion();[0m
    [22m[35m"2.5"[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.6-7 CoefficientToPolynomial[0m
  
  [1m[34m> CoefficientToPolynomial( [0m[22m[34mx, b, F[0m[1m[34m ) _______________________________[0mfunction
  
  Returns  the  Zech  log  of  x  to  base b, ie the i such that $x+1=b^i$, so
  $y+z=y(1+z/y)=b^k$,   where   k=Log(y,b)+ZechLog(z/y,b)  and  b  must  be  a
  primitive element of F.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);; l := One(F);;[0m
    [22m[35mgap> ZechLog(2*l,8*l,F);[0m
    [22m[35m-24[0m
    [22m[35mgap> 8*l+l;(2*l)^(-24);[0m
    [22m[35mZ(11)^6[0m
    [22m[35mZ(11)^6[0m
    [22m[35m[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.6-8 CoefficientToPolynomial[0m
  
  [1m[34m> CoefficientToPolynomial( [0m[22m[34mcoeffs, R[0m[1m[34m ) _____________________________[0mfunction
  
  The  function  [22m[32mCoefficientToPolynomial[0m  returns  the  degree  d-1 polynomial
  c_0+c_1x+...+c_d-1x^d-1,  where  [22m[34mcoeffs[0m  is  a  list of elements of a field,
  coeffs= c_0,...,c_d-1, and [22m[34mR[0m is a univariate polynomial ring.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);[0m
    [22m[35mGF(11)[0m
    [22m[35mgap> R1:=PolynomialRing(F,["a"]);;[0m
    [22m[35mgap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;[0m
    [22m[35mgap> coeffs:=Z(11)^0*[1,2,3,4];[0m
    [22m[35m[ Z(11)^0, Z(11), Z(11)^8, Z(11)^2 ][0m
    [22m[35mgap> CoefficientToPolynomial(coeffs,R1);[0m
    [22m[35mZ(11)^2*a^3+Z(11)^8*a^2+Z(11)*a+Z(11)^0[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.6-9 DegreesMonomialTerm[0m
  
  [1m[34m> DegreesMonomialTerm( [0m[22m[34mm, R[0m[1m[34m ) ______________________________________[0mfunction
  
  The  function  [22m[32mDegreesMonomialTerm[0m returns the list of degrees to which each
  variable  in  the  multivariate  polynomial ring [22m[34mR[0m occurs in the monomial [22m[34mm[0m,
  where [22m[34mcoeffs[0m is a list of elements of a field.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(11);[0m
    [22m[35mGF(11)[0m
    [22m[35mgap> R1:=PolynomialRing(F,["a"]);;[0m
    [22m[35mgap> var1:=IndeterminatesOfPolynomialRing(R1);; a:=var1[1];;[0m
    [22m[35mgap> b:=X(F,"b",var1);[0m
    [22m[35mb[0m
    [22m[35mgap> var2:=Concatenation(var1,[b]);[0m
    [22m[35m[ a, b ][0m
    [22m[35mgap> R2:=PolynomialRing(F,var2);[0m
    [22m[35mPolynomialRing(..., [ a, b ])[0m
    [22m[35mgap> c:=X(F,"c",var2);[0m
    [22m[35mc[0m
    [22m[35mgap> var3:=Concatenation(var2,[c]);[0m
    [22m[35m[ a, b, c ][0m
    [22m[35mgap> R3:=PolynomialRing(F,var3);[0m
    [22m[35mPolynomialRing(..., [ a, b, c ])[0m
    [22m[35mgap> m:=b^3*c^7;[0m
    [22m[35mb^3*c^7[0m
    [22m[35mgap> DegreesMonomialTerm(m,R3);[0m
    [22m[35m[ 0, 3, 7 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m7.6-10 DivisorsMultivariatePolynomial[0m
  
  [1m[34m> DivisorsMultivariatePolynomial( [0m[22m[34mf, R[0m[1m[34m ) ___________________________[0mfunction
  
  The  function  [22m[32mDivisorsMultivariatePolynomial[0m returns the list of polynomial
  divisors  of  [22m[34mf[0m in the multivariate polynomial ring [22m[34mR[0m with coefficients in a
  field.  This  program  uses a simple but slow algorithm (see Joachim von zur
  Gathen,  J\"urgen  Gerhard, [GJ03], exercise 16.10) which first converts the
  multivariate  polynomial  [22m[34mf[0m to an associated univariate polynomial f^*, then
  [22m[32mFactors[0m  f^*,  and  finally  converts these univariate factors back into the
  multivariate  polynomial  factors  of [22m[34mf[0m. Since [22m[32mFactors[0m is non-deterministic,
  [22m[32mDivisorsMultivariatePolynomial[0m is non-deterministic as well.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> R2:=PolynomialRing(GF(3),["x1","x2"]);[0m
    [22m[35mPolynomialRing(..., [ x1, x2 ])[0m
    [22m[35mgap> vars:=IndeterminatesOfPolynomialRing(R2);[0m
    [22m[35m[ x1, x2 ][0m
    [22m[35mgap> x2:=vars[2];[0m
    [22m[35mx2[0m
    [22m[35mgap> x1:=vars[1];[0m
    [22m[35mx1[0m
    [22m[35mgap> f:=x1^3+x2^3;;[0m
    [22m[35mgap> DivisorsMultivariatePolynomial(f,R2);[0m
    [22m[35m[ x1+x2, x1+x2, x1+x2 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
