# HG changeset patch
# User Florent Hivert <Florent.Hivert@univ-rouen.fr>
# Date 1268669308 -3600
# Node ID f815c9f725ca00c20501036dac7b941adccf6c48
# Parent 6d2612bf6089bfddc16907dd238dfae1d63a576c
8420: Review: Better ReSTification of the doc.
Removed unused __init__
Added and moved a few tests.
diff --git a/sage/combinat/perfect_matching.py b/sage/combinat/perfect_matching.py
a
|
b
|
|
1 | 1 | r""" |
2 | 2 | Perfect matchings |
3 | 3 | |
4 | | A perfect matching of a set `S` is a partition into 2-element sets. If `S`is |
5 | | the set `{1,..,n}`, it is equivalent to fixpoint-free involutions. These simple |
6 | | combinatorial objects appear in different domains: |
7 | | |
8 | | - combinatorics of orthogonal polynomials (A. de Medicis et X.Viennot, |
9 | | Moments des q-polynomes de Laguerre et la bijection de Foata-Zeilberger, |
10 | | Adv. Appl. Math., 15 (1994), 262-304) |
11 | | |
12 | | - combinatorics of hyperoctahedral group, double coset algebra and zonal |
13 | | polynomials (I. G. Macdonald, Symmetric functions and Hall polynomials, |
14 | | Oxford University Press, second edition, 1995, chapter VII). |
| 4 | A perfect matching of a set `S` is a partition into 2-element sets. If `S` is |
| 5 | the set `\{1,...,n\}`, it is equivalent to fixpoint-free involutions. These |
| 6 | simple combinatorial objects appear in different domains such as combinatoric |
| 7 | of orthogonal polynomials and of the hyperoctaedral groups (see [MV]_, [McD]_ |
| 8 | and also [CM]_): |
15 | 9 | |
16 | 10 | AUTHOR: |
17 | 11 | |
… |
… |
EXAMPLES: |
36 | 30 | sage: PerfectMatchings(4).list() |
37 | 31 | [PerfectMatching [(4, 1), (3, 2)], PerfectMatching [(4, 2), (3, 1)], PerfectMatching [(4, 3), (2, 1)]] |
38 | 32 | |
| 33 | REFERENCES: |
| 34 | |
| 35 | .. [MV] combinatorics of orthogonal polynomials (A. de Medicis et |
| 36 | X.Viennot, Moments des q-polynomes de Laguerre et la bijection de |
| 37 | Foata-Zeilberger, Adv. Appl. Math., 15 (1994), 262-304) |
| 38 | |
| 39 | .. [McD] combinatorics of hyperoctahedral group, double coset algebra and |
| 40 | zonal polynomials (I. G. Macdonald, Symmetric functions and Hall |
| 41 | polynomials, Oxford University Press, second edition, 1995, chapter |
| 42 | VII). |
| 43 | |
| 44 | .. [CM] Benoit Collins, Sho Matsumoto, On some properties of |
| 45 | orthogonal Weingarten functions, arXiv:0903.5143. |
| 46 | """ |
| 47 | |
39 | 48 | #***************************************************************************** |
40 | 49 | # Copyright (C) 2010 Valentin Feray <feray@labri.fr> |
41 | 50 | # |
… |
… |
EXAMPLES: |
43 | 52 | # http://www.gnu.org/licenses/ |
44 | 53 | #***************************************************************************** |
45 | 54 | |
46 | | """ |
47 | 55 | |
48 | 56 | #from sage.combinat.permutation import Permutation_Class |
49 | 57 | from sage.structure.unique_representation import UniqueRepresentation |
… |
… |
class PerfectMatching(ElementWrapper): |
127 | 135 | matching (i.e. a list of pairs with pairwise disjoint elements or a |
128 | 136 | fixpoint-free involution) and raises a ValueError otherwise: |
129 | 137 | |
130 | | sage: try: |
131 | | ... m=PerfectMatching([(1, 2, 3), (4, 5)]) |
132 | | ... except ValueError: |
133 | | ... "A ValueError has been raised." |
134 | | 'A ValueError has been raised.' |
135 | | |
| 138 | sage: PerfectMatching([(1, 2, 3), (4, 5)]) |
| 139 | Traceback (most recent call last): |
| 140 | ... |
| 141 | ValueError: [(1, 2, 3), (4, 5)] is not a valid perfect matching: all elements of the list must be pairs |
| 142 | |
136 | 143 | If you know your datas are in a good format, use directly |
137 | | `PerfectMatchings(objects)(data)`. |
| 144 | `PerfectMatchings(objects)(data)`. |
| 145 | |
| 146 | TESTS:: |
| 147 | |
| 148 | sage: m=PerfectMatching([('a','e'),('b','c'),('d','f')]) |
| 149 | sage: TestSuite(m).run() |
| 150 | sage: m=PerfectMatching([]) |
| 151 | sage: TestSuite(m).run() |
138 | 152 | """ |
139 | 153 | # we have to extract from the argument p the set of objects of the |
140 | 154 | # matching and the list of pairs. |
… |
… |
class PerfectMatching(ElementWrapper): |
171 | 185 | # executed and we do not have an infinite loop. |
172 | 186 | return PerfectMatchings(objects)(data) |
173 | 187 | |
174 | | def __init__(self,data,parent): |
175 | | r""" |
176 | | See :meth:`__classcall_private__` |
177 | | |
178 | | TESTS:: |
179 | | |
180 | | sage: m=PerfectMatching([('a','e'),('b','c'),('d','f')]) |
181 | | sage: TestSuite(m).run() |
182 | | """ |
183 | | self.value=data |
184 | | Element.__init__(self,parent=parent) |
185 | | |
186 | 188 | def _repr_(self): |
187 | 189 | r""" |
188 | 190 | returns the name of the object |
… |
… |
class PerfectMatching(ElementWrapper): |
272 | 274 | INPUT: |
273 | 275 | |
274 | 276 | - ``other`` -- a perfect matching of the same set of ``self``. |
275 | | (if the second argument is empty, the method :meth:`an_element` is |
276 | | called on the parent of the first) |
| 277 | (if the second argument is empty, the method :meth:`an_element` is |
| 278 | called on the parent of the first) |
277 | 279 | |
278 | 280 | OUTPUT: |
279 | 281 | |
… |
… |
class PerfectMatching(ElementWrapper): |
320 | 322 | INPUT: |
321 | 323 | |
322 | 324 | - ``other`` -- a perfect matching of the same set of ``self``. |
323 | | (if the second argument is empty, the method :meth:`an_element` is |
324 | | called on the parent of the first) |
| 325 | (if the second argument is empty, the method :meth:`an_element` is |
| 326 | called on the parent of the first) |
325 | 327 | |
326 | 328 | OUTPUT: |
327 | 329 | |
… |
… |
class PerfectMatching(ElementWrapper): |
348 | 350 | INPUT: |
349 | 351 | |
350 | 352 | - ``other`` -- a perfect matching of the same set of ``self``. |
351 | | (if the second argument is empty, the method :meth:`an_element` is |
352 | | called on the parent of the first) |
| 353 | (if the second argument is empty, the method :meth:`an_element` is |
| 354 | called on the parent of the first) |
353 | 355 | |
354 | 356 | OUTPUT: |
355 | 357 | |
… |
… |
class PerfectMatching(ElementWrapper): |
378 | 380 | INPUT: |
379 | 381 | |
380 | 382 | - ``other`` -- a perfect matching of the same set of ``self``. |
381 | | (if the second argument is empty, the fonction an_element is |
382 | | called on the parent of the first) |
| 383 | (if the second argument is empty, the method :meth:`an_element` is |
| 384 | called on the parent of the first) |
383 | 385 | |
384 | 386 | OUTPUT: |
385 | 387 | |
… |
… |
class PerfectMatching(ElementWrapper): |
654 | 656 | |
655 | 657 | def Weingarten_function(self,d,other=None): |
656 | 658 | r""" |
657 | | Returns the Weingarten function of two pairings. This function is |
658 | | the value of some integrals over the orhtogonal groups `O_N` |
659 | | |
660 | | Reference : Benoit Collins, Sho Matsumoto, On some properties of |
661 | | orthogonal Weingarten functions, arXiv:0903.5143 |
662 | | With the convention of this article, the function returns |
| 659 | Returns the Weingarten function of two pairings. |
| 660 | |
| 661 | This function is the value of some integrals over the orhtogonal |
| 662 | groups `O_N`. With the convention of [CM]_, the method returns |
663 | 663 | `Wg^{O(d)}(other,self)`. |
664 | 664 | |
665 | 665 | EXAMPLES:: |
… |
… |
class PerfectMatchings(UniqueRepresentat |
705 | 705 | |
706 | 706 | sage: PerfectMatchings(5).list() |
707 | 707 | [] |
| 708 | sage: TestSuite(PerfectMatchings(5)).run() |
| 709 | sage: TestSuite(PerfectMatchings([])).run() |
708 | 710 | """ |
709 | 711 | |
710 | 712 | @staticmethod |
… |
… |
class PerfectMatchings(UniqueRepresentat |
880 | 882 | r""" |
881 | 883 | Returns the Weingarten matrix corresponding to the set of |
882 | 884 | PerfectMatchings ``self``. It is a useful theoretical tool to compute |
883 | | polynomial integral over the orthogonal group `O_N`. |
884 | | |
885 | | Reference : Benoit Collins, Sho Matsumoto, On some properties of |
886 | | orthogonal Weingarten functions, arXiv:0903.5143 |
| 885 | polynomial integral over the orthogonal group `O_N` (see [CM]_). |
887 | 886 | |
888 | 887 | EXAMPLES:: |
889 | 888 | |
diff --git a/sage/combinat/permutation.py b/sage/combinat/permutation.py
a
|
b
|
class Permutation_class(CombinatorialObj |
2616 | 2616 | break |
2617 | 2617 | i -= 1 |
2618 | 2618 | return Permutation_class(self[:i+1]) |
2619 | | |
2620 | | def coset_type(self): |
| 2619 | |
| 2620 | def hyperoctahedral_double_coset_type(self): |
| 2621 | r""" |
| 2622 | Returns the coset type of ``self`` as a |
| 2623 | :mod:`perfect matching <sage.combinat.perfect_matching>`. |
| 2624 | |
| 2625 | ``self`` must be a permutation of even size `2n`. The coset-type |
| 2626 | determines the double class of the permutation, that is its image in |
| 2627 | `H_n \backslash S_2n / H_n`, where `H_n` is the hyperoctahedral group of order |
| 2628 | `n` (see [Mcd]_ for more details). It is returned as an instance of |
| 2629 | :class:`PerfectMatching <sage.combinat.perfect_matching.PerfectMatching>`. |
| 2630 | |
| 2631 | EXAMPLE:: |
| 2632 | |
| 2633 | sage: Permutation([3, 4, 6, 1, 5, 7, 2, 8]).hyperoctahedral_double_coset_type() |
| 2634 | [3, 1] |
| 2635 | sage: all([p.hyperoctahedral_double_coset_type() == |
| 2636 | ... p.inverse().hyperoctahedral_double_coset_type() |
| 2637 | ... for p in Permutations(4)]) |
| 2638 | True |
| 2639 | sage: Permutation([]).hyperoctahedral_double_coset_type() |
| 2640 | [] |
| 2641 | |
| 2642 | REFERENCES: |
| 2643 | |
| 2644 | .. [Mcd] I. G. Macdonald, Symmetric functions and Hall |
| 2645 | polynomials, Oxford University Press, second edition, 1995 |
| 2646 | (chapter VII). |
| 2647 | """ |
2621 | 2648 | from sage.combinat.perfect_matching import PerfectMatchings |
2622 | | r""" |
2623 | | returns the coset type of ``self``, which must be a permutation of even |
2624 | | size `2n`. The coset-type determines the double class of the |
2625 | | permutation, that is its image in `H_n \ S_2n / H_n`, where `H_n` is the |
2626 | | hyperoctahedral group of order `n`. See I. G. Macdonald, Symmetric |
2627 | | functions and Hall polynomials, Oxford University Press, second edition, |
2628 | | 1995 (chapter VII) for more details. |
2629 | | |
2630 | | EXAMPLE:: |
2631 | | |
2632 | | sage: Permutation([3, 4, 6, 1, 5, 7, 2, 8]).coset_type() |
2633 | | [3, 1] |
2634 | | sage: all([p.coset_type()==p.inverse().coset_type() |
2635 | | ... for p in Permutations(4)]) |
2636 | | True |
2637 | | """ |
2638 | 2649 | n = len(self) |
2639 | 2650 | if n%2==1: |
2640 | 2651 | raise ValueError, "%s is a permutation of odd size and has no coset-type"%p |