Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/modular/modform/ambient.py
4056 views
1
# -*- coding: utf-8 -*-
2
r"""
3
Ambient Spaces of Modular Forms
4
5
EXAMPLES:
6
7
We compute a basis for the ambient space
8
`M_2(\Gamma_1(25),\chi)`, where `\chi` is
9
quadratic.
10
11
::
12
13
sage: chi = DirichletGroup(25,QQ).0; chi
14
Dirichlet character modulo 25 of conductor 5 mapping 2 |--> -1
15
sage: n = ModularForms(chi,2); n
16
Modular Forms space of dimension 6, character [-1] and weight 2 over Rational Field
17
sage: type(n)
18
<class 'sage.modular.modform.ambient_eps.ModularFormsAmbient_eps_with_category'>
19
20
Compute a basis::
21
22
sage: n.basis()
23
[
24
1 + O(q^6),
25
q + O(q^6),
26
q^2 + O(q^6),
27
q^3 + O(q^6),
28
q^4 + O(q^6),
29
q^5 + O(q^6)
30
]
31
32
Compute the same basis but to higher precision::
33
34
sage: n.set_precision(20)
35
sage: n.basis()
36
[
37
1 + 10*q^10 + 20*q^15 + O(q^20),
38
q + 5*q^6 + q^9 + 12*q^11 - 3*q^14 + 17*q^16 + 8*q^19 + O(q^20),
39
q^2 + 4*q^7 - q^8 + 8*q^12 + 2*q^13 + 10*q^17 - 5*q^18 + O(q^20),
40
q^3 + q^7 + 3*q^8 - q^12 + 5*q^13 + 3*q^17 + 6*q^18 + O(q^20),
41
q^4 - q^6 + 2*q^9 + 3*q^14 - 2*q^16 + 4*q^19 + O(q^20),
42
q^5 + q^10 + 2*q^15 + O(q^20)
43
]
44
45
TESTS::
46
47
sage: m = ModularForms(Gamma1(20),2,GF(7))
48
sage: loads(dumps(m)) == m
49
True
50
51
::
52
53
sage: m = ModularForms(GammaH(11,[4]), 2); m
54
Modular Forms space of dimension 2 for Congruence Subgroup Gamma_H(11) with H generated by [4] of weight 2 over Rational Field
55
sage: type(m)
56
<class 'sage.modular.modform.ambient_g1.ModularFormsAmbient_gH_Q_with_category'>
57
sage: m == loads(dumps(m))
58
True
59
"""
60
61
#########################################################################
62
# Copyright (C) 2006 William Stein <[email protected]>
63
#
64
# Distributed under the terms of the GNU General Public License (GPL)
65
#
66
# http://www.gnu.org/licenses/
67
#########################################################################
68
69
# system packages
70
71
# Sage packages
72
import sage.rings.all as rings
73
import sage.modular.arithgroup.all as arithgroup
74
import sage.modular.dirichlet as dirichlet
75
import sage.modular.hecke.all as hecke
76
import sage.modular.modsym.all as modsym
77
import sage.modules.free_module as free_module
78
import sage.rings.all as rings
79
80
from sage.structure.sequence import Sequence
81
82
83
import cuspidal_submodule
84
import defaults
85
import eisenstein_submodule
86
import eis_series
87
import space
88
import submodule
89
90
91
class ModularFormsAmbient(space.ModularFormsSpace,
92
hecke.AmbientHeckeModule):
93
"""
94
An ambient space of modular forms.
95
"""
96
def __init__(self, group, weight, base_ring, character=None):
97
"""
98
Create an ambient space of modular forms.
99
100
EXAMPLES::
101
102
sage: m = ModularForms(Gamma1(20),20); m
103
Modular Forms space of dimension 238 for Congruence Subgroup Gamma1(20) of weight 20 over Rational Field
104
sage: m.is_ambient()
105
True
106
"""
107
if not arithgroup.is_CongruenceSubgroup(group):
108
raise TypeError, 'group (=%s) must be a congruence subgroup'%group
109
weight = rings.Integer(weight)
110
111
if character is None and arithgroup.is_Gamma0(group):
112
character = dirichlet.TrivialCharacter(group.level(), base_ring)
113
114
space.ModularFormsSpace.__init__(self, group, weight, character, base_ring)
115
try:
116
d = self.dimension()
117
except NotImplementedError:
118
d = None
119
hecke.AmbientHeckeModule.__init__(self, base_ring, d, group.level(), weight)
120
121
def _repr_(self):
122
"""
123
Return string representation of self.
124
125
EXAMPLES::
126
127
sage: m = ModularForms(Gamma1(20),100); m._repr_()
128
'Modular Forms space of dimension 1198 for Congruence Subgroup Gamma1(20) of weight 100 over Rational Field'
129
130
The output of _repr_ is not affected by renaming the space::
131
132
sage: m.rename('A big modform space')
133
sage: m
134
A big modform space
135
sage: m._repr_()
136
'Modular Forms space of dimension 1198 for Congruence Subgroup Gamma1(20) of weight 100 over Rational Field'
137
"""
138
try:
139
d = self.dimension()
140
except NotImplementedError:
141
d = "(unknown)"
142
return "Modular Forms space of dimension %s for %s of weight %s over %s"%(
143
d, self.group(), self.weight(), self.base_ring())
144
145
def _submodule_class(self):
146
"""
147
Return the Python class of submodules of this modular forms space.
148
149
EXAMPLES::
150
151
sage: m = ModularForms(Gamma0(20),2)
152
sage: m._submodule_class()
153
<class 'sage.modular.modform.submodule.ModularFormsSubmodule'>
154
"""
155
return submodule.ModularFormsSubmodule
156
157
def change_ring(self, base_ring):
158
"""
159
Change the base ring of this space of modular forms.
160
161
INPUT:
162
163
164
- ``R`` - ring
165
166
167
EXAMPLES::
168
169
sage: M = ModularForms(Gamma0(37),2)
170
sage: M.basis()
171
[
172
q + q^3 - 2*q^4 + O(q^6),
173
q^2 + 2*q^3 - 2*q^4 + q^5 + O(q^6),
174
1 + 2/3*q + 2*q^2 + 8/3*q^3 + 14/3*q^4 + 4*q^5 + O(q^6)
175
]
176
177
The basis after changing the base ring is the reduction modulo
178
`3` of an integral basis.
179
180
::
181
182
sage: M3 = M.change_ring(GF(3))
183
sage: M3.basis()
184
[
185
1 + q^3 + q^4 + 2*q^5 + O(q^6),
186
q + q^3 + q^4 + O(q^6),
187
q^2 + 2*q^3 + q^4 + q^5 + O(q^6)
188
]
189
"""
190
import constructor
191
M = constructor.ModularForms(self.group(), self.weight(), base_ring, prec=self.prec())
192
return M
193
194
def dimension(self):
195
"""
196
Return the dimension of this ambient space of modular forms,
197
computed using a dimension formula (so it should be reasonably
198
fast).
199
200
EXAMPLES::
201
202
sage: m = ModularForms(Gamma1(20),20)
203
sage: m.dimension()
204
238
205
"""
206
try:
207
return self.__dimension
208
except AttributeError:
209
self.__dimension = self._dim_eisenstein() + self._dim_cuspidal()
210
return self.__dimension
211
212
def hecke_module_of_level(self, N):
213
r"""
214
Return the Hecke module of level N corresponding to self, which is the
215
domain or codomain of a degeneracy map from self. Here N must be either
216
a divisor or a multiple of the level of self.
217
218
EXAMPLES::
219
220
sage: ModularForms(25, 6).hecke_module_of_level(5)
221
Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(5) of weight 6 over Rational Field
222
sage: ModularForms(Gamma1(4), 3).hecke_module_of_level(8)
223
Modular Forms space of dimension 7 for Congruence Subgroup Gamma1(8) of weight 3 over Rational Field
224
sage: ModularForms(Gamma1(4), 3).hecke_module_of_level(9)
225
Traceback (most recent call last):
226
...
227
ValueError: N (=9) must be a divisor or a multiple of the level of self (=4)
228
"""
229
if not (N % self.level() == 0 or self.level() % N == 0):
230
raise ValueError, "N (=%s) must be a divisor or a multiple of the level of self (=%s)" % (N, self.level())
231
import constructor
232
return constructor.ModularForms(self.group()._new_group_from_level(N), self.weight(), self.base_ring(), prec=self.prec())
233
234
def _degeneracy_raising_matrix(self, M, t):
235
r"""
236
Calculate the matrix of the degeneracy map from self to M corresponding
237
to `f(q) \mapsto f(q^t)`. Here the level of M should be a multiple of
238
the level of self, and t should divide the quotient.
239
240
EXAMPLE::
241
242
sage: ModularForms(22, 2)._degeneracy_raising_matrix(ModularForms(44, 2), 1)
243
[ 1 0 -1 -2 0 0 0 0 0]
244
[ 0 1 0 -2 0 0 0 0 0]
245
[ 0 0 0 0 1 0 0 0 24]
246
[ 0 0 0 0 0 1 0 -2 21]
247
[ 0 0 0 0 0 0 1 3 -10]
248
sage: ModularForms(22, 2)._degeneracy_raising_matrix(ModularForms(44, 2), 2)
249
[0 1 0 0 0 0 0 0 0]
250
[0 0 0 1 0 0 0 0 0]
251
[0 0 0 0 1 0 0 0 0]
252
[0 0 0 0 0 0 1 0 0]
253
[0 0 0 0 0 0 0 1 0]
254
"""
255
from sage.matrix.matrix_space import MatrixSpace
256
A = MatrixSpace(self.base_ring(), self.dimension(), M.dimension())
257
d = M.sturm_bound() + 1
258
q = self.an_element().qexp(d).parent().gen()
259
im_gens = []
260
for x in self.basis():
261
fq = x.qexp(d)
262
fqt = fq(q**t).add_bigoh(d) # silly workaround for #5367
263
im_gens.append(M(fqt))
264
return A([M.coordinate_vector(u) for u in im_gens])
265
266
def rank(self):
267
r"""
268
This is a synonym for ``self.dimension()``.
269
270
EXAMPLES::
271
272
sage: m = ModularForms(Gamma0(20),4)
273
sage: m.rank()
274
12
275
sage: m.dimension()
276
12
277
"""
278
return self.dimension()
279
280
def ambient_space(self):
281
"""
282
Return the ambient space that contains this ambient space. This is,
283
of course, just this space again.
284
285
EXAMPLES::
286
287
sage: m = ModularForms(Gamma0(3),30)
288
sage: m.ambient_space() is m
289
True
290
"""
291
return self
292
293
def is_ambient(self):
294
"""
295
Return True if this an ambient space of modular forms.
296
297
This is an ambient space, so this function always returns True.
298
299
EXAMPLES::
300
301
sage: ModularForms(11).is_ambient()
302
True
303
sage: CuspForms(11).is_ambient()
304
False
305
"""
306
return True
307
308
def modular_symbols(self, sign=0):
309
"""
310
Return the corresponding space of modular symbols with the given
311
sign.
312
313
EXAMPLES::
314
315
sage: S = ModularForms(11,2)
316
sage: S.modular_symbols()
317
Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field
318
sage: S.modular_symbols(sign=1)
319
Modular Symbols space of dimension 2 for Gamma_0(11) of weight 2 with sign 1 over Rational Field
320
sage: S.modular_symbols(sign=-1)
321
Modular Symbols space of dimension 1 for Gamma_0(11) of weight 2 with sign -1 over Rational Field
322
323
::
324
325
sage: ModularForms(1,12).modular_symbols()
326
Modular Symbols space of dimension 3 for Gamma_0(1) of weight 12 with sign 0 over Rational Field
327
"""
328
sign = rings.Integer(sign)
329
try:
330
return self.__modular_symbols[sign]
331
except AttributeError:
332
self.__modular_symbols = {}
333
except KeyError:
334
pass
335
M = modsym.ModularSymbols(group = self.group(),
336
weight = self.weight(),
337
sign = sign,
338
base_ring = self.base_ring())
339
self.__modular_symbols[sign] = M
340
return M
341
342
def module(self):
343
"""
344
Return the underlying free module corresponding to this space
345
of modular forms.
346
347
If the dimension of self can be computed reasonably quickly,
348
then this function returns a free module (viewed as a tuple
349
space) of the same dimension as self over the same base ring.
350
Otherwise, the dimension of self.module() may be smaller. For
351
example, in the case of weight 1 forms, in some cases the
352
dimension can't easily be computed so self.module() is of
353
smaller dimension.
354
355
EXAMPLES::
356
357
sage: m = ModularForms(Gamma1(13),10)
358
sage: m.free_module()
359
Vector space of dimension 69 over Rational Field
360
sage: ModularForms(Gamma1(13),4, GF(49,'b')).free_module()
361
Vector space of dimension 27 over Finite Field in b of size 7^2
362
363
Note that in the following example the dimension can't be
364
(quickly) computed, so M.module() returns a space of different
365
dimension than M::
366
367
sage: M = ModularForms(Gamma1(57), 1); M
368
Modular Forms space of dimension (unknown) for Congruence ...
369
sage: M.module()
370
Vector space of dimension 36 over Rational Field
371
sage: M.basis()
372
Traceback (most recent call last):
373
...
374
NotImplementedError: Computation of dimensions of weight 1 cusp forms spaces not implemented in general
375
"""
376
if hasattr(self, "__module"): return self.__module
377
try:
378
d = self.dimension()
379
except NotImplementedError:
380
381
# This only comes up for weight 1 forms, where we want to be able
382
# to embed Eisenstein forms (which we know how to calculate) into
383
# some suitable ambient space. Because we can't even calculate the
384
# dimension of the weight 1 cusp forms in general, we just map
385
# Eisenstein series onto basis vectors, and then make it clear by
386
# raising errors in appropriate places that some cusp forms might
387
# exist but we don't know how to compute them.
388
389
d = self._dim_eisenstein()
390
self.__module = free_module.VectorSpace(self.base_ring(), d)
391
return self.__module
392
393
# free_module -- stupid thing: there are functions in classes
394
# ModularFormsSpace and HeckeModule that both do much the same
395
# thing, and one has to override both of them!
396
def free_module(self):
397
"""
398
Return the free module underlying this space of modular forms.
399
400
EXAMPLES::
401
402
sage: ModularForms(37).free_module()
403
Vector space of dimension 3 over Rational Field
404
"""
405
return self.module()
406
407
def prec(self, new_prec=None):
408
"""
409
Set or get default initial precision for printing modular forms.
410
411
INPUT:
412
413
414
- ``new_prec`` - positive integer (default: None)
415
416
417
OUTPUT: if new_prec is None, returns the current precision.
418
419
EXAMPLES::
420
421
sage: M = ModularForms(1,12, prec=3)
422
sage: M.prec()
423
3
424
425
::
426
427
sage: M.basis()
428
[
429
q - 24*q^2 + O(q^3),
430
1 + 65520/691*q + 134250480/691*q^2 + O(q^3)
431
]
432
433
::
434
435
sage: M.prec(5)
436
5
437
sage: M.basis()
438
[
439
q - 24*q^2 + 252*q^3 - 1472*q^4 + O(q^5),
440
1 + 65520/691*q + 134250480/691*q^2 + 11606736960/691*q^3 + 274945048560/691*q^4 + O(q^5)
441
]
442
"""
443
if new_prec:
444
self.__prec = new_prec
445
try:
446
return self.__prec
447
except AttributeError:
448
self.__prec = defaults.DEFAULT_PRECISION
449
return self.__prec
450
451
def set_precision(self, n):
452
"""
453
Set the default precision for displaying elements of this space.
454
455
EXAMPLES::
456
457
sage: m = ModularForms(Gamma1(5),2)
458
sage: m.set_precision(10)
459
sage: m.basis()
460
[
461
1 + 60*q^3 - 120*q^4 + 240*q^5 - 300*q^6 + 300*q^7 - 180*q^9 + O(q^10),
462
q + 6*q^3 - 9*q^4 + 27*q^5 - 28*q^6 + 30*q^7 - 11*q^9 + O(q^10),
463
q^2 - 4*q^3 + 12*q^4 - 22*q^5 + 30*q^6 - 24*q^7 + 5*q^8 + 18*q^9 + O(q^10)
464
]
465
sage: m.set_precision(5)
466
sage: m.basis()
467
[
468
1 + 60*q^3 - 120*q^4 + O(q^5),
469
q + 6*q^3 - 9*q^4 + O(q^5),
470
q^2 - 4*q^3 + 12*q^4 + O(q^5)
471
]
472
"""
473
if n < 0:
474
raise ValueError, "n (=%s) must be >= 0"%n
475
self.__prec = rings.Integer(n)
476
477
####################################################################
478
# Computation of Special Submodules
479
####################################################################
480
def cuspidal_submodule(self):
481
"""
482
Return the cuspidal submodule of this ambient module.
483
484
EXAMPLES::
485
486
sage: ModularForms(Gamma1(13)).cuspidal_submodule()
487
Cuspidal subspace of dimension 2 of Modular Forms space of dimension 13 for
488
Congruence Subgroup Gamma1(13) of weight 2 over Rational Field
489
"""
490
try:
491
return self.__cuspidal_submodule
492
except AttributeError:
493
self.__cuspidal_submodule = cuspidal_submodule.CuspidalSubmodule(self)
494
return self.__cuspidal_submodule
495
496
def eisenstein_submodule(self):
497
"""
498
Return the Eisenstein submodule of this ambient module.
499
500
EXAMPLES::
501
502
sage: m = ModularForms(Gamma1(13),2); m
503
Modular Forms space of dimension 13 for Congruence Subgroup Gamma1(13) of weight 2 over Rational Field
504
sage: m.eisenstein_submodule()
505
Eisenstein subspace of dimension 11 of Modular Forms space of dimension 13 for Congruence Subgroup Gamma1(13) of weight 2 over Rational Field
506
"""
507
try:
508
return self.__eisenstein_submodule
509
except AttributeError:
510
self.__eisenstein_submodule = eisenstein_submodule.EisensteinSubmodule(self)
511
return self.__eisenstein_submodule
512
513
def new_submodule(self, p=None):
514
"""
515
Return the new or `p`-new submodule of this ambient
516
module.
517
518
INPUT:
519
520
521
- ``p`` - (default: None), if specified return only
522
the `p`-new submodule.
523
524
525
EXAMPLES::
526
527
sage: m = ModularForms(Gamma0(33),2); m
528
Modular Forms space of dimension 6 for Congruence Subgroup Gamma0(33) of weight 2 over Rational Field
529
sage: m.new_submodule()
530
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 6 for Congruence Subgroup Gamma0(33) of weight 2 over Rational Field
531
532
Another example::
533
534
sage: M = ModularForms(17,4)
535
sage: N = M.new_subspace(); N
536
Modular Forms subspace of dimension 4 of Modular Forms space of dimension 6 for Congruence Subgroup Gamma0(17) of weight 4 over Rational Field
537
sage: N.basis()
538
[
539
q + 2*q^5 + O(q^6),
540
q^2 - 3/2*q^5 + O(q^6),
541
q^3 + O(q^6),
542
q^4 - 1/2*q^5 + O(q^6)
543
]
544
545
::
546
547
sage: ModularForms(12,4).new_submodule()
548
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 9 for Congruence Subgroup Gamma0(12) of weight 4 over Rational Field
549
550
Unfortunately (TODO) - `p`-new submodules aren't yet
551
implemented::
552
553
sage: m.new_submodule(3) # not implemented
554
Traceback (most recent call last):
555
...
556
NotImplementedError
557
sage: m.new_submodule(11) # not implemented
558
Traceback (most recent call last):
559
...
560
NotImplementedError
561
"""
562
try:
563
return self.__new_submodule[p]
564
except AttributeError:
565
self.__new_submodule = {}
566
except KeyError:
567
pass
568
if not p is None:
569
p = rings.Integer(p)
570
if not p.is_prime():
571
raise ValueError, "p (=%s) must be a prime or None."%p
572
M = self.cuspidal_submodule().new_submodule(p) + self.eisenstein_submodule().new_submodule(p)
573
self.__new_submodule[p] = M
574
return M
575
576
def _q_expansion(self, element, prec):
577
r"""
578
Return the q-expansion of a particular element of this space of
579
modular forms, where the element should be a vector, list, or tuple
580
(not a ModularFormElement). Here element should have length =
581
self.dimension(). If element = [ a_i ] and self.basis() = [ v_i
582
], then we return `\sum a_i v_i`.
583
584
INPUT:
585
586
587
- ``element`` - vector, list or tuple
588
589
- ``prec`` - desired precision of q-expansion
590
591
592
EXAMPLES::
593
594
sage: m = ModularForms(Gamma0(23),2); m
595
Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(23) of weight 2 over Rational Field
596
sage: m.basis()
597
[
598
q - q^3 - q^4 + O(q^6),
599
q^2 - 2*q^3 - q^4 + 2*q^5 + O(q^6),
600
1 + 12/11*q + 36/11*q^2 + 48/11*q^3 + 84/11*q^4 + 72/11*q^5 + O(q^6)
601
]
602
sage: m._q_expansion([1,2,0], 5)
603
q + 2*q^2 - 5*q^3 - 3*q^4 + O(q^5)
604
"""
605
B = self.q_expansion_basis(prec)
606
f = self._q_expansion_zero()
607
for i in range(len(element)):
608
if element[i]:
609
f += element[i] * B[i]
610
return f
611
612
613
####################################################################
614
# Computations of Dimensions
615
####################################################################
616
def _dim_cuspidal(self):
617
"""
618
Return the dimension of the cuspidal subspace of this ambient
619
modular forms space, computed using a dimension formula.
620
621
EXAMPLES::
622
623
sage: m = ModularForms(GammaH(11,[4]), 2); m
624
Modular Forms space of dimension 2 for Congruence Subgroup Gamma_H(11) with H generated by [4] of weight 2 over Rational Field
625
sage: m._dim_cuspidal()
626
1
627
"""
628
try:
629
return self.__the_dim_cuspidal
630
except AttributeError:
631
if arithgroup.is_Gamma1(self.group()) and self.character() is not None:
632
self.__the_dim_cuspidal = self.group().dimension_cusp_forms(self.weight(), self.character())
633
else:
634
self.__the_dim_cuspidal = self.group().dimension_cusp_forms(self.weight())
635
return self.__the_dim_cuspidal
636
637
def _dim_eisenstein(self):
638
"""
639
Return the dimension of the Eisenstein subspace of this modular
640
symbols space, computed using a dimension formula.
641
642
EXAMPLES::
643
644
sage: m = ModularForms(GammaH(13,[4]), 2); m
645
Modular Forms space of dimension 3 for Congruence Subgroup Gamma_H(13) with H generated by [4] of weight 2 over Rational Field
646
sage: m._dim_eisenstein()
647
3
648
"""
649
try:
650
return self.__the_dim_eisenstein
651
except AttributeError:
652
if self.weight() == 1:
653
self.__the_dim_eisenstein = len(self.eisenstein_params())
654
else:
655
if arithgroup.is_Gamma1(self.group()) and self.character() is not None:
656
self.__the_dim_eisenstein = self.group().dimension_eis(self.weight(), self.character())
657
else:
658
self.__the_dim_eisenstein = self.group().dimension_eis(self.weight())
659
return self.__the_dim_eisenstein
660
661
def _dim_new_cuspidal(self):
662
"""
663
Return the dimension of the new cuspidal subspace, computed using
664
dimension formulas.
665
666
EXAMPLES::
667
668
sage: m = ModularForms(GammaH(11,[2]), 2); m._dim_new_cuspidal()
669
1
670
"""
671
try:
672
return self.__the_dim_new_cuspidal
673
except AttributeError:
674
if arithgroup.is_Gamma1(self.group()) and self.character() is not None:
675
self.__the_dim_new_cuspidal = self.group().dimension_new_cusp_forms(self.weight(), self.character())
676
else:
677
self.__the_dim_new_cuspidal = self.group().dimension_new_cusp_forms(self.weight())
678
return self.__the_dim_new_cuspidal
679
680
def _dim_new_eisenstein(self):
681
"""
682
Compute the dimension of the Eisenstein submodule.
683
684
EXAMPLES::
685
686
sage: m = ModularForms(Gamma0(11), 4)
687
sage: m._dim_new_eisenstein()
688
0
689
sage: m = ModularForms(Gamma0(11), 2)
690
sage: m._dim_new_eisenstein()
691
1
692
"""
693
try:
694
return self.__the_dim_new_eisenstein
695
except AttributeError:
696
if arithgroup.is_Gamma0(self.group()) and self.weight() == 2:
697
if rings.is_prime(self.level()):
698
d = 1
699
else:
700
d = 0
701
else:
702
E = self.eisenstein_series()
703
d = len([g for g in E if g.new_level() == self.level()])
704
self.__the_dim_new_eisenstein = d
705
return self.__the_dim_new_eisenstein
706
707
708
####################################################################
709
# Computations of all Eisenstein series in self
710
####################################################################
711
712
def eisenstein_params(self):
713
"""
714
Return parameters that define all Eisenstein series in self.
715
716
OUTPUT: an immutable Sequence
717
718
EXAMPLES::
719
720
sage: m = ModularForms(Gamma0(22), 2)
721
sage: v = m.eisenstein_params(); v
722
[(Dirichlet character modulo 22 of conductor 1 mapping 13 |--> 1, Dirichlet character modulo 22 of conductor 1 mapping 13 |--> 1, 2), (Dirichlet character modulo 22 of conductor 1 mapping 13 |--> 1, Dirichlet character modulo 22 of conductor 1 mapping 13 |--> 1, 11), (Dirichlet character modulo 22 of conductor 1 mapping 13 |--> 1, Dirichlet character modulo 22 of conductor 1 mapping 13 |--> 1, 22)]
723
sage: type(v)
724
<class 'sage.structure.sequence.Sequence_generic'>
725
"""
726
try:
727
return self.__eisenstein_params
728
except AttributeError:
729
eps = self.character()
730
if eps == None:
731
if arithgroup.is_Gamma1(self.group()):
732
eps = self.level()
733
else:
734
raise NotImplementedError
735
params = eis_series.compute_eisenstein_params(eps, self.weight())
736
self.__eisenstein_params = Sequence(params, immutable=True)
737
return self.__eisenstein_params
738
739
def eisenstein_series(self):
740
"""
741
Return all Eisenstein series associated to this space.
742
743
::
744
745
sage: ModularForms(27,2).eisenstein_series()
746
[
747
q^3 + O(q^6),
748
q - 3*q^2 + 7*q^4 - 6*q^5 + O(q^6),
749
1/12 + q + 3*q^2 + q^3 + 7*q^4 + 6*q^5 + O(q^6),
750
1/3 + q + 3*q^2 + 4*q^3 + 7*q^4 + 6*q^5 + O(q^6),
751
13/12 + q + 3*q^2 + 4*q^3 + 7*q^4 + 6*q^5 + O(q^6)
752
]
753
754
::
755
756
sage: ModularForms(Gamma1(5),3).eisenstein_series()
757
[
758
-1/5*zeta4 - 2/5 + q + (4*zeta4 + 1)*q^2 + (-9*zeta4 + 1)*q^3 + (4*zeta4 - 15)*q^4 + q^5 + O(q^6),
759
q + (zeta4 + 4)*q^2 + (-zeta4 + 9)*q^3 + (4*zeta4 + 15)*q^4 + 25*q^5 + O(q^6),
760
1/5*zeta4 - 2/5 + q + (-4*zeta4 + 1)*q^2 + (9*zeta4 + 1)*q^3 + (-4*zeta4 - 15)*q^4 + q^5 + O(q^6),
761
q + (-zeta4 + 4)*q^2 + (zeta4 + 9)*q^3 + (-4*zeta4 + 15)*q^4 + 25*q^5 + O(q^6)
762
]
763
764
::
765
766
sage: eps = DirichletGroup(13).0^2
767
sage: ModularForms(eps,2).eisenstein_series()
768
[
769
-7/13*zeta6 - 11/13 + q + (2*zeta6 + 1)*q^2 + (-3*zeta6 + 1)*q^3 + (6*zeta6 - 3)*q^4 - 4*q^5 + O(q^6),
770
q + (zeta6 + 2)*q^2 + (-zeta6 + 3)*q^3 + (3*zeta6 + 3)*q^4 + 4*q^5 + O(q^6)
771
]
772
"""
773
return self.eisenstein_submodule().eisenstein_series()
774
775
def _compute_q_expansion_basis(self, prec):
776
"""
777
EXAMPLES::
778
779
sage: m = ModularForms(11,4)
780
sage: m._compute_q_expansion_basis(5)
781
[q + 3*q^3 - 6*q^4 + O(q^5), q^2 - 4*q^3 + 2*q^4 + O(q^5), 1 + O(q^5), q + 9*q^2 + 28*q^3 + 73*q^4 + O(q^5)]
782
"""
783
S = self.cuspidal_submodule()
784
E = self.eisenstein_submodule()
785
B_S = S._compute_q_expansion_basis(prec)
786
B_E = E._compute_q_expansion_basis(prec)
787
return B_S + B_E
788
789
def _compute_hecke_matrix(self, n):
790
"""
791
Compute the matrix of the Hecke operator T_n acting on self.
792
793
NOTE:
794
795
If self is a level 1 space, the much faster Victor Miller basis
796
is used for this computation.
797
798
EXAMPLES::
799
800
sage: M = ModularForms(11, 2)
801
sage: M._compute_hecke_matrix(6)
802
[ 2 0]
803
[ 0 12]
804
805
TESTS:
806
807
The following Hecke matrix is 43x43 with very large integer entries.
808
We test it indirectly by computing the product and the sum of its
809
eigenvalues, and reducing these two integers modulo all the primes
810
less than 100::
811
812
sage: M = ModularForms(1, 512)
813
sage: t = M._compute_hecke_matrix(5) # long time (2s)
814
sage: f = t.charpoly() # long time (4s)
815
sage: [f[0]%p for p in prime_range(100)] # long time (0s, depends on above)
816
[0, 0, 0, 0, 1, 9, 2, 7, 0, 0, 0, 0, 1, 12, 9, 16, 37, 0, 21, 11, 70, 22, 0, 58, 76]
817
sage: [f[42]%p for p in prime_range(100)] # long time (0s, depends on above)
818
[0, 0, 4, 0, 10, 4, 4, 8, 12, 1, 23, 13, 10, 27, 20, 13, 16, 59, 53, 41, 11, 13, 12, 6, 82]
819
"""
820
if self.level() == 1:
821
k = self.weight()
822
d = self.dimension()
823
from sage.modular.all import victor_miller_basis, hecke_operator_on_basis
824
vmb = victor_miller_basis(k, prec=d*n+1)
825
return hecke_operator_on_basis(vmb, n, k)
826
else:
827
return space.ModularFormsSpace._compute_hecke_matrix(self, n)
828
829
def _compute_hecke_matrix_prime_power(self, p, r):
830
r"""
831
Compute the Hecke matrix `T_{p^r}`, where `p` is prime and `r \ge 2`.
832
833
This is an internal method. End users are encouraged to use the
834
method hecke_matrix() instead.
835
836
TESTS:
837
838
sage: M = ModularForms(1, 12)
839
sage: M._compute_hecke_matrix_prime_power(5, 3)
840
[ 116415324211120654296876 11038396588040733750558720]
841
[ 0 -359001100500]
842
sage: delta_qexp(126)[125]
843
-359001100500
844
sage: eisenstein_series_qexp(12, 126)[125]
845
116415324211120654296876
846
"""
847
if self.level() == 1:
848
return self._compute_hecke_matrix(p**r)
849
else:
850
return space.ModularFormsSpace._compute_hecke_matrix_prime_power(self, p, r)
851
852
853