Ticket #7151: trac_7151_quaternion_group.patch

File trac_7151_quaternion_group.patch, 4.1 KB (added by rbeezer, 12 years ago)
  • sage/groups/perm_gps/all.py

    # HG changeset patch
    # User Rob Beezer <beezer@ups.edu>
    # Date 1254981026 25200
    # Node ID 8f94868f822167551b45627911c64e67295b33c8
    # Parent  e334f15125a3faecdecfefc6079a7ba4536955e8
    Trac 7151 - add quaternion group to named permutation groups
    
    diff -r e334f15125a3 -r 8f94868f8221 sage/groups/perm_gps/all.py
    a b  
    44from permgroup_named import (SymmetricGroup, AlternatingGroup,
    55                       DihedralGroup, CyclicPermutationGroup,
    66                       TransitiveGroup, PGL, PSL, PSp,PSU,PGU,
    7                        MathieuGroup, KleinFourGroup, SuzukiGroup)
     7                       MathieuGroup, KleinFourGroup, QuaternionGroup,
     8                       SuzukiGroup)
    89
    910from permgroup import  PermutationGroup, PermutationGroup_generic, PermutationGroup_subgroup, direct_product_permgroups
    1011
  • sage/groups/perm_gps/permgroup_named.py

    diff -r e334f15125a3 -r 8f94868f8221 sage/groups/perm_gps/permgroup_named.py
    a b  
    2222
    2323-- KleinFourGroup, subgroup of $S_4$ of order $4$ which is not $C_2 \times C_2$
    2424
     25-- QuaternionGroup, non-abelian group of order `8`, `\{\pm 1, \pm I, \pm J, \pm K\}`
     26
    2527-- PGL(n,q), projective general linear group of $n\times n$ matrices over
    2628             the finite field GF(q)
    2729
     
    383385            The Klein 4 group of order 4, as a permutation group
    384386        """
    385387        return 'The Klein 4 group of order 4, as a permutation group'
    386        
     388
     389class QuaternionGroup(PermutationGroup_generic):
     390    r"""
     391    The quaternion group of order 8.
     392
     393    OUTPUT:
     394        The quaternion group of order 8, as a permutation group
     395
     396    EXAMPLES:
     397
     398    The quaternion group is one of two non-abelian groups of order 8,
     399    the other being the dihedral group `D_4`.  One way to describe this
     400    group is with three generators, `I, J, K`, so the whole group is
     401    then given as the set `\{\pm 1, \pm I, \pm J, \pm K\}` with relations
     402    such as `I^2=J^2=K^2=-1`, `IJ=K` and `JI=-K`.
     403
     404    The examples below illustrate how to use this group in a similar
     405    manner, by testing some of these relations.  The representation used
     406    here is the same as the representation used more generally to prove
     407    Cayley's Theorem. ::
     408
     409        sage: Q = QuaternionGroup()
     410        sage: I = Q.gen(0)
     411        sage: J = Q.gen(1)
     412        sage: K = I*J
     413        sage: [I,J,K]
     414        [(1,2,5,6)(3,4,7,8), (1,3,5,7)(2,8,6,4), (1,8,5,4)(2,7,6,3)]
     415        sage: neg_one = I^2; neg_one
     416        (1,5)(2,6)(3,7)(4,8)
     417        sage: J^2 == neg_one and K^2 == neg_one
     418        True
     419        sage: J*I == neg_one*K
     420        True
     421        sage: Q.center().order() == 2
     422        True
     423        sage: neg_one in Q.center()
     424        True
     425
     426    TESTS:
     427    ::
     428        sage: Q == loads(dumps(Q))
     429        True
     430
     431    AUTHOR:
     432        -- Rob Beezer (2009-10-09)
     433    """
     434    def __init__(self):
     435        I = [(1,2,5,6),(3,4,7,8)]
     436        J = [(1,3,5,7),(2,8,6,4)]
     437        PermutationGroup_generic.__init__(self, [I,J])
     438
     439    def _repr_(self):
     440        r"""
     441        EXAMPLES:
     442            sage: Q=QuaternionGroup(); Q
     443            Quaternion group of order 8 as a permutation group
     444        """
     445        return "Quaternion group of order 8 as a permutation group"
    387446
    388447class DihedralGroup(PermutationGroup_generic):
    389448    def __init__(self, n):
     
    431490        TESTS:
    432491            sage: G == loads(dumps(G))
    433492            True
    434         """       
     493        """
    435494        n = Integer(n)
    436495        if n <= 0:
    437496            raise ValueError, "n must be positive"
     
    453512            gens = tuple([tuple(gen0),tuple(gen1)])
    454513
    455514        PermutationGroup_generic.__init__(self, gens)
    456        
     515
    457516    def _repr_(self):
    458517        """
    459518        EXAMPLES:
    460519            sage: G = DihedralGroup(5); G
    461             Dihedral group of order 10 as a permutation group       
     520            Dihedral group of order 10 as a permutation group
    462521        """
    463522        return "Dihedral group of order %s as a permutation group"%self.order()
    464523