Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/modular/modsym/g1list.py
4059 views
1
r"""
2
List of coset representatives for `\Gamma_1(N)` in `{\rm SL}_2(\ZZ)`
3
"""
4
5
#*****************************************************************************
6
# Sage: System for Algebra and Geometry Experimentation
7
#
8
# Copyright (C) 2005 William Stein <[email protected]>
9
#
10
# Distributed under the terms of the GNU General Public License (GPL)
11
#
12
# This code is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
# General Public License for more details.
16
#
17
# The full text of the GPL is available at:
18
#
19
# http://www.gnu.org/licenses/
20
#*****************************************************************************
21
22
import sage.rings.arith as arith
23
24
class G1list:
25
r"""
26
A class representing a list of coset representatives for `\Gamma_1(N)` in
27
`{\rm SL}_2(\ZZ)`. What we actually calculate is a list of elements of
28
`(\ZZ/N\ZZ)^2` of exact order `N`.
29
30
TESTS::
31
32
sage: L = sage.modular.modsym.g1list.G1list(18)
33
sage: loads(dumps(L)) == L
34
True
35
"""
36
def __init__(self, N):
37
"""
38
EXAMPLE::
39
40
sage: L = sage.modular.modsym.g1list.G1list(6); L # indirect doctest
41
List of coset representatives for Gamma_1(6) in SL_2(Z)
42
"""
43
self.__N = N
44
self.__list = [(u,v) for u in xrange(N) for v in xrange(N) \
45
if arith.GCD(arith.GCD(u,v),N) == 1]
46
47
def __cmp__(self, other):
48
r"""
49
Compare self to other.
50
51
EXAMPLE::
52
53
sage: L1 = sage.modular.modsym.g1list.G1list(6)
54
sage: L2 = sage.modular.modsym.g1list.G1list(7)
55
sage: L1 < L2
56
True
57
sage: L1 == QQ
58
False
59
"""
60
61
if not isinstance(other, G1list):
62
return cmp(type(self), type(other))
63
else:
64
return cmp(self.__N, other.__N)
65
66
def __getitem__(self, i):
67
"""
68
EXAMPLE::
69
70
sage: L = sage.modular.modsym.g1list.G1list(19); L[100] # indirect doctest
71
(5, 6)
72
"""
73
return self.__list[i]
74
75
def __len__(self):
76
"""
77
Return the length of the underlying list.
78
79
EXAMPLE::
80
81
sage: L = sage.modular.modsym.g1list.G1list(24); len(L) # indirect doctest
82
384
83
"""
84
return len(self.__list)
85
86
def __repr__(self):
87
"""
88
String representation of self.
89
90
EXAMPLE::
91
92
sage: L = sage.modular.modsym.g1list.G1list(3); L.__repr__()
93
'List of coset representatives for Gamma_1(3) in SL_2(Z)'
94
"""
95
return "List of coset representatives for Gamma_1(%s) in SL_2(Z)"%self.__N
96
97
def list(self):
98
r"""
99
Return a list of vectors representing the cosets. Do not change the
100
returned list!
101
102
EXAMPLE::
103
104
sage: L = sage.modular.modsym.g1list.G1list(4); L.list()
105
[(0, 1), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 1), (2, 3), (3, 0), (3, 1), (3, 2), (3, 3)]
106
"""
107
return self.__list
108
109
def normalize(self, u, v):
110
r"""
111
Given a pair `(u,v)` of integers, return the unique pair `(u', v')`
112
such that the pair `(u', v')` appears in ``self.list()`` and `(u, v)`
113
is equivalent to `(u', v')`. This is rather trivial, but is here for
114
consistency with the ``P1List`` class which is the equivalent for
115
`\Gamma_0` (where the problem is rather harder).
116
117
This will only make sense if `{\rm gcd}(u, v, N) = 1`; otherwise the
118
output will not be an element of self.
119
120
EXAMPLE::
121
122
sage: L = sage.modular.modsym.g1list.G1list(4); L.normalize(6, 1)
123
(2, 1)
124
sage: L = sage.modular.modsym.g1list.G1list(4); L.normalize(6, 2) # nonsense!
125
(2, 2)
126
"""
127
return u % self.__N, v % self.__N
128
129
130
131
132
133
134
135