@@ -1189,8 +1189,8 @@ def has_left_descent(self, i):
1189
1189
return self ._colors [i ] == 1 or self ._perm [i - 1 ] < self ._perm [i ]
1190
1190
return self ._colors [i ] == 1 and self ._perm [i - 1 ] > self ._perm [i ]
1191
1191
1192
- def to_cycles (self , singletons = True , use_min = True , negative_singletons = True ):
1193
- """
1192
+ def to_cycles (self , singletons = True , use_min = True , negative_cycles = True ):
1193
+ r """
1194
1194
Return the signed permutation ``self`` as a list of disjoint cycles.
1195
1195
1196
1196
The cycles are returned in the order of increasing smallest
@@ -1205,18 +1205,25 @@ def to_cycles(self, singletons=True, use_min=True, negative_singletons=True):
1205
1205
- ``use_min`` -- (default: ``True``) if ``False``, the cycles are
1206
1206
returned in the order of increasing *largest* (not smallest)
1207
1207
elements, and each cycle starts with its largest element
1208
+ - ``negative_cycles`` -- (default: ``True``) if ``False``, for any
1209
+ two cycles `C^{\pm} = \{\pm c_1, \ldots, \pm c_k\}` such that
1210
+ `C^+ \neq C^-`, this does not include the cycle `C^-`
1208
1211
1209
1212
EXAMPLES::
1210
1213
1211
1214
sage: pi = SignedPermutations(7)([2,-1,4,-6,-5,-3,7])
1212
1215
sage: pi.to_cycles()
1213
- [(1, 2, -1, -2), (3, 4, -6), (5, -5), (7,)]
1216
+ [(1, 2, -1, -2), (3, 4, -6), (-3, -4, 6), ( 5, -5), (7,), (- 7,)]
1214
1217
sage: pi.to_cycles(singletons=False)
1218
+ [(1, 2, -1, -2), (3, 4, -6), (-3, -4, 6), (5, -5)]
1219
+ sage: pi.to_cycles(negative_cycles=False)
1220
+ [(1, 2, -1, -2), (3, 4, -6), (5, -5), (7,)]
1221
+ sage: pi.to_cycles(singletons=False, negative_cycles=False)
1215
1222
[(1, 2, -1, -2), (3, 4, -6), (5, -5)]
1216
1223
sage: pi.to_cycles(use_min=False)
1217
- [(7,), (6, -3, -4), (5, -5), (2, -1, -2, 1)]
1224
+ [(7,), (-7,), ( 6, -3, -4), (-6, 3, 4), (5, -5), (2, -1, -2, 1)]
1218
1225
sage: pi.to_cycles(singletons=False, use_min=False)
1219
- [(6, -3, -4), (5, -5), (2, -1, -2, 1)]
1226
+ [(6, -3, -4), (-6, 3, 4), ( 5, -5), (2, -1, -2, 1)]
1220
1227
"""
1221
1228
cycles = []
1222
1229
@@ -1235,16 +1242,20 @@ def to_cycles(self, singletons=True, use_min=True, negative_singletons=True):
1235
1242
cycle = [cycle_first ]
1236
1243
l [i ], next_val = False , l [i ]
1237
1244
s = self ._colors [i ]
1245
+ add_neg = True
1238
1246
while next_val != cycle_first :
1239
1247
cycle .append (s * next_val )
1240
1248
s *= self ._colors [next_val - 1 ]
1241
1249
l [next_val - 1 ], next_val = False , l [next_val - 1 ]
1242
1250
if s != 1 :
1243
1251
cycle .extend ([- e for e in cycle ])
1252
+ add_neg = False
1244
1253
1245
1254
# Add the cycle to the list of cycles
1246
1255
if singletons or len (cycle ) > 1 :
1247
1256
cycles .append (tuple (cycle ))
1257
+ if negative_cycles and add_neg :
1258
+ cycles .append (tuple ([- e for e in cycle ]))
1248
1259
1249
1260
return cycles
1250
1261
@@ -1256,7 +1267,7 @@ def order(self):
1256
1267
1257
1268
sage: pi = SignedPermutations(7)([2,-1,4,-6,-5,-3,7])
1258
1269
sage: pi.to_cycles(singletons=False)
1259
- [(1, 2, -1, -2), (3, 4, -6), (5, -5)]
1270
+ [(1, 2, -1, -2), (3, 4, -6), (-3, -4, 6), ( 5, -5)]
1260
1271
sage: pi.order()
1261
1272
12
1262
1273
"""
0 commit comments