# HG changeset patch
# User hthomas@unb.ca
# Date 1304882414 10800
# Node ID 4e8c4d1ee854c0f487bff2aaefe892916baff3ab
# Parent 00fc7e12b5f07c7d64a44d6ad4224dfa55ff3dd8
#11314: Enhance method from_shape_and_word in tableau to allow English reading order
diff -r 00fc7e12b5f0 -r 4e8c4d1ee854 sage/combinat/tableau.py
a
|
b
|
|
1676 | 1676 | res[j][k] = i -1 |
1677 | 1677 | return Tableau_class(res) |
1678 | 1678 | |
1679 | | def from_shape_and_word(shape, w): |
1680 | | """ |
1681 | | Returns a tableau from a shape and word. |
| 1679 | def from_shape_and_word(shape, w, french=True): |
| 1680 | r""" |
| 1681 | Returns a tableau from a shape and word. |
| 1682 | |
| 1683 | INPUT: |
1682 | 1684 | |
| 1685 | - ``shape`` -- a partition |
| 1686 | - ``w`` -- a word whose length equals that of the partition |
| 1687 | - ``french`` -- boolean |
| 1688 | |
| 1689 | OUTPUT: |
| 1690 | |
| 1691 | A tableau, whose shape is ``shape`` and whose reading word is ``w``. |
| 1692 | If ``french`` is true, the reading word is to be read starting |
| 1693 | from the top row in French notation (= the bottom row in English notation). |
| 1694 | If ``french`` is false, the reading word is to be read starting with the |
| 1695 | top row in English notation. |
| 1696 | |
1683 | 1697 | EXAMPLES:: |
1684 | 1698 | |
1685 | 1699 | sage: from sage.combinat.tableau import from_shape_and_word |
… |
… |
|
1690 | 1704 | word: 4213 |
1691 | 1705 | sage: from_shape_and_word(shape, word) |
1692 | 1706 | [[1, 3], [2], [4]] |
| 1707 | sage: word = Word(flatten(t)) |
| 1708 | sage: from_shape_and_word(shape, word, False) |
| 1709 | [[1, 3], [2], [4]] |
| 1710 | |
1693 | 1711 | """ |
1694 | 1712 | res = [] |
1695 | 1713 | j = 0 |
1696 | | for i in reversed(range(len(shape))): |
1697 | | res.append( list(w[j:j+shape[i]]) ) |
1698 | | j += shape[i] |
1699 | | res.reverse() |
| 1714 | if french: |
| 1715 | for i in reversed(range(len(shape))): |
| 1716 | res.append( list(w[j:j+shape[i]]) ) |
| 1717 | j += shape[i] |
| 1718 | res.reverse() |
| 1719 | else: |
| 1720 | for i in range (len(shape)): |
| 1721 | res.append(list(w[j:j+shape[i]])) |
| 1722 | j += shape[i] |
1700 | 1723 | return Tableau_class(res) |
1701 | 1724 | |
1702 | 1725 | def Tableaux(n=None): |