Ticket #3683: 10128.patch

File 10128.patch, 5.6 KB (added by wdj, 13 years ago)

This is a new patch based on sage 3.1.alpha0. Does not require other patches.

  • sage/groups/matrix_gps/matrix_group.py

    # HG changeset patch
    # User David Joyner <wdjoyner@gmail.com>
    # Date 1217731872 14400
    # Node ID a4b82d791cfbdc8cf726c64ee3438f3c9a4cf6ed
    # Parent  c4c599b04604d8042c9a9805986a7e4dc999e6c7
    this is based on sage 3.1.alpha0 and fixes the bug SImon found. - wdj
    
    diff -r c4c599b04604 -r a4b82d791cfb sage/groups/matrix_gps/matrix_group.py
    a b  
    77                    methods; examples (2006-03-15)
    88   William Stein (2006-12) -- rewrite
    99   DJ (2007-12) -- Added invariant_generators (with M Albrecht, S King)
     10   DJ (2008-08) -- Added module_composition_factors (interface to
     11                   GAP's meataxe implementation) and as_permutation_group
     12                   (returns isomorphic PermutationGroup).
    1013
    1114This class is designed for computing with matrix groups defined by a
    1215relatively (small) finite set of generating matrices.
     
    451454        return list(v)
    452455
    453456class MatrixGroup_gap_finite_field(MatrixGroup_gap):
     457    """
     458    Python class for matrix groups over a finite field.
     459    """
    454460    def order(self):
    455461        """
    456462        EXAMPLES:
     
    628634                raise ValueError, "each generator must be an invertible matrix but one is not:\n%s"%x
    629635        self._gensG = v
    630636        MatrixGroup_gap.__init__(self, M.nrows(), M.base_ring())
     637
     638    def as_permutation_group(self, method =None):
     639        r"""
     640        EXAMPLES:
     641            sage: F = GF(7); MS = MatrixSpace(F,2,2)
     642            sage: gens = [MS([[0,1],[-1,0]]),MS([[1,1],[2,3]])]
     643            sage: G = MatrixGroup(gens)
     644            sage: G.as_permutation_group()
     645            Permutation Group with generators [(1,2,4,8)(3,6,9,16)(5,10,15,25)(7,13,17,28)(11,19,26,37)(12,21,27,20)(14,24,29,18)(22,32,38,47)(23,34,39,33)(30,40,36,45)(31,42,46,41)(35,44,48,43), (1,3,7,14,4,9,17,29)(2,5,11,20,8,15,26,21)(6,12,22,33,16,27,38,34)(10,18,30,41,25,24,36,42)(13,23,35,40,28,39,48,45)(19,31,43,47,37,46,44,32)]
     646            sage: G.as_permutation_group(method="smaller")
     647            Permutation Group with generators [(1,2,4,8)(3,6,9,16)(5,10,15,25)(7,13,17,28)(11,19,26,37)(12,21,27,20)(14,24,29,18)(22,32,38,47)(23,34,39,33)(30,40,36,45)(31,42,46,41)(35,44,48,43), (1,3,7,14,4,9,17,29)(2,5,11,20,8,15,26,21)(6,12,22,33,16,27,38,34)(10,18,30,41,25,24,36,42)(13,23,35,40,28,39,48,45)(19,31,43,47,37,46,44,32)]
     648
     649        Sometimes the "smaller" option will return an isomorphic group of lower degree.
     650        """       
     651        from sage.groups.perm_gps.permgroup import PermutationGroup
     652        F = self.base_ring()
     653        if not(F.is_finite()):
     654            raise NotImplementedError, "Base ring must be finite."
     655        q = F.order()   
     656        gens = self.gens()
     657        n = self.degree()
     658        MS = MatrixSpace(F,n,n)
     659        mats = [] # initializing list of mats by which the gens act on self
     660        W = self.matrix_space().row_space()
     661        for g in gens:
     662            p = MS(g.matrix())
     663            m = p.rows()
     664            mats.append(m)
     665        mats_str = str(gap([[list(r) for r in m] for m in mats]))
     666        gap.eval("M:=GModuleByMats("+mats_str+", GF("+str(q)+"))")
     667        gap.eval("iso:=IsomorphismPermGroup(Group("+mats_str+"))")
     668        C = gap("Image( iso )")
     669        if method == "smallest":
     670            gap.eval("small:= SmallerDegreePermutationRepresentation( Image( iso ) );")
     671            C = gap("Image( small )")
     672        return PermutationGroup(C, from_group = True)
     673
     674    def module_composition_factors(self, method=None):
     675        r"""
     676        Returns a list of triples consisting of [base field, dimension, irreducibility],
     677        for each of the Meataxe composition factors modules. The method="verbose" option
     678        returns more information, but in Meataxe notation.
     679
     680        EXAMPLES:
     681            sage: F = GF(7); MS = MatrixSpace(F,2,2)
     682            sage: gens = [MS([[0,1],[-1,0]]),MS([[1,1],[2,3]])]
     683            sage: G = MatrixGroup(gens)
     684            sage: G.module_composition_factors()
     685            [[Finite Field of size 7, 2, True]]
     686
     687        Type "G.module_composition_factors(method='verbose')" to get
     688        a more verbose version.
     689
     690        For more on MeatAxe notation, see http://www.gap-system.org/Manuals/doc/htm/ref/CHAP067.htm
     691        """
     692        from sage.misc.sage_eval import sage_eval
     693        F = self.base_ring()
     694        if not(F.is_finite()):
     695            raise NotImplementedError, "Base ring must be finite."
     696        q = F.order()   
     697        gens = self.gens()
     698        n = self.degree()
     699        MS = MatrixSpace(F,n,n)
     700        mats = [] # initializing list of mats by which the gens act on self
     701        W = self.matrix_space().row_space()
     702        for g in gens:
     703            p = MS(g.matrix())
     704            m = p.rows()
     705            mats.append(m)
     706        mats_str = str(gap([[list(r) for r in m] for m in mats]))
     707        gap.eval("M:=GModuleByMats("+mats_str+", GF("+str(q)+"))")
     708        gap.eval("MCFs := MTX.CompositionFactors( M )")
     709        N = eval(gap.eval("Length(MCFs)"))
     710        if method == "verbose":
     711            print gap.eval('MCFs')+"\n"
     712        L = []
     713        for i in range(1,N+1):
     714            gap.eval("MCF := MCFs[%s]"%i)
     715            L = L + [[sage_eval(gap.eval("MCF.field")), eval(gap.eval("MCF.dimension")), sage_eval(gap.eval("MCF.IsIrreducible"))]] 
     716        return L
    631717
    632718    def gens(self):
    633719        """
     
    812898class MatrixGroup_gens_finite_field(MatrixGroup_gens, MatrixGroup_gap_finite_field):
    813899    pass
    814900
    815 
    816901##     def conjugacy_class_representatives_gap(self):
    817902##         """
    818903##         Wraps GAP Representative+ConjugactClasses but returns a list of