Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/modular/modsym/hecke_operator.py
4056 views
1
##########################################################################
2
#
3
# Copyright (C) 2008 William Stein <[email protected]>
4
#
5
# Distributed under the terms of the GNU General Public License (GPL)
6
#
7
# http://www.gnu.org/licenses/
8
#
9
##########################################################################
10
11
12
import sage.modular.hecke.hecke_operator
13
from sage.rings.arith import is_prime
14
import heilbronn
15
16
class HeckeOperator(sage.modular.hecke.hecke_operator.HeckeOperator):
17
def apply_sparse(self, x):
18
"""
19
Return the image of x under self. If x is not in self.domain(),
20
raise a TypeError.
21
22
EXAMPLES:
23
sage: M = ModularSymbols(17,4,-1)
24
sage: T = M.hecke_operator(4)
25
sage: T.apply_sparse(M.0)
26
64*[X^2,(1,8)] + 24*[X^2,(1,10)] - 9*[X^2,(1,13)] + 37*[X^2,(1,16)]
27
sage: [ T.apply_sparse(x) == T.hecke_module_morphism()(x) for x in M.basis() ]
28
[True, True, True, True]
29
sage: N = ModularSymbols(17,4,1)
30
sage: T.apply_sparse(N.0)
31
Traceback (most recent call last):
32
...
33
TypeError: x (=[X^2,(0,1)]) must be in Modular Symbols space of dimension 4 for Gamma_0(17) of weight 4 with sign -1 over Rational Field
34
"""
35
if x not in self.domain():
36
raise TypeError, "x (=%s) must be in %s"%(x, self.domain())
37
38
# old version just to check for correctness
39
#return self.hecke_module_morphism()(x)
40
41
p = self.index()
42
if is_prime(p):
43
H = heilbronn.HeilbronnCremona(p)
44
else:
45
H = heilbronn.HeilbronnMerel(p)
46
47
M = self.parent().module()
48
mod2term = M._mod2term
49
syms = M.manin_symbols()
50
K = M.base_ring()
51
R = M.manin_gens_to_basis()
52
53
W = R.new_matrix(nrows=1, ncols = R.nrows())
54
55
B = M.manin_basis()
56
57
#from sage.all import cputime
58
#t = cputime()
59
v = x.element()
60
for i in v.nonzero_positions():
61
for h in H:
62
entries = syms.apply(B[i], h)
63
for k, w in entries:
64
f, s = mod2term[k]
65
if s:
66
W[0,f] += s*K(w)*v[i]
67
68
#print 'sym', cputime(t)
69
#t = cputime()
70
ans = M( v.parent()((W * R).row(0)) )
71
#print 'mul', cputime(t)
72
#print 'density: ', len(W.nonzero_positions())/(W.nrows()*float(W.ncols()))
73
74
return ans
75
76
77