6
6
- Daniel Bump (2008): initial version
7
7
- Mike Hansen (2008): initial version
8
8
- Anne Schilling (2008): initial version
9
- - Nicolas Thiery (2008): initial version
9
+ - Nicolas Thiéry (2008): initial version
10
10
- Volker Braun (2013): LibGAP-based matrix groups
11
11
12
12
EXAMPLES:
13
13
14
- More examples on Weyl Groups should be added here...
15
-
16
14
The Cayley graph of the Weyl Group of type ['A', 3]::
17
15
18
16
sage: w = WeylGroup(['A',3])
26
24
sage: d = w.cayley_graph(); d
27
25
Digraph on 192 vertices
28
26
sage: d.show3d(color_by_label=True, edge_size=0.01, vertex_size=0.03) #long time (less than one minute)
27
+
28
+ .. TODO::
29
+
30
+ More examples on Weyl Groups should be added here.
29
31
"""
30
- #* ****************************************************************************
32
+ # ****************************************************************************
31
33
# Copyright (C) 2008 Daniel Bump <bump at match.stanford.edu>,
32
34
33
35
# Anne Schilling <anne at math.ucdavis.edu>
34
36
# Nicolas Thiery <nthiery at users.sf.net>
35
37
#
36
38
# Distributed under the terms of the GNU General Public License (GPL)
37
39
#
38
- # http ://www.gnu.org/licenses/
39
- #* ****************************************************************************
40
+ # https ://www.gnu.org/licenses/
41
+ # ****************************************************************************
40
42
from sage .groups .matrix_gps .finitely_generated import FinitelyGeneratedMatrixGroup_gap
41
43
from sage .groups .matrix_gps .group_element import MatrixGroupElement_gap
42
44
from sage .groups .perm_gps .permgroup import PermutationGroup_generic
59
61
60
62
def WeylGroup (x , prefix = None , implementation = 'matrix' ):
61
63
"""
62
- Returns the Weyl group of the root system defined by the Cartan
64
+ Return the Weyl group of the root system defined by the Cartan
63
65
type (or matrix) ``ct``.
64
66
65
67
INPUT:
66
68
67
- - ``x`` - a root system or a Cartan type (or matrix)
69
+ - ``x`` -- a root system or a Cartan type (or matrix)
68
70
69
71
OPTIONAL:
70
72
@@ -236,7 +238,7 @@ def __init__(self, domain, prefix):
236
238
category = WeylGroups ()
237
239
if self .cartan_type ().is_irreducible ():
238
240
category = category .Irreducible ()
239
- self .n = domain .dimension () # Really needed?
241
+ self .n = domain .dimension () # Really needed?
240
242
self ._prefix = prefix
241
243
242
244
# FinitelyGeneratedMatrixGroup_gap takes plain matrices as input
@@ -252,7 +254,7 @@ def __init__(self, domain, prefix):
252
254
@cached_method
253
255
def cartan_type (self ):
254
256
"""
255
- Returns the CartanType associated to self.
257
+ Return the `` CartanType`` associated to `` self`` .
256
258
257
259
EXAMPLES::
258
260
@@ -265,7 +267,7 @@ def cartan_type(self):
265
267
@cached_method
266
268
def index_set (self ):
267
269
"""
268
- Returns the index set of self.
270
+ Return the index set of `` self`` .
269
271
270
272
EXAMPLES::
271
273
@@ -289,7 +291,7 @@ def from_morphism(self, f):
289
291
@cached_method
290
292
def simple_reflections (self ):
291
293
"""
292
- Returns the simple reflections of self, as a family.
294
+ Return the simple reflections of `` self`` , as a family.
293
295
294
296
EXAMPLES:
295
297
@@ -393,13 +395,13 @@ def _repr_(self):
393
395
Weyl Group of type ['A', 3, 1] (as a matrix group acting on the root space)
394
396
"""
395
397
return "Weyl Group of type %s (as a matrix group acting on the %s)" % (self .cartan_type (),
396
- self ._domain ._name_string (capitalize = False ,
397
- base_ring = False ,
398
- type = False ))
398
+ self ._domain ._name_string (capitalize = False ,
399
+ base_ring = False ,
400
+ type = False ))
399
401
400
402
def character_table (self ):
401
403
"""
402
- Returns the character table as a matrix
404
+ Return the character table as a matrix.
403
405
404
406
Each row is an irreducible character. For larger tables you
405
407
may preface this with a command such as
@@ -421,14 +423,14 @@ def character_table(self):
421
423
X.4 3 -1 1 . -1
422
424
X.5 1 1 1 1 1
423
425
"""
424
- gens_str = ', ' .join (str (g .gap ()) for g in self .gens ())
426
+ gens_str = ', ' .join (str (g .gap ()) for g in self .gens ())
425
427
ctbl = gap ('CharacterTable(Group({0}))' .format (gens_str ))
426
428
return ctbl .Display ()
427
429
428
430
@cached_method
429
431
def one (self ):
430
432
"""
431
- Returns the unit element of the Weyl group
433
+ Return the unit element of the Weyl group.
432
434
433
435
EXAMPLES::
434
436
@@ -441,13 +443,13 @@ def one(self):
441
443
sage: type(e) == W.element_class
442
444
True
443
445
"""
444
- return self ._element_constructor_ (matrix (QQ ,self .n ,self .n ,1 ))
446
+ return self ._element_constructor_ (matrix (QQ , self .n , self .n , 1 ))
445
447
446
- unit = one # For backward compatibility
448
+ unit = one # For backward compatibility
447
449
448
450
def domain (self ):
449
451
"""
450
- Returns the domain of the element of ``self``, that is the
452
+ Return the domain of the element of ``self``, that is the
451
453
root lattice realization on which they act.
452
454
453
455
EXAMPLES::
@@ -463,7 +465,7 @@ def domain(self):
463
465
464
466
def simple_reflection (self , i ):
465
467
"""
466
- Returns the `i^{th}` simple reflection.
468
+ Return the `i^{th}` simple reflection.
467
469
468
470
EXAMPLES::
469
471
@@ -485,7 +487,7 @@ def simple_reflection(self, i):
485
487
486
488
def long_element_hardcoded (self ):
487
489
"""
488
- Returns the long Weyl group element (hardcoded data)
490
+ Return the long Weyl group element (hardcoded data).
489
491
490
492
Do we really want to keep it? There is a generic
491
493
implementation which works in all cases. The hardcoded should
@@ -497,22 +499,22 @@ def long_element_hardcoded(self):
497
499
sage: types = [ ['A',5],['B',3],['C',3],['D',4],['G',2],['F',4],['E',6] ]
498
500
sage: [WeylGroup(t).long_element().length() for t in types]
499
501
[15, 9, 9, 12, 6, 24, 36]
500
- sage: all( WeylGroup(t).long_element() == WeylGroup(t).long_element_hardcoded() for t in types ) # long time (17s on sage.math, 2011)
502
+ sage: all(WeylGroup(t).long_element() == WeylGroup(t).long_element_hardcoded() for t in types) # long time (17s on sage.math, 2011)
501
503
True
502
504
"""
503
505
type = self .cartan_type ()
504
- if type [0 ] == 'D' and type [1 ]% 2 == 1 :
505
- l = [- 1 for i in range (self .n - 1 )]
506
+ if type [0 ] == 'D' and type [1 ] % 2 :
507
+ l = [- 1 for i in range (self .n - 1 )]
506
508
l .append (1 )
507
- m = diagonal_matrix (QQ ,l )
509
+ m = diagonal_matrix (QQ , l )
508
510
elif type [0 ] == 'A' :
509
511
l = [0 for k in range ((self .n )** 2 )]
510
- for k in range (self .n - 1 , (self .n )** 2 - 1 , self .n - 1 ):
512
+ for k in range (self .n - 1 , (self .n )** 2 - 1 , self .n - 1 ):
511
513
l [k ] = 1
512
514
m = matrix (QQ , self .n , l )
513
515
elif type [0 ] == 'E' :
514
516
if type [1 ] == 6 :
515
- half = ZZ (1 )/ ZZ (2 )
517
+ half = ZZ (1 ) / ZZ (2 )
516
518
l = [[- half , - half , - half , half , 0 , 0 , 0 , 0 ],
517
519
[- half , - half , half , - half , 0 , 0 , 0 , 0 ],
518
520
[- half , half , - half , - half , 0 , 0 , 0 , 0 ],
@@ -523,10 +525,10 @@ def long_element_hardcoded(self):
523
525
[0 , 0 , 0 , 0 , - half , half , half , half ]]
524
526
m = matrix (QQ , 8 , l )
525
527
else :
526
- raise NotImplementedError ("Not implemented yet for this type" )
528
+ raise NotImplementedError ("not implemented yet for this type" )
527
529
elif type [0 ] == 'G' :
528
- third = ZZ (1 )/ ZZ (3 )
529
- twothirds = ZZ (2 )/ ZZ (3 )
530
+ third = ZZ (1 ) / ZZ (3 )
531
+ twothirds = ZZ (2 ) / ZZ (3 )
530
532
l = [[- third , twothirds , twothirds ],
531
533
[twothirds , - third , twothirds ],
532
534
[twothirds , twothirds , - third ]]
@@ -559,6 +561,7 @@ def classical(self):
559
561
raise ValueError ("classical subgroup only defined for affine types" )
560
562
return ClassicalWeylSubgroup (self ._domain , prefix = self ._prefix )
561
563
564
+
562
565
class ClassicalWeylSubgroup (WeylGroup_gens ):
563
566
"""
564
567
A class for Classical Weyl Subgroup of an affine Weyl Group
@@ -638,9 +641,9 @@ def __repr__(self):
638
641
Parabolic Subgroup of the Weyl Group of type ['C', 4, 1]^* (as a matrix group acting on the coweight lattice)
639
642
"""
640
643
return "Parabolic Subgroup of the Weyl Group of type %s (as a matrix group acting on the %s)" % (self .domain ().cartan_type (),
641
- self ._domain ._name_string (capitalize = False ,
642
- base_ring = False ,
643
- type = False ))
644
+ self ._domain ._name_string (capitalize = False ,
645
+ base_ring = False ,
646
+ type = False ))
644
647
645
648
def weyl_group (self , prefix = "hereditary" ):
646
649
"""
@@ -672,6 +675,7 @@ def _test_is_finite(self, **options):
672
675
tester .assertTrue (not self .weyl_group (self ._prefix ).is_finite ())
673
676
tester .assertTrue (self .is_finite ())
674
677
678
+
675
679
class WeylGroupElement (MatrixGroupElement_gap ):
676
680
"""
677
681
Class for a Weyl Group elements
@@ -705,7 +709,7 @@ def to_matrix(self):
705
709
706
710
def domain (self ):
707
711
"""
708
- Returns the ambient lattice associated with self.
712
+ Return the ambient lattice associated with `` self`` .
709
713
710
714
EXAMPLES::
711
715
@@ -789,8 +793,8 @@ def __eq__(self, other):
789
793
purposes.
790
794
"""
791
795
return (self .__class__ == other .__class__ and
792
- self ._parent == other ._parent and
793
- self .matrix () == other .matrix ())
796
+ self ._parent == other ._parent and
797
+ self .matrix () == other .matrix ())
794
798
795
799
def _richcmp_ (self , other , op ):
796
800
"""
@@ -835,15 +839,14 @@ def action(self, v):
835
839
alpha[0] + alpha[1]
836
840
"""
837
841
if v not in self .domain ():
838
- raise ValueError ("{ } is not in the domain". format ( v ) )
839
- return self .domain ().from_vector (self .matrix ()* v .to_vector ())
842
+ raise ValueError (f" { v } is not in the domain" )
843
+ return self .domain ().from_vector (self .matrix () * v .to_vector ())
840
844
841
-
842
- ##########################################################################
845
+ # #######################################################################
843
846
# Descents
844
- ### #######################################################################
847
+ # #######################################################################
845
848
846
- def has_descent (self , i , positive = False , side = "right" ):
849
+ def has_descent (self , i , positive = False , side = "right" ):
847
850
"""
848
851
Test if ``self`` has a descent at position ``i``.
849
852
@@ -934,7 +937,7 @@ def has_left_descent(self, i):
934
937
sage: [(s[3]*s[2]).has_left_descent(i) for i in W.domain().index_set()]
935
938
[False, False, True]
936
939
"""
937
- return self .has_descent (i , side = "left" )
940
+ return self .has_descent (i , side = "left" )
938
941
939
942
def has_right_descent (self , i ):
940
943
"""
@@ -957,13 +960,14 @@ def has_right_descent(self, i):
957
960
"""
958
961
return self .has_descent (i , side = "right" )
959
962
960
- def apply_simple_reflection (self , i , side = "right" ):
963
+ def apply_simple_reflection (self , i , side = "right" ):
961
964
s = self .parent ().simple_reflections ()
962
965
if side == "right" :
963
966
return self * s [i ]
964
967
else :
965
968
return s [i ] * self
966
969
970
+ # TODO
967
971
# The methods first_descent, descents, reduced_word appear almost verbatim in
968
972
# root_lattice_realizations and need to be factored out!
969
973
@@ -978,9 +982,8 @@ def to_permutation(self):
978
982
"""
979
983
W = self .parent ()
980
984
e = W .domain ().basis ()
981
- return tuple ( c * (j + 1 )
982
- for i in e .keys ()
983
- for (j ,c ) in self .action (e [i ]) )
985
+ return tuple (c * (j + 1 ) for i in e .keys ()
986
+ for (j , c ) in self .action (e [i ]))
984
987
985
988
def to_permutation_string (self ):
986
989
"""
@@ -993,6 +996,7 @@ def to_permutation_string(self):
993
996
"""
994
997
return "" .join (str (i ) for i in self .to_permutation ())
995
998
999
+
996
1000
WeylGroup_gens .Element = WeylGroupElement
997
1001
998
1002
@@ -1025,13 +1029,12 @@ def __init__(self, cartan_type, prefix):
1025
1029
"""
1026
1030
self ._cartan_type = cartan_type
1027
1031
self ._index_set = cartan_type .index_set ()
1028
- self ._index_set_inverse = {ii : i for i ,ii in enumerate (cartan_type .index_set ())}
1032
+ self ._index_set_inverse = {ii : i for i , ii in enumerate (cartan_type .index_set ())}
1029
1033
self ._reflection_representation = None
1030
1034
self ._prefix = prefix
1031
- #from sage.libs.gap.libgap import libgap
1032
1035
Q = cartan_type .root_system ().root_lattice ()
1033
1036
Phi = list (Q .positive_roots ()) + [- x for x in Q .positive_roots ()]
1034
- p = [[Phi .index (x .weyl_action ([i ]))+ 1 for x in Phi ]
1037
+ p = [[Phi .index (x .weyl_action ([i ])) + 1 for x in Phi ]
1035
1038
for i in self ._cartan_type .index_set ()]
1036
1039
cat = FiniteWeylGroups ()
1037
1040
if self ._cartan_type .is_irreducible ():
@@ -1207,7 +1210,7 @@ def reflection_index_set(self):
1207
1210
sage: W.reflection_index_set()
1208
1211
(1, 2, 3, 4, 5, 6)
1209
1212
"""
1210
- return tuple (range (1 , self .number_of_reflections ()+ 1 ))
1213
+ return tuple (range (1 , self .number_of_reflections () + 1 ))
1211
1214
1212
1215
def cartan_type (self ):
1213
1216
"""
@@ -1301,9 +1304,9 @@ def distinguished_reflections(self):
1301
1304
1302
1305
def build_elt (index ):
1303
1306
r = pos_roots [index ]
1304
- perm = [Phi .index (x .reflection (r ))+ 1 for x in Phi ]
1307
+ perm = [Phi .index (x .reflection (r )) + 1 for x in Phi ]
1305
1308
return self .element_class (perm , self , check = False )
1306
- return Family (self .reflection_index_set (), lambda i : build_elt (i - 1 ))
1309
+ return Family (self .reflection_index_set (), lambda i : build_elt (i - 1 ))
1307
1310
1308
1311
reflections = distinguished_reflections
1309
1312
0 commit comments