Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/modular/modform/ambient_R.py
4057 views
1
"""
2
Modular Forms over a Non-minimal Base Ring
3
"""
4
5
#########################################################################
6
# Copyright (C) 2006 William Stein <[email protected]>
7
#
8
# Distributed under the terms of the GNU General Public License (GPL)
9
#
10
# http://www.gnu.org/licenses/
11
#########################################################################
12
13
import ambient
14
from cuspidal_submodule import CuspidalSubmodule_R
15
from sage.rings.all import ZZ
16
17
class ModularFormsAmbient_R(ambient.ModularFormsAmbient):
18
def __init__(self, M, base_ring):
19
"""
20
Ambient space of modular forms over a ring other than QQ.
21
22
EXAMPLES::
23
24
sage: M = ModularForms(23,2,base_ring=GF(7)) ## indirect doctest
25
sage: M
26
Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(23) of weight 2 over Finite Field of size 7
27
sage: M == loads(dumps(M))
28
True
29
"""
30
self.__M = M
31
if M.character() is not None:
32
self.__R_character = M.character().change_ring(base_ring)
33
else:
34
self.__R_character = None
35
ambient.ModularFormsAmbient.__init__(self, M.group(), M.weight(), base_ring, M.character())
36
37
def modular_symbols(self,sign=0):
38
r"""
39
Return the space of modular symbols attached to this space, with the given sign (default 0).
40
41
TESTS::
42
43
sage: K.<i> = QuadraticField(-1)
44
sage: chi = DirichletGroup(5, base_ring = K).0
45
sage: L.<c> = K.extension(x^2 - 402*i)
46
sage: M = ModularForms(chi, 7, base_ring = L)
47
sage: symbs = M.modular_symbols()
48
sage: symbs.character() == chi
49
True
50
sage: symbs.base_ring() == L
51
True
52
"""
53
sign = ZZ(sign)
54
try:
55
return self.__modular_symbols[sign]
56
except AttributeError:
57
self.__modular_symbols = {}
58
except KeyError:
59
pass
60
M = self.__M.modular_symbols(sign).change_ring(self.base_ring())
61
self.__modular_symbols[sign] = M
62
return M
63
64
def _repr_(self):
65
"""
66
String representation for self.
67
68
EXAMPLES::
69
70
sage: M = ModularForms(23,2,base_ring=GF(7)) ## indirect doctest
71
sage: M._repr_()
72
'Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(23) of weight 2 over Finite Field of size 7'
73
74
sage: chi = DirichletGroup(109).0 ** 36
75
sage: ModularForms(chi, 2, base_ring = chi.base_ring())
76
Modular Forms space of dimension 9, character [zeta3] and weight 2 over Cyclotomic Field of order 108 and degree 36
77
"""
78
s = str(self.__M)
79
i = s.find('over')
80
if i != -1:
81
s = s[:i]
82
return s + 'over %s'%self.base_ring()
83
84
def _compute_q_expansion_basis(self, prec=None):
85
"""
86
Compute q-expansions for a basis of self to precision prec.
87
88
EXAMPLES:
89
sage: M = ModularForms(23,2,base_ring=GF(7))
90
sage: M._compute_q_expansion_basis(5)
91
[1 + 5*q^3 + 5*q^4 + O(q^5),
92
q + 6*q^3 + 6*q^4 + O(q^5),
93
q^2 + 5*q^3 + 6*q^4 + O(q^5)]
94
"""
95
if prec == None:
96
prec = self.prec()
97
if self.base_ring().characteristic() == 0:
98
B = self.__M.q_expansion_basis(prec)
99
else:
100
B = self.__M.q_integral_basis(prec)
101
R = self._q_expansion_ring()
102
return [R(f) for f in B]
103
104
def cuspidal_submodule(self):
105
r"""
106
Return the cuspidal subspace of this space.
107
108
EXAMPLE::
109
110
sage: C = CuspForms(7, 4, base_ring=CyclotomicField(5)) # indirect doctest
111
sage: type(C)
112
<class 'sage.modular.modform.cuspidal_submodule.CuspidalSubmodule_R_with_category'>
113
"""
114
return CuspidalSubmodule_R(self)
115
116
117
def change_ring(self, R):
118
r"""
119
Return this modular forms space with the base ring changed to the ring R.
120
121
EXAMPLE::
122
123
sage: chi = DirichletGroup(109, CyclotomicField(3)).0
124
sage: M9 = ModularForms(chi, 2, base_ring = CyclotomicField(9))
125
sage: M9.change_ring(CyclotomicField(15))
126
Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 over Cyclotomic Field of order 15 and degree 8
127
sage: M9.change_ring(QQ)
128
Traceback (most recent call last):
129
...
130
ValueError: Space cannot be defined over Rational Field
131
"""
132
if not R.has_coerce_map_from(self.__M.base_ring()):
133
raise ValueError, "Space cannot be defined over %s" % R
134
return ModularFormsAmbient_R(self.__M, R)
135
136