@@ -195,18 +195,35 @@ def __setstate__(self, state):
195
195
self ._set_parent (state [0 ])
196
196
self .__dict__ = state [1 ]
197
197
198
- @combinatorial_map (name = 'conjugate' )
198
+ @combinatorial_map (order = 2 , name = 'conjugate' )
199
199
def conjugate (self ):
200
200
r"""
201
201
Return the conjugate of the composition ``self``.
202
202
203
- Algorithm from mupad-combinat.
203
+ The conjugate of a composition `I` is defined as the
204
+ complement (see :meth:`complement`) of the reverse composition
205
+ (see :meth:`reversed`) of `I`.
206
+
207
+ An equivalent definition of the conjugate goes by saying that
208
+ the ribbon shape of the conjugate of a composition `I` is the
209
+ conjugate of the ribbon shape of `I`. (The ribbon shape of a
210
+ composition is returned by :meth:`to_skew_partition`.)
211
+
212
+ This implementation uses the algorithm from mupad-combinat.
204
213
205
214
EXAMPLES::
206
215
207
216
sage: Composition([1, 1, 3, 1, 2, 1, 3]).conjugate()
208
217
[1, 1, 3, 3, 1, 3]
209
218
219
+ The ribbon shape of the conjugate of `I` is the conjugate of
220
+ the ribbon shape of `I`::
221
+
222
+ sage: all( I.conjugate().to_skew_partition()
223
+ ....: == I.to_skew_partition().conjugate()
224
+ ....: for I in Compositions(4) )
225
+ True
226
+
210
227
TESTS::
211
228
212
229
sage: parent(list(Compositions(1))[0].conjugate())
@@ -227,23 +244,40 @@ def conjugate(self):
227
244
228
245
return self .parent ()([cocjg [0 ]] + [cocjg [i ]- cocjg [i - 1 ]+ 1 for i in range (1 ,len (cocjg ))])
229
246
230
- @combinatorial_map (name = 'reversed' )
247
+ @combinatorial_map (order = 2 , name = 'reversed' )
231
248
def reversed (self ):
232
- """
249
+ r """
233
250
Return the reverse composition of ``self``.
234
251
252
+ The reverse composition of a composition `(i_1, i_2, \ldots, i_k)`
253
+ is defined as the composition `(i_k, i_{k-1}, \ldots, i_1)`.
254
+
235
255
EXAMPLES::
236
256
237
257
sage: Composition([1, 1, 3, 1, 2, 1, 3]).reversed()
238
258
[3, 1, 2, 1, 3, 1, 1]
239
259
"""
240
260
return self .parent ()(reversed (self ))
241
261
242
- @combinatorial_map (name = 'complement' )
262
+ @combinatorial_map (order = 2 , name = 'complement' )
243
263
def complement (self ):
244
- """
245
- Return the complement composition of ``self``. The complement is the
246
- reverse of the conjugate composition of ``self``.
264
+ r"""
265
+ Return the complement of the composition ``self``.
266
+
267
+ The complement of a composition `I` is defined as follows:
268
+
269
+ If `I` is the empty composition, then the complement is the empty
270
+ composition as well. Otherwise, let `S` be the descent set of `I`
271
+ (that is, the subset
272
+ `\{ i_1, i_1 + i_2, \ldots, i_1 + i_2 + \cdots + i_{k-1} \}`
273
+ of `\{ 1, 2, \ldots, |I|-1 \}`, where `I` is written as
274
+ `(i_1, i_2, \ldots, i_k)`). Then, the complement of `I` is
275
+ defined as the composition of size `|I|` whose descent set is
276
+ `\{ 1, 2, \ldots, |I|-1 \} \setminus S`.
277
+
278
+ The complement of a composition `I` also is the reverse
279
+ composition (:meth:`reversed`) of the conjugate
280
+ (:meth:`conjugate`) of `I`.
247
281
248
282
EXAMPLES::
249
283
@@ -268,7 +302,7 @@ def __add__(self, other):
268
302
sage: Composition([]) + Composition([]) == Composition([])
269
303
True
270
304
"""
271
- return Composition (list (self )+ list (other ))
305
+ return Compositions () (list (self )+ list (other ))
272
306
273
307
def size (self ):
274
308
"""
@@ -305,7 +339,7 @@ def sum(compositions):
305
339
sage: Composition.sum([]) == Composition([])
306
340
True
307
341
"""
308
- return sum (compositions , Composition ([]))
342
+ return sum (compositions , Compositions () ([]))
309
343
310
344
def near_concatenation (self , other ):
311
345
r"""
@@ -341,7 +375,7 @@ def near_concatenation(self, other):
341
375
"""
342
376
if len (self ) == 0 or len (other ) == 0 :
343
377
return None
344
- return Composition (list (self )[:- 1 ] + [self [- 1 ] + other [0 ]] + list (other )[1 :])
378
+ return Compositions () (list (self )[:- 1 ] + [self [- 1 ] + other [0 ]] + list (other )[1 :])
345
379
346
380
def ribbon_decomposition (self , other , check = True ):
347
381
r"""
@@ -422,13 +456,6 @@ def ribbon_decomposition(self, other, check=True):
422
456
...
423
457
ValueError: [3, 1, 1, 3, 1] is not the same size as [4, 3, 1]
424
458
425
- REFERENCES:
426
-
427
- .. [NCSF1] Israel Gelfand, D. Krob, Alain Lascoux, B. Leclerc,
428
- V. S. Retakh, J.-Y. Thibon,
429
- *Noncommutative symmetric functions*.
430
- :arxiv:`hep-th/9407124v1`
431
-
432
459
AUTHORS:
433
460
434
461
- Darij Grinberg (2013-08-29)
@@ -452,7 +479,7 @@ def ribbon_decomposition(self, other, check=True):
452
479
try :
453
480
i = I_iter .next ()
454
481
except StopIteration :
455
- factors .append (Composition (current_factor ))
482
+ factors .append (Compositions () (current_factor ))
456
483
return (tuple (factors ), tuple (signs ))
457
484
if current_factor_size + i <= j :
458
485
current_factor .append (i )
@@ -465,7 +492,7 @@ def ribbon_decomposition(self, other, check=True):
465
492
current_factor .append (j - current_factor_size )
466
493
i -= j - current_factor_size
467
494
signs .append (1 )
468
- factors .append (Composition (current_factor ))
495
+ factors .append (Compositions () (current_factor ))
469
496
break
470
497
471
498
return (tuple (factors ), tuple (signs ))
@@ -584,7 +611,7 @@ def join(self, other, check=True):
584
611
try :
585
612
i = I_iter .next ()
586
613
except StopIteration :
587
- return Composition (factors )
614
+ return Compositions () (factors )
588
615
if current_factor_size + i <= j :
589
616
factors .append (i )
590
617
current_factor_size += i
@@ -595,7 +622,7 @@ def join(self, other, check=True):
595
622
i -= j - current_factor_size
596
623
break
597
624
598
- return Composition (factors )
625
+ return Compositions () (factors )
599
626
600
627
sup = join
601
628
@@ -705,7 +732,7 @@ def meet(self, other, check=True):
705
732
i = I_iter .next ()
706
733
except StopIteration :
707
734
factors .append (current_part )
708
- return Composition (factors )
735
+ return Compositions () (factors )
709
736
if current_factor_size + i <= j :
710
737
current_part += i
711
738
current_factor_size += i
@@ -719,7 +746,7 @@ def meet(self, other, check=True):
719
746
current_part += j - current_factor_size
720
747
break
721
748
722
- return Composition (factors )
749
+ return Compositions () (factors )
723
750
724
751
inf = meet
725
752
@@ -816,7 +843,7 @@ def fatten(self, grouping):
816
843
for i in range (len (grouping )):
817
844
result [i ] = sum (self [j :j + grouping [i ]])
818
845
j += grouping [i ]
819
- return Composition (result )
846
+ return Compositions () (result )
820
847
821
848
def fatter (self ):
822
849
"""
@@ -894,7 +921,7 @@ def refinement_splitting(self, J):
894
921
sum1 += new_comp [- 1 ]
895
922
if sum1 > sum2 :
896
923
raise ValueError ("composition J (= %s) does not refine self (= %s)" % (I , J ))
897
- decomp .append (Composition (new_comp ))
924
+ decomp .append (Compositions () (new_comp ))
898
925
return decomp
899
926
900
927
def refinement_splitting_lengths (self , J ):
@@ -921,7 +948,7 @@ def refinement_splitting_lengths(self, J):
921
948
...
922
949
ValueError: composition J (= [2, 1]) does not refine self (= [1, 2])
923
950
"""
924
- return Composition (map (len ,self .refinement_splitting (J )))
951
+ return Compositions () (map (len ,self .refinement_splitting (J )))
925
952
926
953
refinement = deprecated_function_alias (13243 , refinement_splitting_lengths )
927
954
@@ -1685,6 +1712,11 @@ def from_subset(self, S, n):
1685
1712
sage: Compositions().from_subset({2,1,5,9}, 12)
1686
1713
[1, 1, 3, 4, 3]
1687
1714
1715
+ sage: Compositions().from_subset([], 12)
1716
+ [12]
1717
+ sage: Compositions().from_subset([], 0)
1718
+ []
1719
+
1688
1720
TESTS::
1689
1721
1690
1722
sage: Compositions().from_subset([2,1,5,9],9)
0 commit comments