1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
#############################################################################
##
#W random.gi The Congruence package Ann Dooms
#W Eric Jespers
#W Olexandr Konovalov
##
##
#############################################################################
##
## This file contains implementations of methods to construct random elements
## of congruence subgroups CongruenceSubgroupGamma, CongruenceSubgroupGamma0,
## CongruenceSubgroupGammaUpper0, CongruenceSubgroupGamma1 and
## CongruenceSubgroupGammaUpper1.
## The idea is to select two random entries a and b in the same row or column
## of the matrix, such that a and b will satisfy the requirements arising
## from the congruence subgroup. For example, for the principal congruence
## subgroup we will select a and b as follows:
## a := 1 + n * Random( [ -10 .. 10 ] );
## b := n * Random( [ -10 .. 10 ] );
## After this we can find such x and y for the other row (or column) of the
## matrix that its determinant will be equal to one. If the resulting matrix
## will be not in the congruence subgroup because of not suitable x and y,
## we will repeat this process for another a and b until we will find
## suitable x and y.
## For each type of congruence subgroups, we provide one- and two-argument
## versions of Random. The one-argument version uses Random( [ -10 .. 10 ] )
## to generate a and b, ## and in the two-argument version Random([ -m..m ])
## will be used, where m is given by the second argument.
#############################################################################
##
## The principal congruence subgroup of level N consists of all matrices
## of the form [ 1+N N ]
## [ N 1+N ]
##
InstallMethod( Random,
"for a principal congruence subgroup",
[ IsPrincipalCongruenceSubgroup ],
0,
function( G )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := 1 + n * Random( [ -10 .. 10 ] );
b := n * Random( [ -10 .. 10 ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1 and
IsInt( -gcd.coeff2/n ) and
IsInt( (gcd.coeff1-1)/n );
return [ [ a, b ],
[ -gcd.coeff2, gcd.coeff1 ] ];
end);
InstallOtherMethod( Random,
"for a principal congruence subgroup",
[ IsPrincipalCongruenceSubgroup, IsPosInt ],
0,
function( G, m )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := 1 + n * Random( [ -m .. m ] );
b := n * Random( [ -m .. m ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1 and
IsInt( -gcd.coeff2/n ) and
IsInt( (gcd.coeff1-1)/n );
return [ [ a, b ],
[ -gcd.coeff2, gcd.coeff1 ] ];
end);
#############################################################################
##
## The congruence subgroup CongruenceSubgroupGamma0(N) consists of all matrices
## of the form [ * * ]
## [ N * ]
##
InstallMethod( Random,
"for a congruence subgroup CongruenceSubgroupGamma0",
[ IsCongruenceSubgroupGamma0 ],
0,
function( G )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := Random( [ -n*10 .. n*10 ] );
b := n * Random( [ -10 .. 10 ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1;
return [ [ a, -gcd.coeff2 ],
[ b, gcd.coeff1 ] ];
end);
InstallOtherMethod( Random,
"for a congruence subgroup CongruenceSubgroupGamma0",
[ IsCongruenceSubgroupGamma0, IsPosInt ],
0,
function( G, m )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := Random( [ -n*m .. n*m ] );
b := n * Random( [ -m .. m ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1;
return [ [ a, -gcd.coeff2 ],
[ b, gcd.coeff1 ] ];
end);
#############################################################################
##
## The congruence subgroup CongruenceSubgroupGammaUpper0(N) consists of all matrices
## of the form [ * N ]
## [ * * ]
##
InstallMethod( Random,
"for a congruence subgroup CongruenceSubgroupGammaUpper0",
[ IsCongruenceSubgroupGammaUpper0 ],
0,
function( G )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := Random( [ -n*10 .. n*10 ] );
b := n * Random( [ -10 .. 10 ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1;
return [ [ a, b ],
[ -gcd.coeff2, gcd.coeff1 ] ];
end);
InstallOtherMethod( Random,
"for a congruence subgroup CongruenceSubgroupGammaUpper0",
[ IsCongruenceSubgroupGammaUpper0, IsPosInt ],
0,
function( G, m )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := Random( [ -n*m .. n*m ] );
b := n * Random( [ -m .. m ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1;
return [ [ a, b ],
[ -gcd.coeff2, gcd.coeff1 ] ];
end);
#############################################################################
##
## The congruence subgroup CongruenceSubgroupGamma1(N) consists of all matrices
## of the form [ 1+N * ]
## [ N 1+N ]
##
InstallMethod( Random,
"for a congruence subgroup CongruenceSubgroupGamma1",
[ IsCongruenceSubgroupGamma1 ],
0,
function( G )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := 1 + n * Random( [ -10 .. 10 ] );
b := n * Random( [ -10 .. 10 ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1 and IsInt( (gcd.coeff1-1)/n );
return [ [ a, -gcd.coeff2 ],
[ b, gcd.coeff1 ] ];
end);
InstallOtherMethod( Random,
"for a congruence subgroup CongruenceSubgroupGamma1",
[ IsCongruenceSubgroupGamma1, IsPosInt ],
0,
function( G, m )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := 1 + n * Random( [ -m .. m ] );
b := n * Random( [ -m .. m ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1 and IsInt( (gcd.coeff1-1)/n );
return [ [ a, -gcd.coeff2 ],
[ b, gcd.coeff1 ] ];
end);
#############################################################################
##
## The congruence subgroup CongruenceSubgroupGammaUpper1(N) consists of all matrices
## of the form [ 1+N N ]
## [ * 1+N ]
##
InstallMethod( Random,
"for a congruence subgroup CongruenceSubgroupGammaUpper1",
[ IsCongruenceSubgroupGammaUpper1 ],
0,
function( G )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := 1 + n * Random( [ -10 .. 10 ] );
b := n * Random( [ -10 .. 10 ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1 and IsInt( (gcd.coeff1-1)/n );
return [ [ a, b ],
[ -gcd.coeff2, gcd.coeff1 ] ];
end);
InstallOtherMethod( Random,
"for a congruence subgroup CongruenceSubgroupGammaUpper1",
[ IsCongruenceSubgroupGammaUpper1, IsPosInt ],
0,
function( G, m )
local n, a, b, gcd;
n := LevelOfCongruenceSubgroup( G );
repeat
a := 1 + n * Random( [ -m .. m ] );
b := n * Random( [ -m .. m ] );
gcd := Gcdex( a, b );
until gcd.gcd = 1 and IsInt( (gcd.coeff1-1)/n );
return [ [ a, b ],
[ -gcd.coeff2, gcd.coeff1 ] ];
end);
#############################################################################
##
#E
##
|