Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/groups/class_function.py
4040 views
1
r"""
2
Class functions of groups.
3
4
This module implements a wrapper of GAP's ClassFunction function.
5
6
NOTE: The ordering of the columns of the character table of a group
7
corresponds to the ordering of the list. However, in general there is
8
no way to canonically list (or index) the conjugacy classes of a group.
9
Therefore the ordering of the columns of the character table of
10
a group is somewhat random.
11
12
AUTHORS:
13
14
- Franco Saliola (November 2008): initial version
15
16
- Volker Braun (October 2010): Bugfixes, exterior and symmetric power.
17
"""
18
19
#*****************************************************************************
20
# Copyright (C) 2008 Franco Saliola <[email protected]>
21
#
22
# Distributed under the terms of the GNU General Public License (GPL)
23
# http://www.gnu.org/licenses/
24
#*****************************************************************************
25
26
from sage.structure.sage_object import SageObject
27
from sage.interfaces.gap import gap, GapElement
28
from sage.rings.all import Integer
29
from sage.rings.all import CyclotomicField
30
31
32
class ClassFunction(SageObject):
33
"""
34
A wrapper of GAP's ClassFunction function.
35
36
.. NOTE::
37
38
It is *not* checked whether the given values describes a character,
39
since GAP does not do this.
40
41
EXAMPLES::
42
43
sage: G = CyclicPermutationGroup(4)
44
sage: values = [1, -1, 1, -1]
45
sage: chi = ClassFunction(G, values); chi
46
Character of Cyclic group of order 4 as a permutation group
47
sage: loads(dumps(chi)) == chi
48
True
49
"""
50
def __init__(self, G, values):
51
r"""
52
Returns the character of the group G with values given by the list
53
values. The order of the values must correspond to the output of
54
G.conjugacy_classes_representatives().
55
56
EXAMPLES::
57
58
sage: G = CyclicPermutationGroup(4)
59
sage: values = [1, -1, 1, -1]
60
sage: chi = ClassFunction(G, values); chi
61
Character of Cyclic group of order 4 as a permutation group
62
"""
63
self._group = G
64
if isinstance(values, GapElement) and gap.IsClassFunction(values):
65
self._gap_classfunction = values
66
else:
67
self._gap_classfunction = gap.ClassFunction(G, list(values))
68
e = self._gap_classfunction.Conductor()
69
self._base_ring = CyclotomicField(e)
70
71
72
def _gap_init_(self):
73
r"""
74
Returns a string showing how to declare / initialize self in Gap.
75
Stored in the \code{self._gap_string} attribute.
76
77
EXAMPLES::
78
79
sage: G = CyclicPermutationGroup(4)
80
sage: values = [1, -1, 1, -1]
81
sage: ClassFunction(G, values)._gap_init_()
82
'ClassFunction( CharacterTable( Group( [ (1,2,3,4) ] ) ), [ 1, -1, 1, -1 ] )'
83
"""
84
return str(self._gap_classfunction)
85
86
87
def _gap_(self, *args):
88
r"""
89
Coerce self into a GAP element.
90
91
EXAMPLES::
92
93
sage: G = CyclicPermutationGroup(4)
94
sage: values = [1, -1, 1, -1]
95
sage: chi = ClassFunction(G, values); chi
96
Character of Cyclic group of order 4 as a permutation group
97
sage: type(_)
98
<class 'sage.groups.class_function.ClassFunction'>
99
sage: chi._gap_()
100
ClassFunction( CharacterTable( Group( [ (1,2,3,4) ] ) ), [ 1, -1, 1, -1 ] )
101
sage: type(_)
102
<class 'sage.interfaces.gap.GapElement'>
103
"""
104
return self._gap_classfunction
105
106
107
def __repr__(self):
108
r"""
109
Return a string representation.
110
111
OUTPUT:
112
113
A string.
114
115
EXAMPLES::
116
117
sage: G = SymmetricGroup(4)
118
sage: values = [1, -1, 1, 1, -1]
119
sage: ClassFunction(G, values)
120
Character of Symmetric group of order 4! as a permutation group
121
"""
122
return "Character of %s" % repr(self._group)
123
124
125
def __iter__(self):
126
r"""
127
Iterate through the values of self evaluated on the conjugacy
128
classes.
129
130
EXAMPLES::
131
132
sage: xi = ClassFunction(SymmetricGroup(4), [1, -1, 1, 1, -1])
133
sage: list(xi)
134
[1, -1, 1, 1, -1]
135
"""
136
for v in self._gap_classfunction:
137
yield self._base_ring(v)
138
139
140
def __cmp__(self, other):
141
r"""
142
Rich comparison for class functions.
143
144
Compares groups and then the values of the class function on the
145
conjugacy classes. Otherwise, compares types of objects.
146
147
EXAMPLES::
148
149
sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]])
150
sage: chi = G.character([1, 1, 1, 1, 1, 1, 1])
151
sage: H = PermutationGroup([[(1,2,3),(4,5)]])
152
sage: xi = H.character([1, 1, 1, 1, 1, 1])
153
sage: chi == chi
154
True
155
sage: xi == xi
156
True
157
sage: xi == chi
158
False
159
sage: chi < xi
160
False
161
sage: xi < chi
162
True
163
164
"""
165
if isinstance(other, ClassFunction):
166
return cmp((self._group, self.values()),
167
(other._group, other.values()))
168
else:
169
return cmp(type(self), type(other))
170
171
172
def __reduce__(self):
173
r"""
174
Add pickle support.
175
176
EXAMPLES::
177
178
sage: G = GL(2,7)
179
sage: values = list(gap(G).CharacterTable().Irr()[2])
180
sage: chi = ClassFunction(G, values)
181
sage: loads(dumps(chi)) == chi
182
True
183
"""
184
return ClassFunction, (self._group, self.values())
185
186
187
def domain(self):
188
r"""
189
Returns the domain of the self.
190
191
OUTPUT:
192
193
The underlying group of the class function.
194
195
EXAMPLES::
196
197
sage: ClassFunction(SymmetricGroup(4), [1,-1,1,1,-1]).domain()
198
Symmetric group of order 4! as a permutation group
199
"""
200
return self._group
201
202
203
def __call__(self, g):
204
"""
205
Evaluate the character on the group element g. Returns an error if
206
g is not in G.
207
208
EXAMPLES::
209
210
sage: G = GL(2,7)
211
sage: values = list(gap(G).CharacterTable().Irr()[2])
212
sage: chi = ClassFunction(G, values)
213
sage: z = G([[3,0],[0,3]]); z
214
[3 0]
215
[0 3]
216
sage: chi(z)
217
1
218
sage: G = GL(2,3)
219
sage: chi = G.irreducible_characters()[3]
220
sage: g = G.conjugacy_class_representatives()[6]
221
sage: chi(g)
222
zeta8^3 + zeta8
223
224
sage: G = SymmetricGroup(3)
225
sage: h = G((2,3))
226
sage: triv = G.trivial_character()
227
sage: triv(h)
228
1
229
"""
230
return self._base_ring(gap(g)._operation("^", self._gap_classfunction))
231
232
233
def __add__(self, other):
234
r"""
235
Returns the sum of the characters self and other.
236
237
INPUT:
238
239
- ``other`` -- a :class:`ClassFunction` of the same group as
240
``self``.
241
242
OUTPUT:
243
244
A :class:`ClassFunction`
245
246
EXAMPLES::
247
248
sage: chi = ClassFunction(SymmetricGroup(4), [3, 1, -1, 0, -1])
249
sage: s = chi+chi
250
sage: s
251
Character of Symmetric group of order 4! as a permutation group
252
sage: s.values()
253
[6, 2, -2, 0, -2]
254
"""
255
if not isinstance(other, ClassFunction):
256
raise NotImplementedError
257
s = self._gap_classfunction + other._gap_classfunction
258
return ClassFunction(self._group, s)
259
260
261
def __sub__(self, other):
262
r"""
263
Returns the difference of the characters ``self`` and ``other``.
264
265
INPUT:
266
267
- ``other`` -- a :class:`ClassFunction` of the same group as
268
``self``.
269
270
OUTPUT:
271
272
A :class:`ClassFunction`
273
274
EXAMPLES::
275
276
sage: G = SymmetricGroup(4)
277
sage: chi1 = ClassFunction(G, [3, 1, -1, 0, -1])
278
sage: chi2 = ClassFunction(G, [1, -1, 1, 1, -1])
279
sage: s = chi1 - chi2
280
sage: s
281
Character of Symmetric group of order 4! as a permutation group
282
sage: s.values()
283
[2, 2, -2, -1, 0]
284
"""
285
if not isinstance(other, ClassFunction):
286
raise NotImplementedError
287
s = self._gap_classfunction - other._gap_classfunction
288
return ClassFunction(self._group, s)
289
290
291
def __mul__(self, other):
292
r"""
293
Return the product of the character with ``other``.
294
295
INPUT:
296
297
- ``other`` -- either a number or a :class:`ClassFunction` of
298
the same group as ``self``. A number can be anything that
299
can be converted into GAP: integers, rational, and elements
300
of certain number fields.
301
302
OUTPUT:
303
304
A :class:`ClassFunction`
305
306
EXAMPLES::
307
308
sage: G = SymmetricGroup(4)
309
sage: chi1 = ClassFunction(G, [3, 1, -1, 0, -1])
310
sage: 3*chi1
311
Character of Symmetric group of order 4! as a permutation group
312
sage: 3*chi1 == chi1+chi1+chi1
313
True
314
sage: (3*chi1).values()
315
[9, 3, -3, 0, -3]
316
317
318
sage: (1/2*chi1).values()
319
[3/2, 1/2, -1/2, 0, -1/2]
320
321
sage: CF3 = CyclotomicField(3)
322
sage: CF3.inject_variables()
323
Defining zeta3
324
sage: (zeta3 * chi1).values()
325
[3*zeta3, zeta3, -zeta3, 0, -zeta3]
326
327
sage: chi2 = ClassFunction(G, [1, -1, 1, 1, -1])
328
sage: p = chi1*chi2
329
sage: p
330
Character of Symmetric group of order 4! as a permutation group
331
sage: p.values()
332
[3, -1, -1, 0, 1]
333
"""
334
if isinstance(other, ClassFunction):
335
p = self._gap_classfunction * other._gap_classfunction
336
return ClassFunction(self._group, p)
337
else:
338
return ClassFunction(self._group, other * self._gap_classfunction)
339
340
341
def __rmul__(self, other):
342
r"""
343
Return the reverse multiplication of ``self`` and ``other``.
344
345
EXAMPLES::
346
347
sage: G = SymmetricGroup(4)
348
sage: chi = ClassFunction(G, [3, 1, -1, 0, -1])
349
sage: chi * 4 # calls chi.__mul__
350
Character of Symmetric group of order 4! as a permutation group
351
sage: 4 * chi # calls chi.__rmul__
352
Character of Symmetric group of order 4! as a permutation group
353
sage: (4 * chi).values()
354
[12, 4, -4, 0, -4]
355
"""
356
return self.__mul__(other)
357
358
359
def __pos__(self):
360
r"""
361
Return ``self``.
362
363
OUTPUT:
364
365
A :class:`ClassFunction`
366
367
EXAMPLES::
368
369
sage: chi = ClassFunction(SymmetricGroup(4), [3, 1, -1, 0, -1])
370
sage: +chi
371
Character of Symmetric group of order 4! as a permutation group
372
sage: _.values()
373
[3, 1, -1, 0, -1]
374
sage: chi.__pos__() == +chi
375
True
376
"""
377
return ClassFunction(self._group, self._gap_classfunction)
378
379
380
def __neg__(self):
381
r"""
382
Return the additive inverse of ``self``.
383
384
OUTPUT:
385
386
A :class:`ClassFunction`
387
388
EXAMPLES::
389
390
sage: chi = ClassFunction(SymmetricGroup(4), [3, 1, -1, 0, -1])
391
sage: -chi
392
Character of Symmetric group of order 4! as a permutation group
393
sage: _.values()
394
[-3, -1, 1, 0, 1]
395
sage: chi.__neg__() == -chi
396
True
397
"""
398
return ClassFunction(self._group, -self._gap_classfunction)
399
400
401
def __pow__(self, other):
402
r"""
403
Returns the product of self with itself other times.
404
405
EXAMPLES::
406
407
sage: chi = ClassFunction(SymmetricGroup(4), [3, 1, -1, 0, -1])
408
sage: p = chi**3
409
sage: p
410
Character of Symmetric group of order 4! as a permutation group
411
sage: p.values()
412
[27, 1, -1, 0, -1]
413
"""
414
if not isinstance(other, (int,Integer)):
415
raise NotImplementedError
416
return ClassFunction(self._group, self._gap_classfunction ** other)
417
418
419
def symmetric_power(self, n):
420
r"""
421
Returns the symmetrized product of self with itself ``n`` times.
422
423
INPUT:
424
425
- ``n`` -- a positive integer.
426
427
OUTPUT:
428
429
The ``n``-th symmetrized power of ``self`` as a
430
:class:`ClassFunction`.
431
432
EXAMPLES::
433
434
sage: chi = ClassFunction(SymmetricGroup(4), [3, 1, -1, 0, -1])
435
sage: p = chi.symmetric_power(3)
436
sage: p
437
Character of Symmetric group of order 4! as a permutation group
438
sage: p.values()
439
[10, 2, -2, 1, 0]
440
"""
441
n = Integer(n)
442
tbl = gap.UnderlyingCharacterTable(self)
443
return ClassFunction(self._group, gap.SymmetricParts(tbl,[self],n)[1])
444
445
446
def exterior_power(self, n):
447
r"""
448
Returns the anti-symmetrized product of self with itself ``n`` times.
449
450
INPUT:
451
452
- ``n`` -- a positive integer.
453
454
OUTPUT:
455
456
The ``n``-th anti-symmetrized power of ``self`` as a
457
:class:`ClassFunction`.
458
459
EXAMPLES::
460
461
sage: chi = ClassFunction(SymmetricGroup(4), [3, 1, -1, 0, -1])
462
sage: p = chi.exterior_power(3) # the highest anti-symmetric power for a 3-d character
463
sage: p
464
Character of Symmetric group of order 4! as a permutation group
465
sage: p.values()
466
[1, -1, 1, 1, -1]
467
sage: p == chi.determinant_character()
468
True
469
"""
470
n = Integer(n)
471
tbl = gap.UnderlyingCharacterTable(self)
472
return ClassFunction(self._group, gap.AntiSymmetricParts(tbl,[self],n)[1])
473
474
475
def scalar_product(self, other):
476
r"""
477
Returns the scalar product of self with other.
478
479
EXAMPLES::
480
481
sage: S4 = SymmetricGroup(4)
482
sage: irr = S4.irreducible_characters()
483
sage: [[x.scalar_product(y) for x in irr] for y in irr]
484
[[1, 0, 0, 0, 0],
485
[0, 1, 0, 0, 0],
486
[0, 0, 1, 0, 0],
487
[0, 0, 0, 1, 0],
488
[0, 0, 0, 0, 1]]
489
"""
490
return self._gap_classfunction.ScalarProduct(other)
491
492
493
def is_irreducible(self):
494
r"""
495
Returns True if self cannot be written as the sum of two nonzero
496
characters of self.
497
498
EXAMPLES::
499
500
sage: S4 = SymmetricGroup(4)
501
sage: irr = S4.irreducible_characters()
502
sage: [x.is_irreducible() for x in irr]
503
[True, True, True, True, True]
504
"""
505
return bool(self._gap_classfunction.IsIrreducible())
506
507
508
def degree(self):
509
r"""
510
Returns the degree of the character self.
511
512
EXAMPLES::
513
514
sage: S5 = SymmetricGroup(5)
515
sage: irr = S5.irreducible_characters()
516
sage: [x.degree() for x in irr]
517
[1, 4, 5, 6, 5, 4, 1]
518
"""
519
return Integer(self._gap_classfunction.DegreeOfCharacter())
520
521
522
def irreducible_constituents(self):
523
r"""
524
Returns a list of the characters that appear in the decomposition
525
of chi.
526
527
EXAMPLES::
528
529
sage: S5 = SymmetricGroup(5)
530
sage: chi = ClassFunction(S5, [22, -8, 2, 1, 1, 2, -3])
531
sage: irr = chi.irreducible_constituents(); irr
532
[Character of Symmetric group of order 5! as a permutation group,
533
Character of Symmetric group of order 5! as a permutation group]
534
sage: map(list, irr)
535
[[4, -2, 0, 1, 1, 0, -1], [5, -1, 1, -1, -1, 1, 0]]
536
sage: G = GL(2,3)
537
sage: chi = ClassFunction(G, [-1, -1, -1, -1, -1, -1, -1, -1])
538
sage: chi.irreducible_constituents()
539
[Character of General Linear Group of degree 2 over Finite Field of size 3]
540
sage: chi = ClassFunction(G, [1, 1, 1, 1, 1, 1, 1, 1])
541
sage: chi.irreducible_constituents()
542
[Character of General Linear Group of degree 2 over Finite Field of size 3]
543
sage: chi = ClassFunction(G, [2, 2, 2, 2, 2, 2, 2, 2])
544
sage: chi.irreducible_constituents()
545
[Character of General Linear Group of degree 2 over Finite Field of size 3]
546
sage: chi = ClassFunction(G, [-1, -1, -1, -1, 3, -1, -1, 1])
547
sage: ic = chi.irreducible_constituents(); ic
548
[Character of General Linear Group of degree 2 over Finite Field of size 3,
549
Character of General Linear Group of degree 2 over Finite Field of size 3]
550
sage: map(list, ic)
551
[[2, -1, 2, -1, 2, 0, 0, 0], [3, 0, 3, 0, -1, 1, 1, -1]]
552
"""
553
L = self._gap_classfunction.ConstituentsOfCharacter()
554
return [ClassFunction(self._group, list(l)) for l in L]
555
556
557
def decompose(self):
558
r"""
559
Returns a list of the characters that appear in the decomposition
560
of chi.
561
562
EXAMPLES::
563
564
sage: S5 = SymmetricGroup(5)
565
sage: chi = ClassFunction(S5, [22, -8, 2, 1, 1, 2, -3])
566
sage: chi.decompose()
567
[(3, Character of Symmetric group of order 5! as a permutation group),
568
(2, Character of Symmetric group of order 5! as a permutation group)]
569
"""
570
L = []
571
for irr in self.irreducible_constituents():
572
L.append((self.scalar_product(irr), irr))
573
return L
574
575
576
def norm(self):
577
r"""
578
Returns the norm of self.
579
580
EXAMPLES::
581
582
sage: A5 = AlternatingGroup(5)
583
sage: [x.norm() for x in A5.irreducible_characters()]
584
[1, 1, 1, 1, 1]
585
"""
586
return self._gap_classfunction.Norm()
587
588
589
def values(self):
590
r"""
591
Return the list of values of self on the conjugacy classes.
592
593
EXAMPLES::
594
595
sage: G = GL(2,3)
596
sage: [x.values() for x in G.irreducible_characters()] #random
597
[[1, 1, 1, 1, 1, 1, 1, 1],
598
[1, 1, 1, 1, 1, -1, -1, -1],
599
[2, -1, 2, -1, 2, 0, 0, 0],
600
[2, 1, -2, -1, 0, -zeta8^3 - zeta8, zeta8^3 + zeta8, 0],
601
[2, 1, -2, -1, 0, zeta8^3 + zeta8, -zeta8^3 - zeta8, 0],
602
[3, 0, 3, 0, -1, -1, -1, 1],
603
[3, 0, 3, 0, -1, 1, 1, -1],
604
[4, -1, -4, 1, 0, 0, 0, 0]]
605
606
TESTS::
607
608
sage: G = GL(2,3)
609
sage: k = CyclotomicField(8)
610
sage: zeta8 = k.gen()
611
sage: v = [tuple(x.values()) for x in G.irreducible_characters()]
612
sage: set(v) == set([(1, 1, 1, 1, 1, 1, 1, 1), (1, 1, 1, 1, 1, -1, -1, -1), (2, -1, 2, -1, 2, 0, 0, 0), (2, 1, -2, -1, 0, -zeta8^3 - zeta8, zeta8^3 + zeta8, 0), (2, 1, -2, -1, 0, zeta8^3 + zeta8, -zeta8^3 - zeta8, 0), (3, 0, 3, 0, -1, -1, -1, 1), (3, 0, 3, 0, -1, 1, 1, -1), (4, -1, -4, 1, 0, 0, 0, 0)])
613
True
614
"""
615
return list(self)
616
617
618
def central_character(self):
619
r"""
620
Returns the central character of self.
621
622
EXAMPLES::
623
624
sage: t = SymmetricGroup(4).trivial_character()
625
sage: t.central_character().values()
626
[1, 6, 3, 8, 6]
627
"""
628
return ClassFunction(self._group, self._gap_classfunction.CentralCharacter())
629
630
631
def determinant_character(self):
632
r"""
633
Returns the determinant character of self.
634
635
EXAMPLES::
636
637
sage: t = ClassFunction(SymmetricGroup(4), [1, -1, 1, 1, -1])
638
sage: t.determinant_character().values()
639
[1, -1, 1, 1, -1]
640
"""
641
return ClassFunction(self._group, self._gap_classfunction.DeterminantOfCharacter())
642
643
644
def tensor_product(self, other):
645
r"""
646
EXAMPLES::
647
648
sage: S3 = SymmetricGroup(3)
649
sage: chi1, chi2, chi3 = S3.irreducible_characters()
650
sage: chi1.tensor_product(chi3).values()
651
[1, -1, 1]
652
"""
653
return ClassFunction(self._group, gap.Tensored([self],[other])[1])
654
655
656
def restrict(self, H):
657
r"""
658
Return the restricted character.
659
660
INPUT:
661
662
- ``H`` -- a subgroup of the underlying group of ``self``.
663
664
OUTPUT:
665
666
A :class:`ClassFunction` of ``H`` defined by restriction.
667
668
EXAMPLES::
669
670
sage: G = SymmetricGroup(5)
671
sage: chi = ClassFunction(G, [3, -3, -1, 0, 0, -1, 3]); chi
672
Character of Symmetric group of order 5! as a permutation group
673
sage: H = G.subgroup([(1,2,3), (1,2), (4,5)])
674
sage: chi.restrict(H)
675
Character of Subgroup of (Symmetric group of order 5! as a permutation group) generated by [(4,5), (1,2), (1,2,3)]
676
sage: chi.restrict(H).values()
677
[3, -3, -3, -1, 0, 0]
678
"""
679
rest = self._gap_classfunction.RestrictedClassFunction(H._gap_())
680
return ClassFunction(H, rest)
681
682
683
def induct(self, G):
684
r"""
685
Return the induced character.
686
687
INPUT:
688
689
- ``G`` -- A supergroup of the underlying group of ``self``.
690
691
OUTPUT:
692
693
A :class:`ClassFunction` of ``G`` defined by
694
induction. Induction is the adjoint functor to restriction,
695
see :meth:`restrict`.
696
697
EXAMPLES::
698
699
sage: G = SymmetricGroup(5)
700
sage: H = G.subgroup([(1,2,3), (1,2), (4,5)])
701
sage: xi = H.trivial_character(); xi
702
Character of Subgroup of (Symmetric group of order 5! as a permutation group) generated by [(4,5), (1,2), (1,2,3)]
703
sage: xi.induct(G)
704
Character of Symmetric group of order 5! as a permutation group
705
sage: xi.induct(G).values()
706
[10, 4, 2, 1, 1, 0, 0]
707
"""
708
rest = self._gap_classfunction.InducedClassFunction(G._gap_())
709
return ClassFunction(G, rest)
710
711