17
17
- Volker Braun (October 2010): Bugfixes, exterior and symmetric power.
18
18
"""
19
19
20
- #* ****************************************************************************
20
+ # ****************************************************************************
21
21
# Copyright (C) 2008 Franco Saliola <[email protected] >
22
22
#
23
23
# Distributed under the terms of the GNU General Public License (GPL)
24
24
# https://www.gnu.org/licenses/
25
- #* ****************************************************************************
25
+ # ****************************************************************************
26
26
27
27
from sage .structure .sage_object import SageObject
28
28
from sage .structure .richcmp import richcmp , richcmp_method
@@ -66,24 +66,26 @@ class function on the conjugacy classes, in that order.
66
66
sage: chi = ClassFunction(G, values); chi
67
67
Character of Cyclic group of order 4 as a permutation group
68
68
"""
69
+ from sage .misc .superseded import deprecation
69
70
try :
70
71
return group .class_function (values )
71
72
except AttributeError :
72
73
pass
73
74
74
- if isinstance (values , LibGapElement ):
75
+ if isinstance (values , ( LibGapElement , tuple , list ) ):
75
76
return ClassFunction_libgap (group , values )
76
77
78
+ # deprecation(36889, "please use libgap class functions instead")
77
79
return ClassFunction_gap (group , values )
78
80
79
81
80
82
#####################################################################
81
- ###
82
- ### GAP Interface-based Class Function
83
- ###
84
- ### This is old code that should be deleted once we have transitioned
85
- ### everything to using the library interface to GAP.
86
- ###
83
+ #
84
+ # GAP Interface-based Class Function
85
+ #
86
+ # This is old code that should be deleted once we have transitioned
87
+ # everything to using the library interface to GAP.
88
+ #
87
89
#####################################################################
88
90
89
91
@richcmp_method
@@ -123,20 +125,20 @@ def __init__(self, G, values):
123
125
if isinstance (values , GapElement ) and gap .IsClassFunction (values ):
124
126
self ._gap_classfunction = values
125
127
else :
126
- self ._gap_classfunction = gap .ClassFunction (G , list (values ))
128
+ self ._gap_classfunction = gap .ClassFunction (G , gap (values ))
127
129
128
130
e = self ._gap_classfunction .Conductor ()
129
131
self ._base_ring = CyclotomicField (e )
130
132
131
133
def _gap_init_ (self ):
132
134
r"""
133
- Returns a string showing how to declare / initialize self in Gap.
135
+ Return a string showing how to declare / initialize self in Gap.
134
136
Stored in the \code{self._gap_string} attribute.
135
137
136
138
EXAMPLES::
137
139
138
140
sage: G = CyclicPermutationGroup(4)
139
- sage: values = [1, -1, 1, -1]
141
+ sage: values = gap( [1, -1, 1, -1])
140
142
sage: ClassFunction(G, values)._gap_init_()
141
143
'ClassFunction( CharacterTable( Group( [ (1,2,3,4) ] ) ), [ 1, -1, 1, -1 ] )'
142
144
"""
@@ -149,7 +151,7 @@ def _gap_(self, *args):
149
151
EXAMPLES::
150
152
151
153
sage: G = CyclicPermutationGroup(4)
152
- sage: values = [1, -1, 1, -1]
154
+ sage: values = gap( [1, -1, 1, -1])
153
155
sage: chi = ClassFunction(G, values); chi
154
156
Character of Cyclic group of order 4 as a permutation group
155
157
sage: type(_)
@@ -173,7 +175,7 @@ def __repr__(self):
173
175
174
176
sage: G = SymmetricGroup(4)
175
177
sage: values = [1, -1, 1, 1, -1]
176
- sage: ClassFunction(G, values)
178
+ sage: ClassFunction(G, gap( values) )
177
179
Character of Symmetric group of order 4! as a permutation group
178
180
"""
179
181
return "Character of %s" % repr (self ._group )
@@ -185,7 +187,7 @@ def __iter__(self):
185
187
186
188
EXAMPLES::
187
189
188
- sage: xi = ClassFunction(SymmetricGroup(4), [1, -1, 1, 1, -1])
190
+ sage: xi = ClassFunction(SymmetricGroup(4), gap( [1, -1, 1, 1, -1]) )
189
191
sage: list(xi)
190
192
[1, -1, 1, 1, -1]
191
193
"""
@@ -239,7 +241,7 @@ def __reduce__(self):
239
241
EXAMPLES::
240
242
241
243
sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]])
242
- sage: chi = ClassFunction(G, [1, 1, 1, 1, 1, 1, 1])
244
+ sage: chi = ClassFunction(G, gap( [1, 1, 1, 1, 1, 1, 1]) )
243
245
sage: type(chi)
244
246
<class 'sage.groups.class_function.ClassFunction_gap'>
245
247
sage: loads(dumps(chi)) == chi
@@ -249,7 +251,7 @@ def __reduce__(self):
249
251
250
252
def domain (self ):
251
253
r"""
252
- Returns the domain of the self.
254
+ Return the domain of the `` self`` .
253
255
254
256
OUTPUT:
255
257
@@ -294,7 +296,7 @@ def __call__(self, g):
294
296
295
297
def __add__ (self , other ):
296
298
r"""
297
- Returns the sum of the characters self and other.
299
+ Return the sum of the characters self and other.
298
300
299
301
INPUT:
300
302
@@ -307,7 +309,7 @@ def __add__(self, other):
307
309
308
310
EXAMPLES::
309
311
310
- sage: chi = ClassFunction(SymmetricGroup(4), [3, 1, -1, 0, -1])
312
+ sage: chi = ClassFunction(SymmetricGroup(4), gap( [3, 1, -1, 0, -1]) )
311
313
sage: s = chi+chi
312
314
sage: s
313
315
Character of Symmetric group of order 4! as a permutation group
@@ -321,7 +323,7 @@ def __add__(self, other):
321
323
322
324
def __sub__ (self , other ):
323
325
r"""
324
- Returns the difference of the characters ``self`` and ``other``.
326
+ Return the difference of the characters ``self`` and ``other``.
325
327
326
328
INPUT:
327
329
@@ -366,7 +368,7 @@ def __mul__(self, other):
366
368
EXAMPLES::
367
369
368
370
sage: G = SymmetricGroup(4)
369
- sage: chi1 = ClassFunction(G, [3, 1, -1, 0, -1])
371
+ sage: chi1 = ClassFunction(G, gap( [3, 1, -1, 0, -1]) )
370
372
sage: 3*chi1
371
373
Character of Symmetric group of order 4! as a permutation group
372
374
sage: 3*chi1 == chi1+chi1+chi1
@@ -384,7 +386,7 @@ def __mul__(self, other):
384
386
sage: (zeta3 * chi1).values()
385
387
[3*zeta3, zeta3, -zeta3, 0, -zeta3]
386
388
387
- sage: chi2 = ClassFunction(G, [1, -1, 1, 1, -1])
389
+ sage: chi2 = ClassFunction(G, gap( [1, -1, 1, 1, -1]) )
388
390
sage: p = chi1*chi2
389
391
sage: p
390
392
Character of Symmetric group of order 4! as a permutation group
@@ -456,7 +458,7 @@ def __neg__(self):
456
458
457
459
def __pow__ (self , other ):
458
460
r"""
459
- Returns the product of self with itself other times.
461
+ Return the product of self with itself other times.
460
462
461
463
EXAMPLES::
462
464
@@ -467,13 +469,13 @@ def __pow__(self, other):
467
469
sage: p.values()
468
470
[27, 1, -1, 0, -1]
469
471
"""
470
- if not isinstance (other , (int ,Integer )):
472
+ if not isinstance (other , (int , Integer )):
471
473
raise NotImplementedError
472
474
return ClassFunction (self ._group , self ._gap_classfunction ** other )
473
475
474
476
def symmetric_power (self , n ):
475
477
r"""
476
- Returns the symmetrized product of self with itself ``n`` times.
478
+ Return the symmetrized product of self with itself ``n`` times.
477
479
478
480
INPUT:
479
481
@@ -486,7 +488,7 @@ def symmetric_power(self, n):
486
488
487
489
EXAMPLES::
488
490
489
- sage: chi = ClassFunction(SymmetricGroup(4), [3, 1, -1, 0, -1])
491
+ sage: chi = ClassFunction(SymmetricGroup(4), gap( [3, 1, -1, 0, -1]) )
490
492
sage: p = chi.symmetric_power(3)
491
493
sage: p
492
494
Character of Symmetric group of order 4! as a permutation group
@@ -495,11 +497,11 @@ def symmetric_power(self, n):
495
497
"""
496
498
n = Integer (n )
497
499
tbl = gap .UnderlyingCharacterTable (self )
498
- return ClassFunction (self ._group , gap .SymmetricParts (tbl ,[self ],n )[1 ])
500
+ return ClassFunction (self ._group , gap .SymmetricParts (tbl , [self ], n )[1 ])
499
501
500
502
def exterior_power (self , n ):
501
503
r"""
502
- Returns the anti-symmetrized product of self with itself ``n`` times.
504
+ Return the anti-symmetrized product of self with itself ``n`` times.
503
505
504
506
INPUT:
505
507
@@ -512,7 +514,7 @@ def exterior_power(self, n):
512
514
513
515
EXAMPLES::
514
516
515
- sage: chi = ClassFunction(SymmetricGroup(4), [3, 1, -1, 0, -1])
517
+ sage: chi = ClassFunction(SymmetricGroup(4), gap( [3, 1, -1, 0, -1]) )
516
518
sage: p = chi.exterior_power(3) # the highest anti-symmetric power for a 3-d character
517
519
sage: p
518
520
Character of Symmetric group of order 4! as a permutation group
@@ -523,11 +525,11 @@ def exterior_power(self, n):
523
525
"""
524
526
n = Integer (n )
525
527
tbl = gap .UnderlyingCharacterTable (self )
526
- return ClassFunction (self ._group , gap .AntiSymmetricParts (tbl ,[self ],n )[1 ])
528
+ return ClassFunction (self ._group , gap .AntiSymmetricParts (tbl , [self ], n )[1 ])
527
529
528
530
def scalar_product (self , other ):
529
531
r"""
530
- Returns the scalar product of self with other.
532
+ Return the scalar product of self with other.
531
533
532
534
EXAMPLES::
533
535
@@ -544,7 +546,7 @@ def scalar_product(self, other):
544
546
545
547
def is_irreducible (self ):
546
548
r"""
547
- Returns True if self cannot be written as the sum of two nonzero
549
+ Return True if self cannot be written as the sum of two nonzero
548
550
characters of self.
549
551
550
552
EXAMPLES::
@@ -558,7 +560,7 @@ def is_irreducible(self):
558
560
559
561
def degree (self ):
560
562
r"""
561
- Returns the degree of the character self.
563
+ Return the degree of the character self.
562
564
563
565
EXAMPLES::
564
566
@@ -571,7 +573,7 @@ def degree(self):
571
573
572
574
def irreducible_constituents (self ):
573
575
r"""
574
- Returns a list of the characters that appear in the decomposition
576
+ Return a list of the characters that appear in the decomposition
575
577
of chi.
576
578
577
579
EXAMPLES::
@@ -694,7 +696,7 @@ def tensor_product(self, other):
694
696
sage: chi1.tensor_product(chi3).values()
695
697
[1, -1, 1]
696
698
"""
697
- return ClassFunction (self ._group , gap .Tensored ([self ],[other ])[1 ])
699
+ return ClassFunction (self ._group , gap .Tensored ([self ], [other ])[1 ])
698
700
699
701
def restrict (self , H ):
700
702
r"""
@@ -791,9 +793,9 @@ def adams_operation(self, k):
791
793
792
794
793
795
#####################################################################
794
- ###
795
- ### Class function using the GAP library
796
- ###
796
+ #
797
+ # Class function using the GAP library
798
+ #
797
799
#####################################################################
798
800
799
801
@@ -834,12 +836,12 @@ def __init__(self, G, values):
834
836
if isinstance (values , LibGapElement ) and values .IsClassFunction ():
835
837
self ._gap_classfunction = values
836
838
else :
837
- self ._gap_classfunction = libgap .ClassFunction (G . _libgap_ () ,
838
- list (values ))
839
+ self ._gap_classfunction = libgap .ClassFunction (G ,
840
+ libgap (values ))
839
841
e = self ._gap_classfunction .Conductor ().sage ()
840
842
self ._base_ring = CyclotomicField (e )
841
843
842
- def gap (self ):
844
+ def _libgap_ (self ):
843
845
r"""
844
846
Return the underlying LibGAP element.
845
847
@@ -850,15 +852,15 @@ def gap(self):
850
852
sage: chi = ClassFunction(G, values); chi
851
853
Character of Cyclic group of order 4 as a permutation group
852
854
sage: type(chi)
853
- <class 'sage.groups.class_function.ClassFunction_gap '>
854
- sage: gap (chi)
855
- ClassFunction( CharacterTable( Group( [ (1,2,3,4) ] ) ), [ 1, -1, 1, -1 ] )
855
+ <class 'sage.groups.class_function.ClassFunction_libgap '>
856
+ sage: libgap (chi)
857
+ ClassFunction( CharacterTable( Group([ (1,2,3,4) ]) ), [ 1, -1, 1, -1 ] )
856
858
sage: type(_)
857
- <class 'sage.interfaces .gap.GapElement '>
859
+ <class 'sage.libs .gap.element.GapElement_List '>
858
860
"""
859
861
return self ._gap_classfunction
860
862
861
- _libgap_ = _gap_ = gap
863
+ gap = _gap_ = _libgap_
862
864
863
865
def _repr_ (self ):
864
866
r"""
@@ -877,6 +879,16 @@ def _repr_(self):
877
879
"""
878
880
return "Character of %s" % repr (self ._group )
879
881
882
+ def __hash__ (self ):
883
+ r"""
884
+ TESTS::
885
+
886
+ sage: G = SymmetricGroup(5)
887
+ sage: chi1 = ClassFunction(G,[1,1,1,1,1,1,1])
888
+ sage: d = {chi1:'trivial'}
889
+ """
890
+ return hash ((self ._group , tuple (self )))
891
+
880
892
def __iter__ (self ):
881
893
r"""
882
894
Iterate through the values.
@@ -1162,7 +1174,7 @@ def __pow__(self, other):
1162
1174
sage: p.values()
1163
1175
[27, 1, -1, 0, -1]
1164
1176
"""
1165
- if not isinstance (other , (int ,Integer )):
1177
+ if not isinstance (other , (int , Integer )):
1166
1178
raise NotImplementedError
1167
1179
return ClassFunction (self ._group , self ._gap_classfunction ** other )
1168
1180
@@ -1189,8 +1201,8 @@ def symmetric_power(self, n):
1189
1201
[10, 2, -2, 1, 0]
1190
1202
"""
1191
1203
n = Integer (n )
1192
- tbl = self ._gap_classfunction .UnderlyingCharacterTable (self )
1193
- return ClassFunction (self ._group , tbl .SymmetricParts ([self ],n )[1 ])
1204
+ tbl = self ._gap_classfunction .UnderlyingCharacterTable ()
1205
+ return ClassFunction (self ._group , tbl .SymmetricParts ([self ], n )[0 ])
1194
1206
1195
1207
def exterior_power (self , n ):
1196
1208
r"""
@@ -1217,8 +1229,8 @@ def exterior_power(self, n):
1217
1229
True
1218
1230
"""
1219
1231
n = Integer (n )
1220
- tbl = self ._gap_classfunction .UnderlyingCharacterTable (self )
1221
- return ClassFunction (self ._group , tbl .AntiSymmetricParts ([self ],n )[1 ])
1232
+ tbl = self ._gap_classfunction .UnderlyingCharacterTable ()
1233
+ return ClassFunction (self ._group , tbl .AntiSymmetricParts ([self ], n )[0 ])
1222
1234
1223
1235
def scalar_product (self , other ):
1224
1236
r"""
0 commit comments