  
  [1X5 Residue-Class-Wise Affine Mappings, Groups and Monoids over ℤ^2[0X
  
  This  chapter  describes  how  to  compute  with  residue-class-wise  affine
  mappings of ℤ^2 and with groups and monoids formed by them.
  
  The rings on which we have defined residue-class-wise affine mappings so far
  have  all  been  principal  ideal  domains, and it has been crucial that all
  nontrivial  principal ideals had finite index. However, the rings ℤ^d, d > 1
  are  not  principal  ideal domains. Furthermore, their principal ideals have
  infinite index. Therefore as moduli of residue-class-wise affine mappings we
  can  only  use  lattices of full rank, for these are precisely the ideals of
  ℤ^d  of  finite  index.  However,  on  the  other  hand  we can also be more
  permissive  and look at ℤ^d not only as a ring, but also as a free ℤ-module.
  The  consequence  of  this is that then an affine mapping of ℤ^d is not just
  given by v -> (av+b)/c for some a, b, c in ℤ^d, but rather by v -> (vA+b)/c,
  where A in ℤ^d x d.
  
  
  [1X5.1 The definition of residue-class-wise affine mappings of ℤ^d[0X
  
  Let  d  in  ℕ.  We call a mapping f: ℤ^d -> ℤ^d [13Xresidue-class-wise affine[0m if
  there  is  a  lattice L = ℤ^d M where M in ℤ^d x d is a matrix of full rank,
  such  that  the  restrictions of f to the residue classes r + L in ℤ^d/L are
  all affine. This means that for any residue class r + L in ℤ^d/L, there is a
  matrix  A_r+L in ℤ^d x d, a vector b_r+L in ℤ^d and a positive integer c_r+L
  such  that the restriction of f to r + L is given by f|_r + L: r + L -> ℤ^d,
  v  -> (v * A_r+L + b_r+L)/c_r+L. For reasons of uniqueness, we assume that L
  is  chosen  maximal  with  respect to inclusion, and that no prime factor of
  c_r+L divides all coefficients of A_r+L and b_r+L.
  
  We  call  the  lattice L the [13Xmodulus[0m of f, written Mod(f). Further we define
  the  [13Xprime set[0m of f as the set of all primes which divide the determinant of
  at least one of the coefficients A_r+L or which divide the determinant of M,
  and  we  call the mapping f [13Xclass-wise translating[0m if all coefficients A_r+L
  are identity matrices and all coefficients c_r+L are equal to 1.
  
  For  the  sake  of simplicity, we identify a lattice with the Hermite normal
  form of the matrix by whose rows it is spanned.
  
  
  [1X5.2 Entering residue-class-wise affine mappings of ℤ^2[0X
  
  Residue-class-wise  affine  mappings of ℤ^2 can be entered using the general
  constructor   [2XRcwaMapping[0m   ([14X2.2-5[0m)   or   the  more  specialized  functions
  [2XClassTransposition[0m  ([14X2.2-3[0m),  [2XClassRotation[0m  ([14X2.2-4[0m) and [2XClassShift[0m ([14X2.2-1[0m).
  The arguments differ only slightly.
  
  
  [1X5.2-1 RcwaMapping (the general constructor; methods for ℤ^2)[0X
  
  [2X> RcwaMapping( [0X[3XR, L, coeffs[0X[2X ) ________________________________________[0Xmethod
  [2X> RcwaMapping( [0X[3XP1, P2[0X[2X ) ______________________________________________[0Xmethod
  [2X> RcwaMapping( [0X[3Xcycles[0X[2X ) ______________________________________________[0Xmethod
  [2X> RcwaMapping( [0X[3Xf, g[0X[2X ) ________________________________________________[0Xmethod
  [6XReturns:[0X  An rcwa mapping of ℤ^2.
  
  The above methods return
  
  [8X(a)[0m
        the  rcwa  mapping  of  [10X[3XR[0m[10X = Integers^2[0m with modulus [3XL[0m and coefficients
        [3Xcoeffs[0m,
  
  [8X(b)[0m
        a  bijective  rcwa  mapping  which  induces  a  bijection  between the
        partitions  [3XP1[0m  and [3XP2[0m of ℤ^2 into residue classes and which is affine
        on the elements of [3XP1[0m,
  
  [8X(c)[0m
        a  bijective  rcwa mapping with "residue class cycles" given by a list
        [3Xcycles[0m  of  lists  of pairwise disjoint residue classes of ℤ^2 each of
        which it permutes cyclically, and
  
  [8X(d)[0m
        the rcwa mapping of ℤ^2 whose projections to the coordinates are given
        by [3Xf[0m and [3Xg[0m,
  
  respectively.
  
  The  modulus  of  an  rcwa  mapping  of ℤ^2 is a lattice of full rank. It is
  represented  by  a  matrix  [3XL[0m  in  Hermite  normal  form, whose rows are the
  spanning vectors.
  
  A  coefficient  list  for  an rcwa mapping of ℤ^2 with modulus [3XL[0m consists of
  |det([3XL[0m)|  coefficient  triples  [10X[[0mA_r+ℤ^2[3XL[0m,  b_r+ℤ^2[3XL[0m, c_r+ℤ^2[3XL[0m[10X][0m. The entries
  A_r+ℤ^2[3XL[0m  are 2 x 2 integer matrices, the b_r+ℤ^2[3XL[0m are elements of ℤ^2, i.e.
  lists  of  two  integers, and the c_r+ℤ^2[3XL[0m are integers. The ordering of the
  coefficient  triples is determined by the ordering of the representatives of
  the    residue   classes   r+ℤ^2[3XL[0m   in   the   sorted   list   returned   by
  [10XAllResidues(Integers^2,[3XL[0m[10X)[0m.
  
  The  methods  for  the  operation  [10XRcwaMapping[0m  perform a number of argument
  checks, which can be skipped by using [10XRcwaMappingNC[0m instead.
  
  Last  but  not  least, regarding Method (d) it should be mentioned that only
  very special rcwa mappings of ℤ^2 have projections to coordinates.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> R := Integers^2;;[0X
    [4Xgap> twice := RcwaMapping(R,[[1,0],[0,1]],[0X
    [4X>                           [[[[2,0],[0,2]],[0,0],1]]);       # method (a)[0X
    [4XRcwa mapping of Z^2: [m,n] -> [2m,2n][0X
    [4Xgap> [4,5]^twice;[0X
    [4X[ 8, 10 ][0X
    [4Xgap> twice1 := RcwaMapping(R,[[1,0],[0,1]],[0X
    [4X>                            [[[[2,0],[0,1]],[0,0],1]]);      # method (a)[0X
    [4XRcwa mapping of Z^2: [m,n] -> [2m,n][0X
    [4Xgap> [4,5]^twice1;[0X
    [4X[ 8, 5 ][0X
    [4Xgap> Image(twice1);[0X
    [4X(0,0)+(2,0)Z+(0,1)Z[0X
    [4Xgap> hyperbolic := RcwaMapping(R,[[1,0],[0,2]],[0X
    [4X>                                [[[[4,0],[0,1]],[0, 0],2],[0X
    [4X>                                 [[[4,0],[0,1]],[2,-1],2]]); # method (a)[0X
    [4X<rcwa mapping of Z^2 with modulus (1,0)Z+(0,2)Z>[0X
    [4Xgap> IsBijective(hyperbolic);[0X
    [4Xtrue[0X
    [4Xgap> Display(hyperbolic);[0X
    [4X[0X
    [4XBijective rcwa mapping of Z^2 with modulus (1,0)Z+(0,2)Z[0X
    [4X[0X
    [4X   [m,n] mod (1,0)Z+(0,2)Z   |              Image of [m,n][0X
    [4X-----------------------------+-------------------------------------------[0X
    [4X [0,0]                       | [2m,n/2][0X
    [4X [0,1]                       | [2m+1,(n-1)/2][0X
    [4X[0X
    [4Xgap> Display(hyperbolic:varnames:="v");[0X
    [4X[0X
    [4XRcwa mapping of Z^2 with modulus (1,0)Z+(0,2)Z[0X
    [4X[0X
    [4X     v mod (1,0)Z+(0,2)Z     |                Image of v[0X
    [4X-----------------------------+-------------------------------------------[0X
    [4X [0,0]                       | v * [[4,0],[0,1]]/2[0X
    [4X [0,1]                       | (v * [[4,0],[0,1]] + [2,-1])/2[0X
    [4X[0X
    [4Xgap> Trajectory(hyperbolic,[0,10000],20);[0X
    [4X[ [ 0, 10000 ], [ 0, 5000 ], [ 0, 2500 ], [ 0, 1250 ], [ 0, 625 ], [0X
    [4X  [ 1, 312 ], [ 2, 156 ], [ 4, 78 ], [ 8, 39 ], [ 17, 19 ], [ 35, 9 ], [0X
    [4X  [ 71, 4 ], [ 142, 2 ], [ 284, 1 ], [ 569, 0 ], [ 1138, 0 ], [0X
    [4X  [ 2276, 0 ], [ 4552, 0 ], [ 9104, 0 ], [ 18208, 0 ] ][0X
    [4Xgap> P1 := AllResidueClassesModulo(R,[[2,1],[0,2]]);[0X
    [4X[ (0,0)+(2,1)Z+(0,2)Z, (0,1)+(2,1)Z+(0,2)Z, (1,0)+(2,1)Z+(0,2)Z,[0X
    [4X  (1,1)+(2,1)Z+(0,2)Z ][0X
    [4Xgap> P2 := AllResidueClassesModulo(R,[[1,0],[0,4]]);[0X
    [4X[ (0,0)+(1,0)Z+(0,4)Z, (0,1)+(1,0)Z+(0,4)Z, (0,2)+(1,0)Z+(0,4)Z,[0X
    [4X  (0,3)+(1,0)Z+(0,4)Z ][0X
    [4Xgap> g := RcwaMapping(P1,P2);                                 # method (b)[0X
    [4X<bijective rcwa mapping of Z^2 with modulus (2,1)Z+(0,2)Z>[0X
    [4Xgap> P1^g = P2;[0X
    [4Xtrue[0X
    [4Xgap> Display(g);[0X
    [4X[0X
    [4XBijective rcwa mapping of Z^2 with modulus (2,1)Z+(0,2)Z[0X
    [4X[0X
    [4X   [m,n] mod (2,1)Z+(0,2)Z   |              Image of [m,n][0X
    [4X-----------------------------+-------------------------------------------[0X
    [4X [0,0]                       | [m/2,-m+2n][0X
    [4X [0,1]                       | [m/2,-m+2n-1][0X
    [4X [1,0]                       | [(m-1)/2,-m+2n+3][0X
    [4X [1,1]                       | [(m-1)/2,-m+2n+2][0X
    [4X[0X
    [4Xgap> classes := List([[[0,0],[[2,1],[0,2]]],[[1,0],[[2,1],[0,4]]],[0X
    [4X>                     [[1,1],[[4,2],[0,4]]]],ResidueClass);[0X
    [4X[ (0,0)+(2,1)Z+(0,2)Z, (1,0)+(2,1)Z+(0,4)Z, (1,1)+(4,2)Z+(0,4)Z ][0X
    [4Xgap> g := RcwaMapping([classes]);                             # method (c)[0X
    [4X<bijective rcwa mapping of Z^2 with modulus (4,2)Z+(0,4)Z, of order 3>[0X
    [4Xgap> Permutation(g,classes);[0X
    [4X(1,2,3)[0X
    [4Xgap> Support(g);[0X
    [4X(0,0)+(2,1)Z+(0,2)Z U (1,0)+(2,1)Z+(0,4)Z U (1,1)+(4,2)Z+(0,4)Z[0X
    [4Xgap> Display(g);[0X
    [4X[0X
    [4XBijective rcwa mapping of Z^2 with modulus (4,2)Z+(0,4)Z, of order 3[0X
    [4X[0X
    [4X   [m,n] mod (4,2)Z+(0,4)Z   |              Image of [m,n][0X
    [4X-----------------------------+-------------------------------------------[0X
    [4X [0,0] [0,2] [2,1] [2,3]     | [m+1,(-m+4n)/2][0X
    [4X [0,1] [0,3] [1,2] [1,3]     |[0X
    [4X [2,0] [2,2] [3,0] [3,2]     |[0X
    [4X [3,3]                       | [m,n][0X
    [4X [1,0] [3,1]                 | [2m-1,(m+2n+1)/2][0X
    [4X [1,1]                       | [(m-1)/2,(n-1)/2][0X
    [4X[0X
    [4Xgap> g := RcwaMapping(ClassTransposition(0,2,1,2),[0X
    [4X>                     ClassReflection(0,2));                  # method (d)[0X
    [4X<rcwa mapping of Z^2 with modulus (2,0)Z+(0,2)Z>[0X
    [4Xgap> Display(g);[0X
    [4X[0X
    [4XRcwa mapping of Z^2 with modulus (2,0)Z+(0,2)Z[0X
    [4X[0X
    [4X   [m,n] mod (2,0)Z+(0,2)Z   |              Image of [m,n][0X
    [4X-----------------------------+-------------------------------------------[0X
    [4X [0,0]                       | [m+1,-n][0X
    [4X [0,1]                       | [m+1,n][0X
    [4X [1,0]                       | [m-1,-n][0X
    [4X [1,1]                       | [m-1,n][0X
    [4X[0X
    [4Xgap> g^2;[0X
    [4XIdentityMapping( ( Integers^2 ) )[0X
    [4Xgap> List(ProjectionsToCoordinates(g),Factorization);[0X
    [4X[ [ ClassTransposition(0,2,1,2) ], [ ClassReflection(0,2) ] ][0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X5.2-2 ClassTransposition (for ℤ^2)[0X
  
  [2X> ClassTransposition( [0X[3Xr1, L1, r2, L2[0X[2X ) _____________________________[0Xfunction
  [2X> ClassTransposition( [0X[3Xcl1, cl2[0X[2X ) ___________________________________[0Xfunction
  [6XReturns:[0X  The class transposition tau_r_1+ℤ^2L_1,r_2+ℤ^2L_2.
  
  Let  d  in ℕ, and let L_1, L_2 in ℤ^d x d be matrices of full rank which are
  in  Hermite  normal  form.  Further  let  r_1 + ℤ^d L_1 and r_2 + ℤ^d L_2 be
  disjoint  residue  classes,  and assume that the representatives r_1 and r_2
  are  reduced  modulo ℤ^d  L_1  and ℤ^d L_2, respectively. Then we define the
  [13Xclass  transposition[0m  tau_r_1+ℤ^d  L_1,  r_2+ℤ^d  L_2  in  Sym(ℤ^d)  as  the
  involution which interchanges r_1 + k L_1 and r_2 + k L_2 for all k in ℤ^d.
  
  The  class  transposition  tau_r_1+ℤ^d  L_1,  r_2+ℤ^d  L_2  interchanges the
  residue  classes  r_1+ℤ^d  L_1  and r_2+ℤ^d L_2, and fixes the complement of
  their  union pointwise. The set of all class transpositions of ℤ^d generates
  the simple group CT(ℤ^d) (cf. [Koh08b]).
  
  In  the  four-argument  form, the arguments [3Xr1[0m, [3XL1[0m, [3Xr2[0m and [3XL2[0m stand for r_1,
  L_1,  r_2 and L_2, respectively. In the two-argument form, the arguments [3Xcl1[0m
  and [3Xcl2[0m   stand  for  the  residue  classes  r_1+ℤ^2  L_1  and r_2+ℤ^2  L_2,
  respectively. Enclosing the argument list in list brackets is permitted. The
  residue  classes  r_1+ℤ^2  L_1  and  r_2+ℤ^2  L_2 are stored as an attribute
  [10XTransposedClasses[0m.
  
  There  is  also  a method for [10XSplittedClassTransposition[0m available for class
  transpositions  of  ℤ^2.  This  method  takes  as  first  argument the class
  transposition, and as second argument a list of two integers. These integers
  are  the numbers of parts into which the class transposition is to be sliced
  in   each   dimension.   Note   that  the  product  of  the  returned  class
  transpositions  is  not  always  equal  to the class transposition passed as
  first argument. However this equality holds if the first entry of the second
  argument is 1.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> ct := ClassTransposition([0,0],[[2,1],[0,2]],[1,0],[[2,1],[0,4]]);[0X
    [4XClassTransposition((0,0)+(2,1)Z+(0,2)Z,(1,0)+(2,1)Z+(0,4)Z)[0X
    [4Xgap> Display(ct);[0X
    [4X[0X
    [4XBijective rcwa mapping of Z^2 with modulus (2,1)Z+(0,4)Z, of order 2[0X
    [4X[0X
    [4X   [m,n] mod (2,1)Z+(0,4)Z   |              Image of [m,n][0X
    [4X-----------------------------+-------------------------------------------[0X
    [4X [0,0] [0,2]                 | [m+1,(-m+4n)/2][0X
    [4X [0,1] [0,3] [1,1] [1,2]     |[0X
    [4X [1,3]                       | [m,n][0X
    [4X [1,0]                       | [m-1,(m+2n-1)/4][0X
    [4X[0X
    [4Xgap> TransposedClasses(ct);[0X
    [4X[ (1,0)+(2,0)Z+(0,4)Z, (0,0)+(2,1)Z+(0,2)Z ][0X
    [4Xgap> ct = ClassTransposition(last);[0X
    [4Xtrue[0X
    [4Xgap> SplittedClassTransposition(ct,[1,2]);[0X
    [4X[ ClassTransposition((1,0)+(2,0)Z+(0,8)Z,(0,0)+(2,1)Z+(0,4)Z), [0X
    [4X  ClassTransposition((1,4)+(2,0)Z+(0,8)Z,(0,2)+(2,1)Z+(0,4)Z) ][0X
    [4Xgap> Product(last) = ct;[0X
    [4Xtrue[0X
    [4Xgap> SplittedClassTransposition(ct,[2,1]);[0X
    [4X[ ClassTransposition((0,0)+(4,0)Z+(0,2)Z,(1,0)+(4,0)Z+(0,4)Z), [0X
    [4X  ClassTransposition((2,1)+(4,0)Z+(0,2)Z,(3,0)+(4,0)Z+(0,4)Z) ][0X
    [4Xgap> Product(last) = ct;[0X
    [4Xfalse[0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X5.2-3 ClassRotation (for ℤ^2)[0X
  
  [2X> ClassRotation( [0X[3Xr, L, u[0X[2X ) _________________________________________[0Xfunction
  [2X> ClassRotation( [0X[3Xcl, u[0X[2X ) ___________________________________________[0Xfunction
  [6XReturns:[0X  The class rotation rho_r(m),u.
  
  Let  d  in  ℕ.  Given  a residue class r+ℤ^dL and a matrix u in GL(d,ℤ), the
  [13Xclass rotation[0m rho_r+ℤ^dL,u is the rcwa mapping which maps v in r+ℤ^dL to vu
  +  r(1-u)  and which fixes ℤ^d \ r+ℤ^dL pointwise. In the two-argument form,
  the  argument [3Xcl[0m stands for the residue class r+ℤ^dL. Enclosing the argument
  list in list brackets is permitted. The argument [3Xu[0m is stored as an attribute
  [10XRotationFactor[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> interchange := ClassRotation([0,0],[[1,0],[0,1]],[[0,1],[1,0]]);[0X
    [4XClassRotation((Integers^2),[[0,1],[1,0]])[0X
    [4Xgap> Display(interchange);[0X
    [4XBijective rcwa mapping of Z^2: [m,n] -> [n,m][0X
    [4Xgap> classes := AllResidueClassesModulo(Integers^2,[[2,1],[0,3]]);[0X
    [4X[ (0,0)+(2,1)Z+(0,3)Z, (0,1)+(2,1)Z+(0,3)Z, (0,2)+(2,1)Z+(0,3)Z, [0X
    [4X  (1,0)+(2,1)Z+(0,3)Z, (1,1)+(2,1)Z+(0,3)Z, (1,2)+(2,1)Z+(0,3)Z ][0X
    [4Xgap> transvection := ClassRotation(classes[5],[[1,1],[0,1]]);[0X
    [4XClassRotation((1,1)+(2,1)Z+(0,3)Z,[[1,1],[0,1]])[0X
    [4Xgap> Display(transvection);[0X
    [4X[0X
    [4XTame bijective rcwa mapping of Z^2 with modulus (2,1)Z+(0,3)Z, of order infinity[0X
    [4X[0X
    [4X   [m,n] mod (2,1)Z+(0,3)Z   |              Image of [m,n][0X
    [4X-----------------------------+-------------------------------------------[0X
    [4X [0,0] [0,1] [0,2] [1,0]     |[0X
    [4X [1,2]                       | [m,n][0X
    [4X [1,1]                       | [m,(3m+2n-3)/2][0X
    [4X[0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X5.2-4 ClassShift (for ℤ^2)[0X
  
  [2X> ClassShift( [0X[3Xr, L, k[0X[2X ) ____________________________________________[0Xfunction
  [2X> ClassShift( [0X[3Xcl, k[0X[2X ) ______________________________________________[0Xfunction
  [6XReturns:[0X  The class shift nu_r+ℤ^dL,k.
  
  Let  d  in ℕ. Given a residue class r+ℤ^dL and an integer k in {1, dots, d},
  the  [13Xclass shift[0m nu_r+ℤ^dL,k is the rcwa mapping which maps v in r+ℤ^dL to v
  +  L_k  and which fixes ℤ^d \ r+ℤ^dL pointwise. Here L_k denotes the kth row
  of L.
  
  In   the   two-argument   form,  the  argument [3Xcl[0m  stands  for  the  residue
  class r+ℤ^dL. Enclosing the argument list in list brackets is permitted.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> shift1 := ClassShift([0,0],[[1,0],[0,1]],1);[0X
    [4XClassShift((Integers^2),1)[0X
    [4Xgap> Display(shift1);[0X
    [4XTame bijective rcwa mapping of Z^2: [m,n] -> [m+1,n][0X
    [4Xgap> s := ClassShift(ResidueClass([1,1],[[2,1],[0,2]]),2);[0X
    [4XClassShift((1,1)+(2,1)Z+(0,2)Z,2)[0X
    [4Xgap> Display(s);[0X
    [4X[0X
    [4XTame bijective rcwa mapping of Z^2 with modulus (2,1)Z+(0,2)Z, of order infinity[0X
    [4X[0X
    [4X   [m,n] mod (2,1)Z+(0,2)Z   |              Image of [m,n][0X
    [4X-----------------------------+-------------------------------------------[0X
    [4X [0,0] [0,1] [1,0]           | [m,n][0X
    [4X [1,1]                       | [m,n+2][0X
    [4X[0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  As  for  other rings, class transpositions, class rotations and class shifts
  of ℤ^2    have    the    distinguishing   properties   [10XIsClassTransposition[0m,
  [10XIsClassRotation[0m and [10XIsClassShift[0m.
  
  
  [1X5.3 Methods for residue-class-wise affine mappings of ℤ^2[0X
  
  There  are  methods  available  for  rcwa  mappings of ℤ^2 for the following
  general operations:
  
  [8X Output [0m
        [10XView[0m, [10XDisplay[0m, [10XPrint[0m, [10XString[0m, [10XRcwaMappingToLaTeX[0m, [10XLaTeXAndXDVI[0m.
  
  [8X Access to components [0m
        [10XModulus[0m, [10XCoefficients[0m.
  
  [8X Attributes [0m
        [10XSupport[0m  /  [10XMovedPoints[0m,  [10XOrder[0m,  [10XMultiplier[0m,  [10XDivisor[0m, [10XPrimeSet[0m, [10XOne[0m,
        [10XZero[0m.
  
  [8X Properties [0m
        [10XIsInjective[0m,    [10XIsSurjective[0m,    [10XIsBijective[0m,    [10XIsTame[0m,   [10XIsIntegral[0m,
        [10XIsBalanced[0m, [10XIsClassWiseOrderPreserving[0m, [10XIsOne[0m, [10XIsZero[0m.
  
  [8X Action on ℤ^d [0m
        [10X^[0m  (for  points  /  finite  sets  / residue class unions), [10XTrajectory[0m,
        [10XShortCycles[0m,            [10XMultpk[0m,            [10XClassWiseOrderPreservingOn[0m,
        [10XClassWiseOrderReversingOn[0m, [10XClassWiseConstantOn[0m.
  
  [8X Arithmetical operations [0m
        [10X=[0m,  [10X*[0m  (multiplication  /  composition  and  multiplication by a 2 x 2
        matrix  or an integer), [10X^[0m (exponentiation and conjugation), [10XInverse[0m, [10X+[0m
        (addition of a constant).
  
  The  above  operations  are documented either in the [5XGAP[0m Reference Manual or
  earlier  in  this mamual. The operations which are special for rcwa mappings
  of ℤ^2 are described in the sequel.
  
  [1X5.3-1 ProjectionsToCoordinates[0m
  
  [2X> ProjectionsToCoordinates( [0X[3Xf[0X[2X ) ___________________________________[0Xattribute
  [6XReturns:[0X  The projections of the rcwa mapping [3Xf[0m of ℤ^2 to the coordinates if
            such projections exist, and [10Xfail[0m otherwise.
  
  An  rcwa  mapping  can  be projected to the first / second coordinate if and
  only  if  the first / second coordinate of the image of a point depends only
  on  the  first / second coordinate of the preimage. Note that this is a very
  strong and restrictive condition.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> f := RcwaMapping(ClassTransposition(0,2,1,2),ClassReflection(0,2));;[0X
    [4Xgap> Display(f);[0X
    [4X[0X
    [4XRcwa mapping of Z^2 with modulus (2,0)Z+(0,2)Z[0X
    [4X[0X
    [4X    [m,n] mod (2,0)Z+(0,2)Z    |               Image of [m,n][0X
    [4X-------------------------------+----------------------------------------------[0X
    [4X [0,0]                         | [m+1,-n][0X
    [4X [0,1]                         | [m+1,n][0X
    [4X [1,0]                         | [m-1,-n][0X
    [4X [1,1]                         | [m-1,n][0X
    [4X[0X
    [4Xgap> List(ProjectionsToCoordinates(f),Factorization);[0X
    [4X[ [ ClassTransposition(0,2,1,2) ], [ ClassReflection(0,2) ] ][0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1X5.4 Methods for residue-class-wise affine groups and -monoids over ℤ^2[0X
  
  Residue-class-wise   affine  groups  over  ℤ^2  can  be  entered  by  [10XGroup[0m,
  [10XGroupByGenerators[0m and [10XGroupWithGenerators[0m, like any groups in [5XGAP[0m. Likewise,
  residue-class-wise  affine  monoids  over  ℤ^2  can be entered by [10XMonoid[0m and
  [10XMonoidByGenerators[0m.   The  groups  RCWA(ℤ^2)  and  CT(ℤ^2)  are  entered  as
  [10XRCWA(Integers^2)[0m  and  [10XCT(Integers^2)[0m, respectively. The monoid Rcwa(ℤ^2) is
  entered as [10XRcwa(Integers^2)[0m.
  
  There   are   methods   provided   for   the  operations  [10XSize[0m,  [10XIsIntegral[0m,
  [10XIsClassWiseTranslating[0m, [10XIsTame[0m, [10XModulus[0m, [10XMultiplier[0m and [10XDivisor[0m.
  
  There  are  methods  for [2XIsomorphismRcwaGroup[0m ([14X3.1-4[0m) which embed the groups
  SL(2,ℤ)  and  GL(2,ℤ)  into  RCWA(ℤ^2) in such a way that the support of the
  image is a specified residue class:
  
  
  [1X5.4-1 IsomorphismRcwaGroup (Embeddings of SL(2,ℤ) and GL(2,ℤ))[0X
  
  [2X> IsomorphismRcwaGroup( [0X[3Xsl2z, cl[0X[2X ) ________________________________[0Xattribute
  [2X> IsomorphismRcwaGroup( [0X[3Xgl2z, cl[0X[2X ) ________________________________[0Xattribute
  [6XReturns:[0X  A monomorphism from [3Xsl2z[0m respectively [3Xgl2z[0m to RCWA(ℤ^2), such that
            the  support  of  the  image  is  the  residue  class [3Xcl[0m  and  the
            generators are affine on [3Xcl[0m.
  
  [4X---------------------------  Example  ----------------------------[0X
    [4X[0X
    [4Xgap> sl := SL(2,Integers);[0X
    [4XSL(2,Integers)[0X
    [4Xgap> phi := IsomorphismRcwaGroup(sl,ResidueClass([1,0],[[2,2],[0,3]]));[0X
    [4X[ [ [ 0, 1 ], [ -1, 0 ] ], [ [ 1, 1 ], [ 0, 1 ] ] ] -> [0X
    [4X[ ClassRotation((1,0)+(2,2)Z+(0,3)Z,[[0,1],[-1,0]]), [0X
    [4X  ClassRotation((1,0)+(2,2)Z+(0,3)Z,[[1,1],[0,1]]) ][0X
    [4Xgap> Support(Image(phi));[0X
    [4X(1,0)+(2,2)Z+(0,3)Z[0X
    [4Xgap> gl := GL(2,Integers);[0X
    [4XGL(2,Integers)[0X
    [4Xgap> phi := IsomorphismRcwaGroup(gl,ResidueClass([1,0],[[2,2],[0,3]]));[0X
    [4X[ [ [ 0, 1 ], [ 1, 0 ] ], [ [ -1, 0 ], [ 0, 1 ] ], [0X
    [4X  [ [ 1, 1 ], [ 0, 1 ] ] ] -> [0X
    [4X[ ClassRotation((1,0)+(2,2)Z+(0,3)Z,[[0,1],[1,0]]), [0X
    [4X  ClassRotation((1,0)+(2,2)Z+(0,3)Z,[[-1,0],[0,1]]), [0X
    [4X  ClassRotation((1,0)+(2,2)Z+(0,3)Z,[[1,1],[0,1]]) ][0X
    [4Xgap> [[-47,-37],[61,48]]^phi;[0X
    [4XClassRotation((1,0)+(2,2)Z+(0,3)Z,[[-47,-37],[61,48]])[0X
    [4Xgap> Display(last);[0X
    [4X[0X
    [4XBijective rcwa mapping of Z^2 with modulus (2,2)Z+(0,3)Z, of order 6[0X
    [4X[0X
    [4X   [m,n] mod (2,2)Z+(0,3)Z   |              Image of [m,n][0X
    [4X-----------------------------+-------------------------------------------[0X
    [4X [0,0] [0,1] [0,2] [1,1]     |[0X
    [4X [1,2]                       | [m,n][0X
    [4X [1,0]                       | [(-263m+122n+266)/3,(-1147m+532n+1147)/6][0X
    [4X[0X
    [4X[0X
  [4X------------------------------------------------------------------[0X
  
  The  function  [2XDrawOrbitPicture[0m  ([14X3.3-2[0m)  can  also be used to depict orbits
  under  the action of rcwa groups over ℤ^2. Further there is a function which
  depicts residue class unions of ℤ^2 and partitions of ℤ^2 into such:
  
  
  [1X5.4-2 DrawGrid[0X
  
  [2X> DrawGrid( [0X[3XU, yrange, xrange, filename[0X[2X ) __________________________[0Xfunction
  [2X> DrawGrid( [0X[3XP, yrange, xrange, filename[0X[2X ) __________________________[0Xfunction
  [6XReturns:[0X  Nothing.
  
  This  function  depicts  the residue class union [3XU[0m of ℤ^2 or the partition [3XP[0m
  of ℤ^2  into  residue  class  unions, respectively. The arguments [3Xyrange[0m and
  [3Xxrange[0m are the coordinate ranges of the rectangular snippet to be drawn, and
  the  argument  [3Xfilename[0m  is the name, i.e. the full path name, of the output
  file.  If the first argument is a residue class union, the output picture is
  black-and-white,  where black pixels represent members of [3XU[0m and white pixels
  represent  non-members.  If  the  first  argument is a partition of ℤ^2 into
  residue  class unions, the produced picture is colored, and different colors
  are used to denote membership in different parts.
  
