# 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 from permgroup_named import (SymmetricGroup, AlternatingGroup, DihedralGroup, CyclicPermutationGroup, TransitiveGroup, PGL, PSL, PSp,PSU,PGU, MathieuGroup, KleinFourGroup, SuzukiGroup) MathieuGroup, KleinFourGroup, QuaternionGroup, SuzukiGroup) from permgroup import  PermutationGroup, PermutationGroup_generic, PermutationGroup_subgroup, direct_product_permgroups
• ## sage/groups/perm_gps/permgroup_named.py

diff -r e334f15125a3 -r 8f94868f8221 sage/groups/perm_gps/permgroup_named.py
 a -- KleinFourGroup, subgroup of $S_4$ of order $4$ which is not $C_2 \times C_2$ -- QuaternionGroup, non-abelian group of order 8, \{\pm 1, \pm I, \pm J, \pm K\} -- PGL(n,q), projective general linear group of $n\times n$ matrices over the finite field GF(q) The Klein 4 group of order 4, as a permutation group """ return 'The Klein 4 group of order 4, as a permutation group' class QuaternionGroup(PermutationGroup_generic): r""" The quaternion group of order 8. OUTPUT: The quaternion group of order 8, as a permutation group EXAMPLES: The quaternion group is one of two non-abelian groups of order 8, the other being the dihedral group D_4.  One way to describe this group is with three generators, I, J, K, so the whole group is then given as the set \{\pm 1, \pm I, \pm J, \pm K\} with relations such as I^2=J^2=K^2=-1, IJ=K and JI=-K. The examples below illustrate how to use this group in a similar manner, by testing some of these relations.  The representation used here is the same as the representation used more generally to prove Cayley's Theorem. :: sage: Q = QuaternionGroup() sage: I = Q.gen(0) sage: J = Q.gen(1) sage: K = I*J sage: [I,J,K] [(1,2,5,6)(3,4,7,8), (1,3,5,7)(2,8,6,4), (1,8,5,4)(2,7,6,3)] sage: neg_one = I^2; neg_one (1,5)(2,6)(3,7)(4,8) sage: J^2 == neg_one and K^2 == neg_one True sage: J*I == neg_one*K True sage: Q.center().order() == 2 True sage: neg_one in Q.center() True TESTS: :: sage: Q == loads(dumps(Q)) True AUTHOR: -- Rob Beezer (2009-10-09) """ def __init__(self): I = [(1,2,5,6),(3,4,7,8)] J = [(1,3,5,7),(2,8,6,4)] PermutationGroup_generic.__init__(self, [I,J]) def _repr_(self): r""" EXAMPLES: sage: Q=QuaternionGroup(); Q Quaternion group of order 8 as a permutation group """ return "Quaternion group of order 8 as a permutation group" class DihedralGroup(PermutationGroup_generic): def __init__(self, n): TESTS: sage: G == loads(dumps(G)) True """ """ n = Integer(n) if n <= 0: raise ValueError, "n must be positive" gens = tuple([tuple(gen0),tuple(gen1)]) PermutationGroup_generic.__init__(self, gens) def _repr_(self): """ EXAMPLES: sage: G = DihedralGroup(5); G Dihedral group of order 10 as a permutation group Dihedral group of order 10 as a permutation group """ return "Dihedral group of order %s as a permutation group"%self.order()