Ticket #6669: trac-6669-2-matrix_hom.patch

File trac-6669-2-matrix_hom.patch, 1.5 KB (added by mraum, 12 years ago)

Patch with doctests.

  • sage/groups/matrix_gps/matrix_group.py

    diff -r 5bf36a37cd0c sage/groups/matrix_gps/matrix_group.py
    a b  
    225225            raise TypeError, "no way to coerce element to self."
    226226        return g
    227227
    228     def _Hom_(self, G, cat=None):
     228    def _Hom_(self, G, cat=None) :
     229        """
     230        EXAMPLES:
     231            sage: G = GL(3,7)
     232            sage: G.Hom(GL(4,7))
     233            Set of Homomorphisms from General Linear Group of degree 3 over Finite Field of size 7 to General Linear Group of degree 4 over Finite Field of size 7
     234            sage: G.Hom(ZZ)
     235            Set of Morphisms from General Linear Group of degree 3 over Finite Field of size 7 to Integer Ring in Category of groups
     236        """
    229237        if not (cat is None or (cat is G.category() and cat is self.category())):
    230238            raise NotImplementedError
    231         if not is_MatrixGroup(G):
    232             raise TypeError, "G (=%s) must be a matrix group."%G
    233         import homset
    234         return homset.MatrixGroupHomset(self, G)
     239       
     240        if is_MatrixGroup(G):
     241            import homset
     242            return homset.MatrixGroupHomset(self, G)
     243        else :
     244            from sage.categories.homset import Homset
     245            from sage.categories.category_types import Groups
     246
     247            return Homset(self, G, Groups(), False)
    235248
    236249    def hom(self, x):
    237250        v = Sequence(x)