Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/libs/cremona/homspace.pyx
4107 views
1
from mat cimport MatrixFactory
2
3
cdef MatrixFactory MF = MatrixFactory()
4
5
cdef class ModularSymbols:
6
"""
7
Class of Cremona Modular Symbols of given level and sign (and weight 2).
8
9
EXAMPLES::
10
11
sage: M = CremonaModularSymbols(225)
12
sage: type(M)
13
<type 'sage.libs.cremona.homspace.ModularSymbols'>
14
"""
15
def __init__(self, long level, int sign=0, bint cuspidal=False, int verbose=0):
16
"""
17
Called when creating a space of Cremona modular symbols.
18
19
INPUT:
20
21
- ``level`` (int) -- the level: an integer, at least 2.
22
- ``sign`` (int, default 0) -- the sign: 0, +1 or -1
23
- ``cuspidal`` (boolean, default False) -- True for cuspidal homology
24
- ``verbose`` (int, default 0) -- verbosity level
25
26
EXAMPLES::
27
28
sage: CremonaModularSymbols(123, sign=1, cuspidal=True)
29
Cremona Cuspidal Modular Symbols space of dimension 13 for Gamma_0(123) of weight 2 with sign 1
30
sage: CremonaModularSymbols(123, sign=-1, cuspidal=True)
31
Cremona Cuspidal Modular Symbols space of dimension 13 for Gamma_0(123) of weight 2 with sign -1
32
sage: CremonaModularSymbols(123, sign=0, cuspidal=True)
33
Cremona Cuspidal Modular Symbols space of dimension 26 for Gamma_0(123) of weight 2 with sign 0
34
sage: CremonaModularSymbols(123, sign=0, cuspidal=False)
35
Cremona Modular Symbols space of dimension 29 for Gamma_0(123) of weight 2 with sign 0
36
"""
37
if not (sign == 0 or sign == 1 or sign == -1):
38
raise ValueError, "sign (= %s) is not supported; use 0, +1 or -1"%sign
39
if level <= 1:
40
raise ValueError, "the level (= %s) must be at least 2"%level
41
sig_on()
42
self.H = new_homspace(level, sign, cuspidal, verbose)
43
sig_off()
44
45
def __dealloc__(self):
46
delete_homspace(self.H)
47
48
def __repr__(self):
49
"""
50
String representation of space of Cremona modular symbols.
51
52
EXAMPLES:
53
54
We test various types of spaces that impact printing::
55
56
sage: M = CremonaModularSymbols(37, sign=1)
57
sage: M.__repr__()
58
'Cremona Modular Symbols space of dimension 3 for Gamma_0(37) of weight 2 with sign 1'
59
60
sage: CremonaModularSymbols(37, cuspidal=True).__repr__()
61
'Cremona Cuspidal Modular Symbols space of dimension 4 for Gamma_0(37) of weight 2 with sign 0'
62
"""
63
return "Cremona %sModular Symbols space of dimension %s for Gamma_0(%s) of weight 2 with sign %s"%(
64
'Cuspidal ' if self.is_cuspidal() else '',
65
self.dimension(), self.level(), self.sign())
66
67
#cpdef long level(self):
68
def level(self):
69
"""
70
Return the level of this modular symbols space.
71
72
EXAMPLES::
73
74
sage: M = CremonaModularSymbols(1234, sign=1)
75
sage: M.level()
76
1234
77
"""
78
return self.H.modulus
79
80
#cpdef int dimension(self):
81
def dimension(self):
82
"""
83
Return the dimension of this modular symbols space.
84
85
EXAMPLES::
86
87
sage: M = CremonaModularSymbols(1234, sign=1)
88
sage: M.dimension()
89
156
90
"""
91
if self.is_cuspidal():
92
return self.H.h1cuspdim()
93
else:
94
return self.H.h1dim()
95
96
def number_of_cusps(self):
97
r"""
98
Return the number of cusps for $\Gamma_0(N)$, where $N$ is the
99
level.
100
101
EXAMPLES::
102
103
sage: M = CremonaModularSymbols(225)
104
sage: M.number_of_cusps()
105
24
106
"""
107
return self.H.h1ncusps()
108
109
#cpdef int sign(self):
110
def sign(self):
111
"""
112
Return the sign of this Cremona modular symbols space. The sign is either 0, +1 or -1.
113
114
EXAMPLES::
115
116
sage: M = CremonaModularSymbols(1122, sign=1); M
117
Cremona Modular Symbols space of dimension 224 for Gamma_0(1122) of weight 2 with sign 1
118
sage: M.sign()
119
1
120
sage: M = CremonaModularSymbols(1122); M
121
Cremona Modular Symbols space of dimension 433 for Gamma_0(1122) of weight 2 with sign 0
122
sage: M.sign()
123
0
124
sage: M = CremonaModularSymbols(1122, sign=-1); M
125
Cremona Modular Symbols space of dimension 209 for Gamma_0(1122) of weight 2 with sign -1
126
sage: M.sign()
127
-1
128
"""
129
return self.H.plusflag
130
131
#cpdef bint is_cuspidal(self):
132
def is_cuspidal(self):
133
"""
134
Return whether or not this space is cuspidal.
135
136
EXAMPLES::
137
138
sage: M = CremonaModularSymbols(1122); M.is_cuspidal()
139
0
140
sage: M = CremonaModularSymbols(1122, cuspidal=True); M.is_cuspidal()
141
1
142
"""
143
return self.H.cuspidal
144
145
def hecke_matrix(self, long p, dual=False, verbose=False):
146
"""
147
Return the matrix of the ``p``-th Hecke operator acting on
148
this space of modular symbols.
149
150
The result of this command is not cached.
151
152
INPUT:
153
154
- ``p`` -- a prime number
155
156
- ``dual`` -- (default: False) whether to compute the Hecke
157
operator acting on the dual space, i.e., the
158
transpose of the Hecke operator
159
160
- ``verbose`` -- (default: False) print verbose output
161
162
OUTPUT:
163
164
(matrix) If ``p`` divides the level, the matrix of the
165
Atkin-Lehner involution `W_p` at ``p``; otherwise the matrix of the
166
Hecke operator `T_p`,
167
168
EXAMPLES::
169
170
sage: M = CremonaModularSymbols(37)
171
sage: t = M.hecke_matrix(2); t
172
5 x 5 Cremona matrix over Rational Field
173
sage: print t.str()
174
[ 3 0 0 0 0]
175
[-1 -1 1 1 0]
176
[ 0 0 -1 0 1]
177
[-1 1 0 -1 -1]
178
[ 0 0 1 0 -1]
179
sage: t.charpoly().factor()
180
(x - 3) * x^2 * (x + 2)^2
181
sage: print M.hecke_matrix(2, dual=True).str()
182
[ 3 -1 0 -1 0]
183
[ 0 -1 0 1 0]
184
[ 0 1 -1 0 1]
185
[ 0 1 0 -1 0]
186
[ 0 0 1 -1 -1]
187
sage: w = M.hecke_matrix(37); w
188
5 x 5 Cremona matrix over Rational Field
189
sage: w.charpoly().factor()
190
(x - 1)^2 * (x + 1)^3
191
sage: sw = w.sage_matrix_over_ZZ()
192
sage: st = t.sage_matrix_over_ZZ()
193
sage: sw^2 == sw.parent()(1)
194
True
195
sage: st*sw == sw*st
196
True
197
"""
198
sig_on()
199
cdef mat M = self.H.heckeop(p, dual, verbose)
200
sig_off()
201
return MF.new_matrix(M)
202
203
204