  
  [1m[4m[31m4. Coding theory functions in the GAP kernel[0m
  
  This  chapter  will  recall  from  the  GAP  manual  the  GAP  coding theory
  functions,  some of which are partially written in C. The main functions are
  [22m[32mAClosestVectorCombinationsMatFFEVecFFE[0m,
  [22m[32mAClosestVectorCombinationsMatFFEVecFFECoords[0m,            [22m[32mCosetLeadersMatFFE[0m,
  [22m[32mDistancesDistributionMatFFEVecFFE[0m,       [22m[32mDistancesDistributionVecFFEsVecFFE[0m,
  [22m[32mDistanceVecFFE[0m, and [22m[32mWeightVecFFE[0m. These are declared in the GAP library file
  'listcoef.gd' and implemented in 'listcoef.gi'.
  
  
  [1m[4m[31m4.1 Distance functions[0m
  
  [1m[4m[31m4.1-1 AClosestVectorCombinationsMatFFEVecFFE[0m
  
  [1m[34m> AClosestVectorCombinationsMatFFEVecFFE( [0m[22m[34mmat, F, vec, r, st[0m[1m[34m ) _____[0mfunction
  
  This  command  runs  through the [22m[34mF[0m-linear combinations of the vectors in the
  rows of the matrix [22m[34mmat[0m that can be written as linear combinations of exactly
  [22m[34mr[0m  rows  (that  is without using zero as a coefficient) and returns a vector
  from  these that is closest to the vector [22m[34mvec[0m. The length of the rows of [22m[34mmat[0m
  and  the  length  of  [22m[34mvec[0m must be equal, and all elements must lie in [22m[34mF[0m. The
  rows  of  [22m[34mmat[0m must be linearly independent. If it finds a vector of distance
  at  most  [22m[34mst[0m, which must be a nonnegative integer, then it stops immediately
  and returns this vector.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(3);;[0m
    [22m[35mgap> x:= Indeterminate( F );; pol:= x^2+1;[0m
    [22m[35mx_1^2+Z(3)^0[0m
    [22m[35mgap> C := GeneratorPolCode(pol,8,F);[0m
    [22m[35ma cyclic [8,6,1..2]1..2 code defined by generator polynomial over GF(3)[0m
    [22m[35mgap> v:=Codeword("12101111");[0m
    [22m[35m[ 1 2 1 0 1 1 1 1 ][0m
    [22m[35mgap> v:=VectorCodeword(v);[0m
    [22m[35m[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ][0m
    [22m[35mgap> G:=GeneratorMat(C);[0m
    [22m[35m[ [ Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],[0m
    [22m[35m  [ 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],[0m
    [22m[35m  [ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],[0m
    [22m[35m  [ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],[0m
    [22m[35m  [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3) ],[0m
    [22m[35m  [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ] ][0m
    [22m[35mgap> AClosestVectorCombinationsMatFFEVecFFE(G,F,v,1,1);[0m
    [22m[35m[ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.1-2 AClosestVectorComb..MatFFEVecFFECoords[0m
  
  [1m[34m> AClosestVectorComb..MatFFEVecFFECoords( [0m[22m[34mmat, F, vec, r, st[0m[1m[34m ) _____[0mfunction
  
  [22m[32mAClosestVectorCombinationsMatFFEVecFFECoords[0m  returns  a  two  element  list
  containing      (a)      the      same      closest     vector     as     in
  [22m[32mAClosestVectorCombinationsMatFFEVecFFE[0m,  and  (b)  a vector [22m[34mv[0m with exactly [22m[34mr[0m
  non-zero entries, such that v*mat is the closest vector.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> F:=GF(3);;[0m
    [22m[35mgap> x:= Indeterminate( F );; pol:= x^2+1;[0m
    [22m[35mx_1^2+Z(3)^0[0m
    [22m[35mgap> C := GeneratorPolCode(pol,8,F);[0m
    [22m[35ma cyclic [8,6,1..2]1..2 code defined by generator polynomial over GF(3)[0m
    [22m[35mgap> v:=Codeword("12101111"); v:=VectorCodeword(v);;[0m
    [22m[35m[ 1 2 1 0 1 1 1 1 ][0m
    [22m[35mgap> G:=GeneratorMat(C);;[0m
    [22m[35mgap> AClosestVectorCombinationsMatFFEVecFFECoords(G,F,v,1,1);[0m
    [22m[35m[ [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ],[0m
    [22m[35m  [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0 ] ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.1-3 DistancesDistributionMatFFEVecFFE[0m
  
  [1m[34m> DistancesDistributionMatFFEVecFFE( [0m[22m[34mvecs, vec[0m[1m[34m ) ___________________[0mfunction
  
  [22m[32mDistancesDistributionMatFFEVecFFE[0m  returns the distances distribution of the
  vector  [22m[34mvec[0m  to the vectors in the list [22m[34mvecs[0m. All vectors must have the same
  length,  and  all  elements  must  lie  in  a  common  field.  The distances
  distribution  is  a list d of length Length(vec)+1, such that the value d[i]
  is the number of vectors in vecs that have distance i+1 to [22m[34mvec[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> v:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;[0m
    [22m[35mgap> vecs:=[ [ Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ] ];;[0m
    [22m[35mgap> DistancesDistributionMatFFEVecFFE(vecs,GF(3),v);[0m
    [22m[35m[ 0, 4, 6, 60, 109, 216, 192, 112, 30 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.1-4 DistancesDistributionVecFFEsVecFFE[0m
  
  [1m[34m> DistancesDistributionVecFFEsVecFFE( [0m[22m[34mvecs, vec[0m[1m[34m ) __________________[0mfunction
  
  [22m[32mDistancesDistributionVecFFEsVecFFE[0m returns the distances distribution of the
  vector  [22m[34mvec[0m  to the vectors in the list [22m[34mvecs[0m. All vectors must have the same
  length,  and  all  elements  must  lie  in  a  common  field.  The distances
  distribution  is  a list d of length Length(vec)+1, such that the value d[i]
  is the number of vectors in [22m[34mvecs[0m that have distance i+1 to [22m[34mvec[0m.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> v:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;[0m
    [22m[35mgap> vecs:=[ [ Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3), 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3), 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0, 0*Z(3) ],[0m
    [22m[35m>   [ 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), 0*Z(3), Z(3)^0, 0*Z(3), Z(3)^0 ] ];;[0m
    [22m[35mgap> DistancesDistributionVecFFEsVecFFE(vecs,v);[0m
    [22m[35m[ 0, 0, 0, 0, 0, 4, 0, 1, 1 ][0m
  [22m[35m------------------------------------------------------------------[0m
  
  
  [1m[4m[31m4.2 Other functions[0m
  
  [1m[4m[31m4.2-1 WeightVecFFE[0m
  
  [1m[34m> WeightVecFFE( [0m[22m[34mvec[0m[1m[34m ) ______________________________________________[0mfunction
  
  [22m[32mWeightVecFFE[0m  returns  the  weight  of the finite field vector [22m[34mvec[0m, i.e. the
  number of nonzero entries.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> v:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;[0m
    [22m[35mgap> WeightVecFFE(v);[0m
    [22m[35m7[0m
  [22m[35m------------------------------------------------------------------[0m
  
  [1m[4m[31m4.2-2 DistanceVecFFE[0m
  
  [1m[34m> DistanceVecFFE( [0m[22m[34mvec1, vec2[0m[1m[34m ) _____________________________________[0mfunction
  
  The [22m[36mHamming metric[0m on GF(q)^n is the function
  
  \[
       dist((v_1,...,v_n),(w_1,...,w_n)) =|\{i\in [1..n]\ |\ v_i\not=
       w_i\}|.
  \]
  
  This  is  also  called  the  (Hamming)  distance between v=(v_1,...,v_n) and
  w=(w_1,...,w_n). [22m[32mDistanceVecFFE[0m returns the distance between the two vectors
  [22m[34mvec1[0m  and  [22m[34mvec2[0m, which must have the same length and whose elements must lie
  in  a common field. The distance is the number of places where [22m[34mvec1[0m and [22m[34mvec2[0m
  differ.
  
  [22m[35m---------------------------  Example  ----------------------------[0m
    [22m[35mgap> v1:=[ Z(3)^0, Z(3), Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;[0m
    [22m[35mgap> v2:=[ Z(3), Z(3)^0, Z(3)^0, 0*Z(3), Z(3)^0, Z(3)^0, Z(3)^0, Z(3)^0 ];;[0m
    [22m[35mgap> DistanceVecFFE(v1,v2);[0m
    [22m[35m2[0m
  [22m[35m------------------------------------------------------------------[0m
  
