@@ -1209,6 +1209,11 @@ def to_cycles(self, singletons=True, use_min=True, negative_cycles=True):
1209
1209
two cycles `C^{\pm} = \{\pm c_1, \ldots, \pm c_k\}` such that
1210
1210
`C^+ \neq C^-`, this does not include the cycle `C^-`
1211
1211
1212
+ .. WARNING::
1213
+
1214
+ The arugment ``negative_cycles`` does not refer to the usual
1215
+ definition of a negative cycle; see :meth:`cycle_type`.
1216
+
1212
1217
EXAMPLES::
1213
1218
1214
1219
sage: pi = SignedPermutations(7)([2,-1,4,-6,-5,-3,7])
@@ -1259,6 +1264,43 @@ def to_cycles(self, singletons=True, use_min=True, negative_cycles=True):
1259
1264
1260
1265
return cycles
1261
1266
1267
+ def cycle_type (self ):
1268
+ r"""
1269
+ Return a pair of partitions of ``len(self)`` corresponding to the
1270
+ signed cycle type of ``self``.
1271
+
1272
+ A *negative cycle* is a cycle `C = (c_0, \ldots, c_{2k-1})` such that
1273
+ `c_0 = c_k`. Any other cycle is positive. For any cycle `C`, we
1274
+ ignore the cycle `-C` (provided this is a different cycle).
1275
+
1276
+ EXAMPLES::
1277
+
1278
+ sage: pi = SignedPermutations(7)([2,-1,4,-6,-5,-3,7])
1279
+ sage: pi.cycle_type()
1280
+ ([3, 1], [2, 1])
1281
+
1282
+ sage: G = SignedPermutations(5)
1283
+ sage: all(pi.cycle_type().size() == 5 for pi in G)
1284
+ True
1285
+ sage: set(pi.cycle_type() for pi in G) == set(PartitionTuples(2, 5))
1286
+ True
1287
+ """
1288
+ cycles = self .to_cycles (negative_cycles = False )
1289
+ pos_cycles = []
1290
+ neg_cycles = []
1291
+ for C in cycles :
1292
+ if (not len (C ) % 2 ) and C [0 ] == - C [len (C )// 2 ]:
1293
+ neg_cycles .append (C )
1294
+ else :
1295
+ pos_cycles .append (C )
1296
+ pos_type = [len (C ) for C in pos_cycles ]
1297
+ pos_type .sort (reverse = True )
1298
+ neg_type = [len (C ) // 2 for C in neg_cycles ]
1299
+ neg_type .sort (reverse = True )
1300
+ from sage .combinat .partition_tuple import PartitionTuples
1301
+ PT = PartitionTuples (2 , self .parent ()._n )
1302
+ return PT ([pos_type , neg_type ])
1303
+
1262
1304
def order (self ):
1263
1305
"""
1264
1306
Return the multiplicative order of the signed permutation.
@@ -1271,7 +1313,7 @@ def order(self):
1271
1313
sage: pi.order()
1272
1314
12
1273
1315
"""
1274
- return lcm (len (c ) for c in self .to_cycles (singletons = False ))
1316
+ return lcm (len (c ) for c in self .to_cycles (singletons = False , negative_cycles = False ))
1275
1317
1276
1318
1277
1319
class SignedPermutations (ColoredPermutations ):
@@ -1329,7 +1371,6 @@ class SignedPermutations(ColoredPermutations):
1329
1371
1330
1372
- :wikipedia:`Hyperoctahedral_group`
1331
1373
"""
1332
-
1333
1374
def __init__ (self , n ):
1334
1375
"""
1335
1376
Initialize ``self``.
@@ -1540,6 +1581,69 @@ def long_element(self, index_set=None):
1540
1581
return super (SignedPermutations , self ).long_element ()
1541
1582
return self .element_class (self , [- ZZ .one ()] * self ._n , self ._P .one ())
1542
1583
1584
+ def conjugacy_class_representative (self , nu ):
1585
+ r"""
1586
+ Return a permutation with (signed) cycle type ``nu``.
1587
+
1588
+ EXAMPLES::
1589
+
1590
+ sage: G = SignedPermutations(4)
1591
+ sage: for nu in PartitionTuples(2, 4):
1592
+ ....: print(nu, G.conjugacy_class_representative(nu))
1593
+ ....: assert nu == G.conjugacy_class_representative(nu).cycle_type(), nu
1594
+ ([4], []) [2, 3, 4, 1]
1595
+ ([3, 1], []) [2, 3, 1, 4]
1596
+ ([2, 2], []) [2, 1, 4, 3]
1597
+ ([2, 1, 1], []) [2, 1, 3, 4]
1598
+ ([1, 1, 1, 1], []) [1, 2, 3, 4]
1599
+ ([3], [1]) [2, 3, 1, -4]
1600
+ ([2, 1], [1]) [2, 1, 3, -4]
1601
+ ([1, 1, 1], [1]) [1, 2, 3, -4]
1602
+ ([2], [2]) [2, 1, 4, -3]
1603
+ ([2], [1, 1]) [2, 1, -3, -4]
1604
+ ([1, 1], [2]) [1, 2, 4, -3]
1605
+ ([1, 1], [1, 1]) [1, 2, -3, -4]
1606
+ ([1], [3]) [1, 3, 4, -2]
1607
+ ([1], [2, 1]) [1, 3, -2, -4]
1608
+ ([1], [1, 1, 1]) [1, -2, -3, -4]
1609
+ ([], [4]) [2, 3, 4, -1]
1610
+ ([], [3, 1]) [2, 3, -1, -4]
1611
+ ([], [2, 2]) [2, -1, 4, -3]
1612
+ ([], [2, 1, 1]) [2, -1, -3, -4]
1613
+ ([], [1, 1, 1, 1]) [-1, -2, -3, -4]
1614
+
1615
+ TESTS::
1616
+
1617
+ sage: all(nu == SignedPermutations(n).conjugacy_class_representative(nu).cycle_type()
1618
+ ....: for n in range(1, 6) for nu in PartitionTuples(2, n))
1619
+ True
1620
+ """
1621
+ from sage .combinat .partition_tuple import PartitionTuple
1622
+ nu = PartitionTuple (nu )
1623
+ if nu .size () != self ._n :
1624
+ raise ValueError ("the size of the partition pair (=%s) must equal"
1625
+ " the rank (=%s)" % (nu .size (), self ._n ))
1626
+ la , mu = nu
1627
+ cyc = []
1628
+ cnt = 0
1629
+
1630
+ for i in la :
1631
+ cyc += [tuple (range (cnt + 1 , cnt + i + 1 ))] + [tuple (range (- cnt - 1 , - cnt - i - 1 , - 1 ))]
1632
+ cnt += i
1633
+ for i in mu :
1634
+ cyc += [tuple (range (cnt + 1 , cnt + i + 1 )) + tuple (range (- cnt - 1 , - cnt - i - 1 , - 1 ))]
1635
+ cnt += i
1636
+
1637
+ p = [None ] * self ._n
1638
+ for c in cyc :
1639
+ for i in range (len (c )- 1 ):
1640
+ if c [i ] > 0 :
1641
+ p [c [i ]- 1 ] = c [i + 1 ]
1642
+ if c [- 1 ] > 0 :
1643
+ p [c [- 1 ]- 1 ] = c [0 ]
1644
+
1645
+ return self (p )
1646
+
1543
1647
Element = SignedPermutation
1544
1648
1545
1649
# TODO: Make this a subgroup
0 commit comments