Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/groups/group_homset.py
4058 views
1
"""
2
Set of homomorphisms between two groups.
3
4
"""
5
6
#*****************************************************************************
7
# Copyright (C) 2006 William Stein <[email protected]>
8
#
9
# Distributed under the terms of the GNU General Public License (GPL)
10
#
11
# http://www.gnu.org/licenses/
12
#*****************************************************************************
13
14
from sage.categories.all import HomsetWithBase, Groups
15
import sage.rings.integer_ring
16
17
GROUPS = Groups()
18
19
20
def is_GroupHomset(H):
21
return isinstance(H, GroupHomset_generic)
22
23
def GroupHomset(G, H):
24
return RingHomset_generic(G, H)
25
26
27
class GroupHomset_generic(HomsetWithBase):
28
"""
29
This class will not work since morphism.GroupHomomorphism_coercion
30
is undefined and morphism.GroupHomomorphism_im_gens is undefined.
31
"""
32
def __init__(self, G, H):
33
HomsetWithBase.__init__(self, G, H, GROUPS, sage.rings.integer_ringer.ZZ)
34
35
def _repr_(self):
36
return "Set of Homomorphisms from %s to %s"%(self.domain(), self.codomain())
37
38
def __call__(self, im_gens, check=True):
39
"""
40
EXAMPLES:
41
42
"""
43
try:
44
return morphism.GroupHomomorphism_im_gens(self, im_gens, check=check)
45
except (NotImplementedError, ValueError), err:
46
raise TypeError, "images (=%s) do not define a valid homomorphism"%im_gens
47
48
def natural_map(self):
49
return morphism.GroupHomomorphism_coercion(self)
50
51
52
53
54
55
56