Path: blob/master/src/sage/groups/matrix_gps/homset.py
8815 views
"""1Matrix Group Homsets23AUTHORS:45- William Stein (2006-05-07): initial version67- Volker Braun (2013-1) port to new Parent, libGAP8"""910##############################################################################11# Copyright (C) 2006 David Joyner and William Stein <[email protected]>12#13# Distributed under the terms of the GNU General Public License (GPL)14#15# The full text of the GPL is available at:16#17# http://www.gnu.org/licenses/18##############################################################################1920from sage.groups.group_homset import GroupHomset_generic212223def is_MatrixGroupHomset(x):24r"""25Test whether ``x`` is a homset.2627EXAMPLES::2829sage: from sage.groups.matrix_gps.homset import is_MatrixGroupHomset30sage: is_MatrixGroupHomset(4)31False3233sage: F = GF(5)34sage: gens = [matrix(F,2,[1,2, -1, 1]), matrix(F,2, [1,1, 0,1])]35sage: G = MatrixGroup(gens)36sage: from sage.groups.matrix_gps.homset import MatrixGroupHomset37sage: M = MatrixGroupHomset(G, G)38sage: is_MatrixGroupHomset(M)39True40"""41return isinstance(x, MatrixGroupHomset)424344class MatrixGroupHomset(GroupHomset_generic):4546def __init__(self, G, H):47r"""48Return the homset of two matrix groups.4950INPUT:5152- ``G`` -- a matrix group.5354- ``H`` -- a matrix group.5556OUTPUT:5758The homset of two matrix groups.5960EXAMPLES::6162sage: F = GF(5)63sage: gens = [matrix(F,2,[1,2, -1, 1]), matrix(F,2, [1,1, 0,1])]64sage: G = MatrixGroup(gens)65sage: from sage.groups.matrix_gps.homset import MatrixGroupHomset66sage: MatrixGroupHomset(G, G)67Set of Homomorphisms from68Matrix group over Finite Field of size 5 with 2 generators (69[1 2] [1 1]70[4 1], [0 1]71) to Matrix group over Finite Field of size 5 with 2 generators (72[1 2] [1 1]73[4 1], [0 1]74)75"""76from sage.categories.groups import Groups77from sage.categories.homset import HomsetWithBase78HomsetWithBase.__init__(self, G, H, Groups(), G.base_ring())7980def __call__(self, im_gens, check=True):81"""82Return the homomorphism defined by images of generators.8384INPUT:8586- ``im_gens`` -- iterable, the list of images of the87generators of the domain8889- ``check`` -- bool (optional, default: ``True``), whether to90check if images define a valid homomorphism9192OUTPUT:9394Group homomorphism.9596EXAMPLES::9798sage: F = GF(5)99sage: gens = [matrix(F,2,[1,2, -1, 1]), matrix(F,2, [1,1, 0,1])]100sage: G = MatrixGroup(gens)101sage: from sage.groups.matrix_gps.homset import MatrixGroupHomset102sage: M = MatrixGroupHomset(G, G)103sage: M(gens)104Homomorphism : Matrix group over Finite Field of size 5 with 2 generators (105[1 2] [1 1]106[4 1], [0 1]107) --> Matrix group over Finite Field of size 5 with 2 generators (108[1 2] [1 1]109[4 1], [0 1]110)111"""112from sage.groups.matrix_gps.morphism import MatrixGroupMorphism_im_gens113try:114return MatrixGroupMorphism_im_gens(self, im_gens, check=check)115except (NotImplementedError, ValueError) as err:116raise TypeError('images do not define a group homomorphism')117118119120121