Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'u/chapoton/12879' in 8.1.b2
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed Aug 20, 2017
2 parents effcedb + 1ea2824 commit e7132ee
Showing 1 changed file with 55 additions and 13 deletions.
68 changes: 55 additions & 13 deletions src/sage/modular/hecke/homspace.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
r"""
Hom spaces between Hecke modules
"""
from __future__ import absolute_import

#*****************************************************************************
# Copyright (C) 2005 William Stein <[email protected]>
#
Expand All @@ -17,10 +15,14 @@
#
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import absolute_import

from sage.matrix.constructor import matrix
from sage.matrix.matrix_space import MatrixSpace
from sage.categories.homset import HomsetWithBase
from .morphism import HeckeModuleMorphism_matrix
from .module import is_HeckeModule

import sage.categories.homset
from . import morphism
from . import module

def is_HeckeModuleHomspace(x):
r"""
Expand All @@ -36,12 +38,13 @@ def is_HeckeModuleHomspace(x):
"""
return isinstance(x, HeckeModuleHomspace)

class HeckeModuleHomspace(sage.categories.homset.HomsetWithBase):

class HeckeModuleHomspace(HomsetWithBase):
r"""
A space of homomorphisms between two objects in the category of Hecke
modules over a given base ring.
"""
def __init__(self, X, Y, category = None):
def __init__(self, X, Y, category=None):
r"""
Create the space of homomorphisms between X and Y, which must have the
same base ring.
Expand All @@ -58,13 +61,13 @@ def __init__(self, X, Y, category = None):
sage: M.Hom(M) == loads(dumps(M.Hom(M)))
True
"""
if not module.is_HeckeModule(X) or not module.is_HeckeModule(Y):
if not is_HeckeModule(X) or not is_HeckeModule(Y):
raise TypeError("X and Y must be Hecke modules")
if X.base_ring() != Y.base_ring():
raise TypeError("X and Y must have the same base ring")
if category is None:
category = X.category()
sage.categories.homset.HomsetWithBase.__init__(self, X, Y, category = category)
HomsetWithBase.__init__(self, X, Y, category=category)

def __call__(self, A, name=''):
r"""
Expand Down Expand Up @@ -116,7 +119,8 @@ def __call__(self, A, name=''):
sage: M = ModularSymbols(Gamma0(3),weight=22,sign=1)
sage: S = M.cuspidal_subspace()
sage: S.Hom(S)(S.gens())
sage: H = S.Hom(S)
sage: H(S.gens())
Hecke module morphism defined by the matrix
[1 0 0 0 0 0]
[0 1 0 0 0 0]
Expand All @@ -126,6 +130,11 @@ def __call__(self, A, name=''):
[0 0 0 0 0 1]
Domain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
Codomain: Modular Symbols subspace of dimension 6 of Modular Symbols space ...
sage: H.zero() in H
True
sage: H.one() in H
True
"""
try:
if A.parent() == self:
Expand All @@ -139,7 +148,40 @@ def __call__(self, A, name=''):
raise TypeError("unable to coerce A to self")
except AttributeError:
pass
if isinstance(A, (list, tuple)):
from sage.matrix.constructor import matrix
if A in self.base_ring():
dim_dom = self.domain().rank()
dim_codom = self.codomain().rank()
MS = MatrixSpace(self.base_ring(), dim_dom, dim_codom)
if self.domain() == self.codomain():
A = A * MS.identity_matrix()
elif A == 0:
A = MS.zero()
else:
raise ValueError('scalars do not coerce to this homspace')
elif isinstance(A, (list, tuple)):
A = matrix([self.codomain().coordinate_vector(f) for f in A])
return morphism.HeckeModuleMorphism_matrix(self, A, name)
return HeckeModuleMorphism_matrix(self, A, name)

def _an_element_(self):
"""
Return an element.
If the domain is equal to the codomain, this returns the
action of the Hecke operator of index 2. Otherwise, this returns zero.
EXAMPLES::
sage: M = ModularSymbols(Gamma0(2), weight=12, sign=1)
sage: S = M.cuspidal_subspace()
sage: S.Hom(S).an_element()
Hecke module morphism defined by the matrix
[ 260 -2108/135]
[ 4860 -284]
Domain: Modular Symbols subspace of dimension 2 of Modular Symbols space ...
Codomain: Modular Symbols subspace of dimension 2 of Modular Symbols space ...
"""
if self.domain() != self.codomain():
return self.zero()
else:
A = self.domain().hecke_operator(2).matrix()
return HeckeModuleMorphism_matrix(self, A)

0 comments on commit e7132ee

Please sign in to comment.