#####
#
# This is GAP code
# 
# The file is ~steger/donald/SU21/a7p2/padic.gap
#
# We work out first the correct integrality conditions at the 3-adic
# place.
#
# See file ~steger/donald/SU21/a7p3/D.txt for the definition of the
# division algebra $\D$ and for all the notation.
#
#####

I3:=IdentityMat(3); # 3 by 3 identity matrix
Z3:=Zero(I3); # 3 by 3 zero matrix

# Function to conjugate a matrix
BarM:=mtx->
  List(mtx,row->
    List(row,x->ComplexConjugate(x))
  );

# Function to calculate the adjoint of a matrix
AdjM:=mtx->TransposedMat(BarM(mtx));

# Real and ``imaginary'' parts of a matrix with entries in
# $\QQ[\sqrt{-7}]$.  The imaginary part is actually calculated as
# $(M-\bar M)/2\sqrt{-7}$, so that it will come out as a rational
# matrix.
ReM:=mtx->(mtx+BarM(mtx))/2;
Im7M:=mtx->(mtx-BarM(mtx))/(2*Sqrt(-7));

# Calculate a matrix modulo m
ModM:=function(mtx,m)
  return (ReM(mtx) mod m) + Sqrt(-7)*(Im7M(mtx) mod m);
end;

cTod6by6:=[
  [  1,  0,    0,  0,  0, -2],
  [  0,  1,    0,  0,  0,  1],
  [  0,  0,    0,  0,  0,  1],
  [  0,  0,  2/7,  1,  0,  0],
  [  0,  0, -1/7,  0,  1,  0],
  [  0,  0, -1/7,  0,  0,  0]];

cTod18by18:=List([1..18],ir->List([1..18],ic->0));
cTod18by18{[1,4,7,10,13,16]}{[1,4,7,10,13,16]}:=cTod6by6;
cTod18by18{[2,5,8,11,14,17]}{[2,5,8,11,14,17]}:=cTod6by6;
cTod18by18{[3,6,9,12,15,18]}{[3,6,9,12,15,18]}:=cTod6by6;


# $Z$, $\phi(Z)$, and $\phi^2(Z)$ in the 3-adic matrix representation:
ZD3M:=[[0,-1,0],[0,-3,1],[3,0,0]];
phiZD3M:= -Sqrt(-7)/7*ZD3M^2
  + (-1/2-9*Sqrt(-7)/14)*ZD3M
  + (-3/2-3*Sqrt(-7)/14)*I3;
phi2ZD3M:= Sqrt(-7)/7*ZD3M^2
  + (-1/2+9*Sqrt(-7)/14)*ZD3M
  + (-3/2+3*Sqrt(-7)/14)*I3;

# $\sigma$ in the 3-adic matrix represenation.
#
# This is an approximation $\mod 3^10$.
#
sigma3M:=
  [[ 53423,44984,2813 ], [ 0,44984,5626 ], [ 25293,8415,19691 ]] +
  Sqrt(-7)*[[ 0,57445,7230 ], [ 0,36150,20086 ], [ 0,27711,22899 ]];

# In the 3-adic matrix representation, the element~$F$ so that
#   
#   \iota(A) = F^{-1} A^* F
#
# Thus, $\iota$-unitary elements will preserve the sesquilinear form
# defined by $F$.
#
# This is an approximation $\mod 3^10$.
#
F3M:=
 [[ 50634,59001,14089 ],[ 59001,36401,42219 ],[ 14089,42219, 19667 ]];

# Function to test a matrix with entries in $\QQ[\sqrt{-7}]$ for being
# zero modulo 3^10.
IsZero3M:=mtx->
  ReM(mtx) mod 3^10 = 0*I3 and Im7M(mtx) mod 3^10 = 0*I3;

# Various checks.  In each case, we only check modulo~$3^10$.  Our
# matrices are rational approximations to matrices with coefficients
# in $\QQ_3[\sqrt{-7}]$, and the approximations are supposed to be
# valid modulo~$3^10$

# Check that $Z^3+3*Z^2+3=0$ and similar:
IsZero3M(ZD3M^3+3*ZD3M^2+3*I3);
IsZero3M(phiZD3M^3+3*phiZD3M^2+3*I3);
IsZero3M(phi2ZD3M^3+3*phi2ZD3M^2+3*I3);

# Check that $\sigma Z \sigma^-1 = \phi(Z)$, and similar:
IsZero3M(sigma3M*ZD3M*sigma3M^-1-phiZD3M);
IsZero3M(sigma3M*phiZD3M*sigma3M^-1-phi2ZD3M);
IsZero3M(sigma3M*phi2ZD3M*sigma3M^-1-ZD3M);

# Check that $\sigma^3 = 2$:
IsZero3M(sigma3M^3-2*I3);

# Check that $F$ is self-adjoint:
IsZero3M(F3M-AdjM(F3M));

# Check that $\iota$ fixes both $\sigma$ and $Z$ and changes the sign
# of $\sqrt{-7}:
IsZero3M(F3M^-1*AdjM(sigma3M)*F3M-sigma3M);
IsZero3M(F3M^-1*AdjM(ZD3M)*F3M-ZD3M);
IsZero3M(F3M^-1*AdjM(Sqrt(-7)*I3)*F3M - (-Sqrt(-7)*I3));

# Function to test whether a matrix is integral mod 3
IsIntegral3M:=mtx->
  (3*ReM(mtx)) mod 3 = 0*I3 and (3*Im7M(mtx)) mod 3 = 0*I3;

# Verify that in this matrix representation, the matrix~$F$ and of the
# sesquilinear form is 3-adically integral, as is its inverse.
IsIntegral3M(F3M);
IsIntegral3M(F3M^-1);

# The preceding checks show that the standard $\QQ_3$ lattice
# $L_0=\ZZ_3^3$, is self-dual with respect to the form given by~$F$.
 
# Consequently matrices which preserve that lattice, which is to say
# matrices in $GL(3,\ZZ_3)$, fix a hyperspecial vertex in the 3-adic
# tree corresponding to the 3-adic reduction of $PU(\D,\iota)$.

# 18-element basis of $\D$ over $\QQ$
basis3M:=ListX([0..1],[0..2],[0..2],
  function(j,k,l)
    return Sqrt(-7)^j*ZD3M^k*sigma3M^l;
  end
);;


# For a $3\times 3$ matrix with coefficients in $\ZZ[\sqrt{-7}]$, this
# function calculate the real and ``imaginary'' parts of the
# 9~entries, each modulo~$9$, and puts them together as an 18~element
# vector.

CondCoeff3:=function(mtx)
  local Re,Im7;
  Re:=ReM(mtx);
  Im7:=Im7M(mtx);
  return Concatenation(
    ListX([1..3],[1..3],function(j,k)
      return Re[j][k] mod 3^2;
    end),
    ListX([1..3],[1..3],function(j,k)
      return Im7[j][k] mod 3^2;
    end)
  );
end;

# The element
#
#   \sum d_{jkl} \sqrt{-7}^j Z^k \sigma^l
#
# in~$\D$ will have (approximate) 3-adic matrix representation
#
#    Sum([1..18],d[j]*basis[j])
#  
# and this 3-adic matrix representation will be 3-adically integral if
# and only if the vector:
#
#   CondMtx3M * d
#
# consists of 3-adic integers.
CondMtx3M:=TransposedMat(List(basis3M,mtx->CondCoeff3(mtx)));

#CondMtx3M:=[
#  [ 1, 8, 7, 0, 0, 6, 0, 6, 6, 0, 0, 0, 0, 0, 3, 0, 0, 0 ],
#  [ 0, 2, 5, 8, 7, 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# Now we work out the two forms of the correct integrality conditions
# at the 7-adic place.
#
# See file ~steger/donald/SU21/a7p3/D.txt for the definition of the
# division algebra $\D$ and for all the notation.
#
#####

# $Z$, $\phi(Z)$, and $\phi^2(Z)$ in the 7-adic matrix representation:

Zapprox:=1;
for j in [1..10] do
  Zapprox:=
    Zapprox+7^j*
      (((((Zapprox^3+3*Zapprox^2+3)/7^j) mod 7)*3+3) mod 7 -3);
od;

# Approximation $\mod 7^10$ to the 7-adic solution of $Z^3+3Z^2+3=0$
Z7:= -3850888;
phiZ7:= -Sqrt(-7)/7*Z7^2 + (-1/2-9*Sqrt(-7)/14)*Z7 
	+(-3/2-3*Sqrt(-7)/14);
phi2Z7:= Sqrt(-7)/7*Z7^2 + (-1/2+9*Sqrt(-7)/14)*Z7 
	+(-3/2+3*Sqrt(-7)/14);

# $Z$, $\phi(Z)$, and $\phi^2(Z)$ in the 7-adic matrix representation:
# These are approximations $\mod 7^10$
ZD7M:=[[Z7,0,0],[0,phiZ7,0],[0,0,phi2Z7]];
phiZD7M:= -Sqrt(-7)/7*ZD7M^2
  + (-1/2-9*Sqrt(-7)/14)*ZD7M
  + (-3/2-3*Sqrt(-7)/14)*I3;
phi2ZD7M:= Sqrt(-7)/7*ZD7M^2
  + (-1/2+9*Sqrt(-7)/14)*ZD7M
  + (-3/2+3*Sqrt(-7)/14)*I3;

# $\sigma$ in the 7-adic matrix represenation.
#
sigma7M:=[[0,1,0],[0,0,1],[2,0,0]];

# In the 7-adic matrix representation, the element~$F$ so that
#   
#   \iota(A) = F^{-1} A^* F
#
# Thus, $\iota$-unitary elements will preserve the sesquilinear form
# defined by $F$.
F7M:=
 [[2,0,0],[0,0,1],[0,1,0]];

# Function to test a matrix with entries in $\QQ[\sqrt{-7}]$ for being
# zero modulo 7^10.
IsZero7M:=mtx->
  ReM(mtx) mod 7^10 = 0*I3 and Im7M(mtx) mod 7^10 = 0*I3;

# Various checks.  In each case, we only check modulo~$7^10$.  Our
# matrices are rational approximations to matrices with coefficients
# in $\QQ_7[\sqrt{-7}]$, and the approximations are supposed to be
# valid modulo~$7^10$

# Check that $Z^3+3*Z^2+3=0$ and similar:
IsZero7M(ZD7M^3+3*ZD7M^2+3*I3);
IsZero7M(phiZD7M^3+3*phiZD7M^2+3*I3);
IsZero7M(phi2ZD7M^3+3*phi2ZD7M^2+3*I3);

# Check that $\sigma Z \sigma^-1 = \phi(Z)$, and similar:
IsZero7M(sigma7M*ZD7M*sigma7M^-1-phiZD7M);
IsZero7M(sigma7M*phiZD7M*sigma7M^-1-phi2ZD7M);
IsZero7M(sigma7M*phi2ZD7M*sigma7M^-1-ZD7M);

# Check that $\sigma^3 = 2$:
IsZero7M(sigma7M^3-2*I3);

# Check that $F$ is self-adjoint:
IsZero7M(F7M-AdjM(F7M));

# Check that $\iota$ fixes both $\sigma$ and $Z$ and changes the sign
# of $\sqrt{-7}:
IsZero7M(F7M^-1*AdjM(sigma7M)*F7M-sigma7M);
IsZero7M(F7M^-1*AdjM(ZD7M)*F7M-ZD7M);
IsZero7M(F7M^-1*AdjM(Sqrt(-7)*I3)*F7M - (-Sqrt(-7)*I3));

# Function to test whether a matrix is integral mod 7
IsIntegral7M:=mtx->
  (7*ReM(mtx)) mod 7 = 0*I3 and (7*Im7M(mtx)) mod 7 = 0*I3;

# Verify that in this matrix representation, the matrix~$F$ and of the
# sesquilinear form is 7-adically integral, as is its inverse.
IsIntegral7M(F7M);
IsIntegral7M(F7M^-1);

# The previous check shows that the standard $\QQ_7$ lattice
# $L_0=\ZZ_7^3$, is self-dual with respect to the form given by~$F$.

# Consequently unitary matrices which preserve that lattice, which is
# to say matrices in $PU \cap PGL(3\ZZ_7)$, fix a vertex of _first_
# type in the 7-adic tree corresponding to the 7-adic reduction of
# $PU(\D,\iota)$. 

# Now we conjugate these matrices to change to a vertex of second
# type.

ConjMtx:=[[1,0,0],[0,1,0],[0,0,Sqrt(-7)]];

# $Z$, $\phi(Z)$, and $\phi^2(Z)$ in the NEW 7-adic matrix
# representation. These are approximations $\mod 7^10$

ZD7MN:=ConjMtx*ZD7M*ConjMtx^-1;
phiZD7MN:=ConjMtx*phiZD7M*ConjMtx^-1;
phi2ZD7MN:=ConjMtx*phi2ZD7M*ConjMtx^-1;

# $\sigma$ in the NEW 7-adic matrix represenation.
#
sigma7MN:=ConjMtx*sigma7M*ConjMtx^-1;

# In the NEW 7-adic matrix representation, the element~$F$ so that
#   
#   \iota(A) = F^{-1} A^* F
#
# Thus, $\iota$-unitary elements will preserve the sesquilinear form
# defined by $F$.
F7MN:= AdjM(ConjMtx)^-1*F7M*ConjMtx^-1;

# Repeat the various checks.  In each case, we only check
# modulo~$7^10$.  Our matrices are rational approximations to matrices
# with coefficients in $\QQ_7[\sqrt{-7}]$, and the approximations are
# supposed to be valid modulo~$7^10$

# Check that $Z^3+3*Z^2+3=0$ and similar:
IsZero7M(ZD7MN^3+3*ZD7MN^2+3*I3);
IsZero7M(phiZD7MN^3+3*phiZD7MN^2+3*I3);
IsZero7M(phi2ZD7MN^3+3*phi2ZD7MN^2+3*I3);

# Check that $\sigma Z \sigma^-1 = \phi(Z)$, and similar:
IsZero7M(sigma7MN*ZD7MN*sigma7MN^-1-phiZD7MN);
IsZero7M(sigma7MN*phiZD7MN*sigma7MN^-1-phi2ZD7MN);
IsZero7M(sigma7MN*phi2ZD7MN*sigma7MN^-1-ZD7MN);

# Check that $\sigma^3 = 2$:
IsZero7M(sigma7MN^3-2*I3);

# Check that $F$ is self-adjoint:
IsZero7M(F7MN-AdjM(F7MN));

# Check that $\iota$ fixes both $\sigma$ and $Z$ and changes the sign
# of $\sqrt{-7}:
IsZero7M(F7MN^-1*AdjM(sigma7MN)*F7MN-sigma7MN);
IsZero7M(F7MN^-1*AdjM(ZD7MN)*F7MN-ZD7MN);
IsZero7M(F7MN^-1*AdjM(Sqrt(-7)*I3)*F7MN - (-Sqrt(-7)*I3));

# Check the degree of integrality of F7MN, the matrix of the
# new sesquilinear form, and of its inverse.

IsIntegral7M(F7MN);
IsIntegral7M(F7MN*Sqrt(-7));

IsIntegral7M(F7MN^-1/Sqrt(-7));
IsIntegral7M(F7MN^-1);

Determinant(Sqrt(-7)*F7MN) = 2*Sqrt(-7);
Determinant(F7MN^-1) = -7/2;

# Let $L_0=\ZZ_7^3$ be the standard lattice in $\QQ_7^3$.  Relative to
# the sesquilinear form defined by F7MN, let $L_0^*% be the lattice
# dual to $L_0$. Here is what to deduce from the previous checks:

#   Since F7MN^-1 is integral, $L_0^* \subseteq L_0$

#   Since F7MN*Sqrt(-7) is integral, $\sqrt(-7)L_0 \subseteq L_0^*$.

#   Since Determinant(F7MN^-1) = -7/2, $[L_0:L_0^*] = 49$

#   Since Determinant(Sqrt(-7)*F7MN) = Sqrt(-7)/2,
#   $[L_0^*:\sqrt(-7)L_0] = 7$ 

# Consequently unitary matrices which preserve $L_0$, which is to say
# matrices in $PU(\QQ_7^3,F7MN) \cap PGL(3\ZZ_7)$, fix a vertex of
# _second_ type in the 7-adic tree corresponding to the 7-adic
# reduction of $PU(\D,\iota)$.  These matrices necessarily fix~$L_0^*$
# as well.

# 18-element basis of $\D$ over $\QQ$, given as matrices over
# $\QQ_7[\sqrt{-7}]$. 
basis7M:=ListX([0..1],[0..2],[0..2],
  function(j,k,l)
    return Sqrt(-7)^j*ZD7M^k*sigma7M^l;
  end
);;

# For a $3\times 3$ matrix with coefficients in $\ZZ[\sqrt{-7}]$, this
# function calculate the real and ``imaginary'' parts of the
# 9~entries, each modulo~$7^3$, and puts them together as an 18~element
# vector.

CondCoeff:=function(mtx)
  local Re,Im7;
  Re:=ReM(mtx);
  Im7:=Im7M(mtx);
  return Concatenation(
    ListX([1..3],[1..3],function(j,k)
      return Re[j][k] mod 7^3;
    end),
    ListX([1..3],[1..3],function(j,k)
      return Im7[j][k] mod 7^3;
    end)
  );
end;

# The element
#
#   \sum d_{jkl} \sqrt{-7}^j Z^k \sigma^l
#
# in~$\D$ will have (approximate) 7-adic matrix representation
#
#    Sum([1..18],d[j]*basis[j])
#  
# and this 3-adic matrix representation will be 3-adically integral if
# and only if the vector:
#
#   CondMtx * d
#
# consists of 3-adic integers.
CondMtx7MType1:=TransposedMat(List(basis7M,mtx->CondCoeff(7*mtx)/7));

# 18-element basis of $\D$ over $\QQ$, given as the NEW matrices over
# $\QQ_7[\sqrt{-7}]$. 
basis7MN:=ListX([0..1],[0..2],[0..2],
  function(j,k,l)
    return Sqrt(-7)^j*ZD7MN^k*sigma7MN^l;
  end
);;

# The element
#
#   \sum d_{jkl} \sqrt{-7}^j Z^k \sigma^l
#
# in~$\D$ will have (approximate) 7-adic matrix representation
#
#    Sum([1..18],d[j]*basis[j])
#  
# and this 3-adic matrix representation will be 3-adically integral if
# and only if the vector:
#
#   CondMtx * d
#
# consists of 3-adic integers.
CondMtx7MType2:=TransposedMat(List(basis7MN,mtx->CondCoeff(7*mtx)/7));

#CondMtx7MType2*7;         
#[ [ 7, 0, 0, 154, 0, 0, 301, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], 
#  [ 0, 7, 0, 0, 154, 0, 0, 301, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], 
#  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 154, 0, 0, 301 ], 
#  [ 0, 0, 14, 0, 0, 168, 0, 0, 105, 0, 0, 0, 0, 0, 294, 0, 0, 196 ], 
#  [ 7, 0, 0, 84, 0, 0, 224, 0, 0, 0, 0, 0, 147, 0, 0, 98, 0, 0 ], 
#  [ 0, 0, 0, 0, 77, 0, 0, 133, 0, 0, 7, 0, 0, 84, 0, 0, 224, 0 ], 
#  [ 0, 0, 0, 0, 49, 0, 0, 147, 0, 0, 245, 0, 0, 196, 0, 0, 294, 0 ], 
#  [ 0, 0, 0, 0, 0, 49, 0, 0, 147, 0, 0, 245, 0, 0, 196, 0, 0, 294 ], 
#  [ 7, 0, 0, 84, 0, 0, 224, 0, 0, 0, 0, 0, 196, 0, 0, 245, 0, 0 ], 
#  [ 0, 0, 0, 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, 15, 0, 0, 0, 0, 0, 7, 0, 0, 21 ], 
#  [ 1, 0, 0, 12, 0, 0, 32, 0, 0, 0, 0, 0, 28, 0, 0, 35, 0, 0 ], 
#  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 22, 0, 0, 43, 0, 0 ], 
#  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 22, 0, 0, 43, 0 ], 
#  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 22, 0, 0, 43 ], 
#  [ 0, 0, 0, 0, 0, 22, 0, 0, 38, 0, 0, 2, 0, 0, 24, 0, 0, 15 ], 
#  [ 0, 0, 0, 11, 0, 0, 19, 0, 0, 1, 0, 0, 12, 0, 0, 32, 0, 0 ], 
#  [ 0, 0, 0, 0, 11, 0, 0, 19, 0, 0, 1, 0, 0, 12, 0, 0, 32, 0 ], 
#  [ 0, 0, 0, 0, 27, 0, 0, 11, 0, 0, 2, 0, 0, 24, 0, 0, 15, 0 ], 
#  [ 0, 0, 0, 0, 0, 27, 0, 0, 11, 0, 0, 2, 0, 0, 24, 0, 0, 15 ], 
#  [ 0, 0, 0, 38, 0, 0, 30, 0, 0, 1, 0, 0, 12, 0, 0, 32, 0, 0 ] ]

######
#
# Here we examine the group $(p=7,a=2)_\emptyset$ and its subgroups
# $7$-adically
# 
######

U7Mp:=
  [[1/18*(Z7^2+3*Z7+3)*Sqrt(-7)+1/6*(Z7^2+Z7-3), 
      1/126*(11*Z7^2+18*Z7-36)*Sqrt(-7)+1/6*(-Z7^2-4*Z7-2),
      1/126*(-2*Z7^2-9*Z7-3)*Sqrt(-7)+1/6*(Z7+1)
    ],
    [1/63*(-2*Z7^2-9*Z7-3)*Sqrt(-7)+1/3*(-Z7-1),
     1/18*(Z7^2+3*Z7+3)*Sqrt(-7)+1/6*(-Z7^2-Z7+1),
     -1/18*Z7^2*Sqrt(-7)+1/6*(-Z7^2-2*Z7)
    ],
    [1/63*(-4*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M^-1*B7M^-2*U7M^-1
  *B7M*U7M^-3,
B7M*U7M^-3*B7M*U7M^3*B7M^-1*U7M*B7M^-1*U7M^-1*B7M^-4*U7M^-1
  *B7M^-1*U7M^-1*B7M^-1*U7M^-1,
U7M*B7M^-2*U7M^-1*B7M^-1*U7M^-1*B7M^-1*U7M^-1*B7M*U7M^-2
  *B7M*U7M*B7M^-1*U7M^2*B7M*U7M*B7M*U7M^-1*B7M^-1*U7M*B7M^-1
  *U7M*B7M^-1*U7M^-1*B7M^-2
];;

List(relnlist7M,function(mtx)
  local tmp;
  tmp:=ModM(mtx,7^10);
  return tmp-tmp[1][1]*One(tmp);
end);

U7R:=(ReM(U7M) mod 7)*One(GF(7));
A7R:=(ReM(A7M) mod 7)*One(GF(7));
B7R:=(ReM(B7M) mod 7)*One(GF(7));

GammaBar7R:=Group(B7R,U7R);

index21a7R:=Group(B7R^3, U7R^2*B7R^-1*U7R*B7R, U7R*B7R*U7R^2*B7R^-1,
U7R*B7R^3*U7R, U7R*B7R^-1*U7R*B7R*U7R, U7R*B7R^-3*U7R,
B7R*U7R^2*B7R^-1*U7R, B7R*U7R*B7R^-1*U7R^-3);

index21b7R:=Group(B7R^3, U7R^2*B7R*U7R^-1*B7R^-1,
(U7R*B7R*U7R^-1)^3, U7R*B7R*U7R^-1*B7R^-1*U7R, U7R*B7R^-1*U7R^-2*B7R,
B7R*U7R*B7R^2*U7R^-2, (B7R*U7R^-1)^3);

index21c7R:=Group(B7R, U7R^-1*B7R^2*U7R^-1, U7R^2*B7R*U7R^2,
U7R^-2*B7R*U7R^-3, (U7R^-1*B7R^-1*U7R^-1)^2);

index7a7R:=Group(B7R, U7R^-1*B7R*U7R^-2, U7R^-2*B7R^-1*U7R^-1,
U7R^3*B7R*U7R^-1);

index7b7R:=Group(B7R, U7R*B7R^-1*U7R^-2, U7R^-1*B7R^-1*U7R^2,
U7R^3*B7R^-1*U7R);

Size(index21a7R);
Size(index21b7R);
Size(index21c7R);

Size(index7a7R);
Size(index7b7R);

#TA7:=EmptySCTable(2,Zero(Z(7)),"symmetric");
#SetEntrySCTable(TA7,1,1,[1,1]);
#SetEntrySCTable(TA7,1,2,[1,2]);
#A7:=AlgebraByStructureConstants(GF(7),TA7,"1","sm7");
#A7basis:=BasisVectors(Basis(A7));
#OA7:=One(A7);
#sm7A7:=A7basis[2];
#
#ToA7:=mtx->
#  (ReM(mtx) mod 7)*OA7+(Im7M(mtx) mod 7)*sm7A7;
#
#ReA7:=x->ExtRepOfObj(x)[1];
#Im7A7:=x->ExtRepOfObj(x)[2];
#ReA7M:=mtx->List(mtx,row->List(row,elt->ReA7(elt)));
#Im7A7M:=mtx->List(mtx,row->List(row,elt->Im7A7(elt)));
#
#InvA7M:=mtx->
#  ReA7M(mtx)^-1*(One(mtx)-Im7A7M(mtx)*ReA7M(mtx)^-1*sm7A7);
#AdjA7M:=mtx->
#  ReA7M(TransposedMat(mtx))*One(mtx) - Im7A7M(TransposedMat(mtx))*sm7A7;

