Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/modular/hecke/morphism.py
4057 views
1
"""
2
Morphisms of Hecke modules
3
4
AUTHORS:
5
6
- William Stein
7
"""
8
9
#*****************************************************************************
10
# Sage: System for Algebra and Geometry Experimentation
11
#
12
# Copyright (C) 2005 William Stein <[email protected]>
13
#
14
# Distributed under the terms of the GNU General Public License (GPL)
15
#
16
# This code is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
# General Public License for more details.
20
#
21
# The full text of the GPL is available at:
22
#
23
# http://www.gnu.org/licenses/
24
#*****************************************************************************
25
26
27
import sage.misc.misc as misc
28
from sage.modules.matrix_morphism import MatrixMorphism
29
from sage.categories.morphism import Morphism
30
31
# We also define other types of Hecke-module morphisms that aren't
32
# specified by a matrix. E.g., Hecke operators, or maybe morphisms on
33
# modular abelian varieties (which are specified by matrices, but on
34
# integral homology). All morphisms derive from HeckeModuleMorphism.
35
36
def is_HeckeModuleMorphism(x):
37
r"""
38
Return True if x is of type HeckeModuleMorphism.
39
40
EXAMPLES::
41
42
sage: sage.modular.hecke.morphism.is_HeckeModuleMorphism(ModularSymbols(6).hecke_operator(7).hecke_module_morphism())
43
True
44
"""
45
return isinstance(x, HeckeModuleMorphism)
46
47
def is_HeckeModuleMorphism_matrix(x):
48
"""
49
50
EXAMPLES::
51
52
sage: sage.modular.hecke.morphism.is_HeckeModuleMorphism_matrix(ModularSymbols(6).hecke_operator(7).matrix_form().hecke_module_morphism())
53
True
54
"""
55
return isinstance(x, HeckeModuleMorphism_matrix)
56
57
class HeckeModuleMorphism(Morphism):
58
r"""
59
Abstract base class for morphisms of Hecke modules.
60
"""
61
pass
62
63
class HeckeModuleMorphism_matrix(MatrixMorphism, HeckeModuleMorphism):
64
"""
65
Morphisms of Hecke modules when the morphism is given by a matrix.
66
67
Note that care is needed when composing morphisms, because morphisms in
68
Sage act on the left, but their matrices act on the right (!). So if F: A
69
-> B and G : B -> C are morphisms, the composition A -> C is G*F, but its
70
matrix is F.matrix() * G.matrix().
71
72
EXAMPLE::
73
74
sage: A = ModularForms(1, 4)
75
sage: B = ModularForms(1, 16)
76
sage: C = ModularForms(1, 28)
77
sage: F = A.Hom(B)(matrix(QQ,1,2,srange(1, 3)))
78
sage: G = B.Hom(C)(matrix(QQ,2,3,srange(1, 7)))
79
sage: G * F
80
Hecke module morphism defined by the matrix
81
[ 9 12 15]
82
Domain: Modular Forms space of dimension 1 for Modular Group SL(2,Z) ...
83
Codomain: Modular Forms space of dimension 3 for Modular Group SL(2,Z) ...
84
sage: F * G
85
Traceback (most recent call last):
86
...
87
TypeError: Incompatible composition of morphisms: domain of left morphism must be codomain of right.
88
"""
89
def __init__(self, parent, A, name=''):
90
"""
91
INPUT:
92
93
- ``parent`` - ModularSymbolsHomspace
94
95
- ``A`` - Matrix
96
97
- ``name`` - str (defaults to '') name of the morphism
98
(used for printing)
99
100
EXAMPLE::
101
102
sage: M = ModularSymbols(6)
103
sage: t = M.Hom(M)(matrix(QQ,3,3,srange(9)), name="spam"); t
104
Hecke module morphism spam defined by the matrix
105
[0 1 2]
106
[3 4 5]
107
[6 7 8]
108
Domain: Modular Symbols space of dimension 3 for Gamma_0(6) of weight ...
109
Codomain: Modular Symbols space of dimension 3 for Gamma_0(6) of weight ...
110
sage: t == loads(dumps(t))
111
True
112
"""
113
if not isinstance(name, str):
114
raise TypeError, "name must be a string"
115
self.__name = name
116
MatrixMorphism.__init__(self, parent, A)
117
118
def name(self, new=None):
119
r"""
120
Return the name of this operator, or set it to a new name.
121
122
EXAMPLES::
123
124
sage: M = ModularSymbols(6)
125
sage: t = M.Hom(M)(matrix(QQ,3,3,srange(9)), name="spam"); t
126
Hecke module morphism spam defined by ...
127
sage: t.name()
128
'spam'
129
sage: t.name("eggs"); t
130
Hecke module morphism eggs defined by ...
131
"""
132
if new is None:
133
return self.__name
134
self.__name = new
135
136
def _repr_(self):
137
r"""
138
String representation of self.
139
140
EXAMPLES::
141
142
sage: M = ModularSymbols(6)
143
sage: t = M.Hom(M)(matrix(QQ,3,3,srange(9))); t._repr_()
144
'Hecke module morphism defined by the matrix\n[0 1 2]\n[3 4 5]\n[6 7 8]\nDomain: Modular Symbols space of dimension 3 for Gamma_0(6) of weight ...\nCodomain: Modular Symbols space of dimension 3 for Gamma_0(6) of weight ...'
145
sage: t.name('spam'); t._repr_()
146
'Hecke module morphism spam defined by the matrix\n[0 1 2]\n[3 4 5]\n[6 7 8]\nDomain: Modular Symbols space of dimension 3 for Gamma_0(6) of weight ...\nCodomain: Modular Symbols space of dimension 3 for Gamma_0(6) of weight ...'
147
"""
148
name = self.__name
149
if name != '':
150
name += ' '
151
return "Hecke module morphism %sdefined by the matrix\n%s\nDomain: %s\nCodomain: %s"%(\
152
name, str(self.matrix()), misc.strunc(self.domain()), misc.strunc(self.codomain()))
153
154
# __mul__ method removed by David Loeffler 2009-04-14 as it is an exact duplicate of sage.modules.matrix_morphism.__mul__
155
156
157