Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/modular/abvar/constructor.py
4045 views
1
"""
2
Constructors for certain modular abelian varieties
3
4
AUTHORS:
5
6
- William Stein (2007-03)
7
"""
8
9
###########################################################################
10
# Copyright (C) 2007 William Stein <[email protected]> #
11
# Distributed under the terms of the GNU General Public License (GPL) #
12
# http://www.gnu.org/licenses/ #
13
###########################################################################
14
15
import weakref
16
17
from sage.rings.integer import Integer
18
19
from sage.modular.arithgroup.all import is_CongruenceSubgroup, Gamma0
20
from sage.modular.modsym.space import is_ModularSymbolsSpace
21
from abvar_newform import ModularAbelianVariety_newform
22
import sage.modular.modform.element
23
import abvar
24
25
_cache = {}
26
27
def _get(key):
28
"""
29
Returns the cached abelian variety with given key. This is used
30
internally by the abelian varieties constructor.
31
32
INPUT:
33
34
35
- ``key`` - hashable
36
37
38
EXAMPLE::
39
40
sage: sage.modular.abvar.constructor._saved('a', J0(37))
41
Abelian variety J0(37) of dimension 2
42
sage: sage.modular.abvar.constructor._get('a')
43
Abelian variety J0(37) of dimension 2
44
sage: sage.modular.abvar.constructor._get('b')
45
Traceback (most recent call last):
46
...
47
ValueError: element not in cache
48
"""
49
if _cache.has_key(key):
50
z = _cache[key]()
51
if z is not None:
52
return z
53
raise ValueError, "element not in cache"
54
55
def _saved(key, J):
56
"""
57
Returns the cached abelian variety with given key. This is used
58
internally by the abelian varieties constructor.
59
60
INPUT:
61
62
63
- ``key`` - hashable
64
65
- ``J`` - modular abelian variety
66
67
68
OUTPUT:
69
70
71
- ``J`` - returns the modabvar, to make code that uses
72
this simpler
73
74
75
EXAMPLES::
76
77
sage: sage.modular.abvar.constructor._saved('37', J0(37))
78
Abelian variety J0(37) of dimension 2
79
"""
80
_cache[key] = weakref.ref(J)
81
return J
82
83
84
def J0(N):
85
"""
86
Return the Jacobian `J_0(N)` of the modular curve
87
`X_0(N)`.
88
89
EXAMPLES::
90
91
sage: J0(389)
92
Abelian variety J0(389) of dimension 32
93
94
The result is cached::
95
96
sage: J0(33) is J0(33)
97
True
98
"""
99
key = 'J0(%s)'%N
100
try:
101
return _get(key)
102
except ValueError:
103
from sage.modular.arithgroup.all import Gamma0
104
J = Gamma0(N).modular_abelian_variety()
105
return _saved(key, J)
106
107
def J1(N):
108
"""
109
Return the Jacobian `J_1(N)` of the modular curve
110
`X_1(N)`.
111
112
EXAMPLES::
113
114
sage: J1(389)
115
Abelian variety J1(389) of dimension 6112
116
"""
117
key = 'J1(%s)'%N
118
try:
119
return _get(key)
120
except ValueError:
121
from sage.modular.arithgroup.all import Gamma1
122
return _saved(key, Gamma1(N).modular_abelian_variety())
123
124
def JH(N, H):
125
"""
126
Return the Jacobian `J_H(N)` of the modular curve
127
`X_H(N)`.
128
129
EXAMPLES::
130
131
sage: JH(389,[16])
132
Abelian variety JH(389,[16]) of dimension 64
133
"""
134
key = 'JH(%s,%s)'%(N,H)
135
try:
136
return _get(key)
137
except ValueError:
138
from sage.modular.arithgroup.all import GammaH
139
return _saved(key, GammaH(N, H).modular_abelian_variety())
140
141
def AbelianVariety(X):
142
"""
143
Create the abelian variety corresponding to the given defining
144
data.
145
146
INPUT:
147
148
149
- ``X`` - an integer, string, newform, modsym space,
150
congruence subgroup or tuple of congruence subgroups
151
152
153
OUTPUT: a modular abelian variety
154
155
EXAMPLES::
156
157
sage: AbelianVariety(Gamma0(37))
158
Abelian variety J0(37) of dimension 2
159
sage: AbelianVariety('37a')
160
Newform abelian subvariety 37a of dimension 1 of J0(37)
161
sage: AbelianVariety(Newform('37a'))
162
Newform abelian subvariety 37a of dimension 1 of J0(37)
163
sage: AbelianVariety(ModularSymbols(37).cuspidal_submodule())
164
Abelian variety J0(37) of dimension 2
165
sage: AbelianVariety((Gamma0(37), Gamma0(11)))
166
Abelian variety J0(37) x J0(11) of dimension 3
167
sage: AbelianVariety(37)
168
Abelian variety J0(37) of dimension 2
169
sage: AbelianVariety([1,2,3])
170
Traceback (most recent call last):
171
...
172
TypeError: X must be an integer, string, newform, modsym space, congruence subgroup or tuple of congruence subgroups
173
"""
174
if isinstance(X, (int, long, Integer)):
175
X = Gamma0(X)
176
if is_CongruenceSubgroup(X):
177
X = X.modular_symbols().cuspidal_submodule()
178
elif isinstance(X, str):
179
from sage.modular.modform.constructor import Newform
180
f = Newform(X, names='a')
181
return ModularAbelianVariety_newform(f, internal_name=True)
182
elif isinstance(X, sage.modular.modform.element.Newform):
183
return ModularAbelianVariety_newform(X)
184
185
if is_ModularSymbolsSpace(X):
186
return abvar.ModularAbelianVariety_modsym(X)
187
188
if isinstance(X, (tuple,list)) and all([is_CongruenceSubgroup(G) for G in X]):
189
return abvar.ModularAbelianVariety(X)
190
191
raise TypeError, "X must be an integer, string, newform, modsym space, congruence subgroup or tuple of congruence subgroups"
192
193