Ticket #7151: trac_7151_quaternion_group.patch
File trac_7151_quaternion_group.patch, 4.1 KB (added by , 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 4 4 from permgroup_named import (SymmetricGroup, AlternatingGroup, 5 5 DihedralGroup, CyclicPermutationGroup, 6 6 TransitiveGroup, PGL, PSL, PSp,PSU,PGU, 7 MathieuGroup, KleinFourGroup, SuzukiGroup) 7 MathieuGroup, KleinFourGroup, QuaternionGroup, 8 SuzukiGroup) 8 9 9 10 from permgroup import PermutationGroup, PermutationGroup_generic, PermutationGroup_subgroup, direct_product_permgroups 10 11 
sage/groups/perm_gps/permgroup_named.py
diff r e334f15125a3 r 8f94868f8221 sage/groups/perm_gps/permgroup_named.py
a b 22 22 23 23  KleinFourGroup, subgroup of $S_4$ of order $4$ which is not $C_2 \times C_2$ 24 24 25  QuaternionGroup, nonabelian group of order `8`, `\{\pm 1, \pm I, \pm J, \pm K\}` 26 25 27  PGL(n,q), projective general linear group of $n\times n$ matrices over 26 28 the finite field GF(q) 27 29 … … 383 385 The Klein 4 group of order 4, as a permutation group 384 386 """ 385 387 return 'The Klein 4 group of order 4, as a permutation group' 386 388 389 class 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 nonabelian 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 (20091009) 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" 387 446 388 447 class DihedralGroup(PermutationGroup_generic): 389 448 def __init__(self, n): … … 431 490 TESTS: 432 491 sage: G == loads(dumps(G)) 433 492 True 434 """ 493 """ 435 494 n = Integer(n) 436 495 if n <= 0: 437 496 raise ValueError, "n must be positive" … … 453 512 gens = tuple([tuple(gen0),tuple(gen1)]) 454 513 455 514 PermutationGroup_generic.__init__(self, gens) 456 515 457 516 def _repr_(self): 458 517 """ 459 518 EXAMPLES: 460 519 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 462 521 """ 463 522 return "Dihedral group of order %s as a permutation group"%self.order() 464 523