"""
Set of homomorphisms between two groups.
"""
from sage.categories.all import HomsetWithBase, Groups
import sage.rings.integer_ring
GROUPS = Groups()
def is_GroupHomset(H):
return isinstance(H, GroupHomset_generic)
def GroupHomset(G, H):
return RingHomset_generic(G, H)
class GroupHomset_generic(HomsetWithBase):
"""
This class will not work since morphism.GroupHomomorphism_coercion
is undefined and morphism.GroupHomomorphism_im_gens is undefined.
"""
def __init__(self, G, H):
HomsetWithBase.__init__(self, G, H, GROUPS, sage.rings.integer_ringer.ZZ)
def _repr_(self):
return "Set of Homomorphisms from %s to %s"%(self.domain(), self.codomain())
def __call__(self, im_gens, check=True):
"""
EXAMPLES:
"""
try:
return morphism.GroupHomomorphism_im_gens(self, im_gens, check=check)
except (NotImplementedError, ValueError), err:
raise TypeError, "images (=%s) do not define a valid homomorphism"%im_gens
def natural_map(self):
return morphism.GroupHomomorphism_coercion(self)