Ticket #14763: trac_14763-review-ts.patch

File trac_14763-review-ts.patch, 10.8 KB (added by tscrim, 8 years ago)
  • sage/combinat/partition.py

    # HG changeset patch
    # User Travis Scrimshaw <tscrim@ucdavis.edu>
    # Date 1371649491 25200
    # Node ID 0571174f783e0f87ebaeca5a3a09a7e3d169e231
    # Parent  9eb303df0ce37743da33ba8414795bd9fbfa9989
    #14763: review patch.
    
    diff --git a/sage/combinat/partition.py b/sage/combinat/partition.py
    a b class Partition(CombinatorialObject, Ele 
    16691669                conj.extend([i]*(p[i-1] - p[i]))
    16701670            return Partition(conj)
    16711671
    1672     def suter_diagonal_slide(self, n, iteration=1):
     1672    def suter_diagonal_slide(self, n, exp=1):
    16731673        r"""
    1674         Return the image of the partition ``self`` under Suter's
    1675         diagonal slide `\sigma_n` on `Y_n`, where the notations used
    1676         are those defined in [Sut2002]_. (See also below for their
    1677         definitions. While [Sut2002]_ gives two *non-equivalent*
    1678         definitions for `\sigma_n`, we are using the formulaic one,
    1679         not the one using the four steps.)
    1680        
    1681         INPUT:
    1682 
    1683         - ``n`` -- nonnegative integer.
    1684 
    1685         - ``iteration`` -- an optional keyword argument which
    1686           defaults to `1`. It should be an integer, and
    1687           determines how often `\sigma_n` is to be applied.
    1688 
    1689         OUTPUT:
    1690        
    1691         The result of applying Suter's diagonal slide `\sigma_n` to
    1692         ``self``, assuming that ``self`` lies in `Y_n`. If the
    1693         optional argument ``iteration`` is set, then the slide
    1694         `\sigma_n` is applied not just once, but ``iteration`` times
    1695         (note that ``iteration`` is allowed to be negative, since
    1696         the slide has finite order).
    1697 
    1698         Here is how `Y_n` and `\sigma_n` are defined:
     1674        Return the image of ``self`` in `Y_n` under Suter's diagonal slide
     1675        `\sigma_n`, where the notations used are those defined in [Sut2002]_.
    16991676
    17001677        The set `Y_n` is defined as the set of all partitions
    1701         `\lambda` such that the hook length of the northwesternmost
    1702         cell of `\lambda` (i. e., the cell with coordinates `(1, 1)`
    1703         if we start counting from `1`) is less than `n`. (This is
    1704         considered true if `\lambda` is empty.)
    1705 
    1706         The map `\sigma_n` sends a partition
    1707         `(\lambda_1, \lambda_2, ..., \lambda_m) \in Y_n` with length
    1708         `m` to the partition
    1709         `(\lambda_2 + 1, \lambda_3 + 1, ..., \lambda_m + 1,
    1710         \underbrace{1, 1, ..., 1}_{n - m - \lambda_1\text{ ones}})`.
     1678        `\lambda` such that the hook length of the `(0, 0)`-cell (i.e. the
     1679        northwestern most cell in English notation) of `\lambda` is less
     1680        than `n`, including the empty partition.
     1681
     1682        The map `\sigma_n` sends a partition (with non-zero entries)
     1683        `(\lambda_1, \lambda_2, \ldots, \lambda_m) \in Y_n` to the partition
     1684        `(\lambda_2 + 1, \lambda_3 + 1, \ldots, \lambda_m + 1,
     1685        \underbrace{1, 1, \ldots, 1}_{n - m - \lambda_1\text{ ones}})`.
    17111686        In other words, it pads the partition with trailing zeroes
    17121687        until it has length `n - \lambda_1`, then removes its first
    17131688        part, and finally adds `1` to each part.
    class Partition(CombinatorialObject, Ele 
    17181693        partitions (:meth:`conjugate()`). This action is faithful if
    17191694        `n \geq 3`.
    17201695
    1721         EXAMPLES:
     1696        .. NOTE::
     1697
     1698            There are two *non-equivalent* definitions for `\sigma_n` in
     1699            [Sut2002]_. Here are using the formulaic one, not the one using
     1700            the four steps which actually defines `\sigma_n^{-1}` instead.
     1701
     1702        INPUT:
     1703
     1704        - ``n`` -- nonnegative integer
     1705
     1706        - ``exp`` -- (default: 1) how many times `\sigma_n` should be applied
     1707
     1708        OUTPUT:
     1709
     1710        The result of applying Suter's diagonal slide `\sigma_n` to
     1711        ``self``, assuming that ``self`` lies in `Y_n`. If the
     1712        optional argument ``exp`` is set, then the slide
     1713        `\sigma_n` is applied not just once, but ``exp`` times
     1714        (note that ``exp`` is allowed to be negative, since
     1715        the slide has finite order).
     1716
     1717        EXAMPLES::
    17221718
    17231719            sage: Partition([5,4,1]).suter_diagonal_slide(8)
    17241720            [5, 2]
    class Partition(CombinatorialObject, Ele 
    17281724            [1, 1, 1, 1, 1, 1]
    17291725            sage: Partition([]).suter_diagonal_slide(1)
    17301726            []
    1731             sage: Partition([]).suter_diagonal_slide(7, iteration=-1)
     1727            sage: Partition([]).suter_diagonal_slide(7, exp=-1)
    17321728            [6]
    1733             sage: Partition([]).suter_diagonal_slide(1, iteration=-1)
     1729            sage: Partition([]).suter_diagonal_slide(1, exp=-1)
    17341730            []
    17351731            sage: P7 = Partitions(7)
    1736             sage: all( p == p.suter_diagonal_slide(9, iteration=-1).suter_diagonal_slide(9)
     1732            sage: all( p == p.suter_diagonal_slide(9, exp=-1).suter_diagonal_slide(9)
    17371733            ....:      for p in P7 )
    17381734            True
    1739             sage: all( p == p.suter_diagonal_slide(9, iteration=3)
    1740             ....:            .suter_diagonal_slide(9, iteration=3)
    1741             ....:            .suter_diagonal_slide(9, iteration=3)
     1735            sage: all( p == p.suter_diagonal_slide(9, exp=3)
     1736            ....:            .suter_diagonal_slide(9, exp=3)
     1737            ....:            .suter_diagonal_slide(9, exp=3)
    17421738            ....:      for p in P7 )
    17431739            True
    1744             sage: all( p == p.suter_diagonal_slide(9, iteration=6)
    1745             ....:            .suter_diagonal_slide(9, iteration=6)
    1746             ....:            .suter_diagonal_slide(9, iteration=6)
     1740            sage: all( p == p.suter_diagonal_slide(9, exp=6)
     1741            ....:            .suter_diagonal_slide(9, exp=6)
     1742            ....:            .suter_diagonal_slide(9, exp=6)
    17471743            ....:      for p in P7 )
    17481744            True
    1749             sage: all( p == p.suter_diagonal_slide(9, iteration=-1)
    1750             ....:            .suter_diagonal_slide(9, iteration=1)
     1745            sage: all( p == p.suter_diagonal_slide(9, exp=-1)
     1746            ....:            .suter_diagonal_slide(9, exp=1)
    17511747            ....:      for p in P7 )
    17521748            True
     1749
     1750        Check of the assertion in [Sut2002]_ that `\sigma_n\bigl( \sigma_n(
     1751        \lambda^{\prime})^{\prime} \bigr) = \lambda`::
     1752
    17531753            sage: all( p.suter_diagonal_slide(8).conjugate()
    1754             ....:      == p.conjugate().suter_diagonal_slide(8, iteration=-1)
    1755             ....:      for p in P7 )      # Check of [Sut2002]_'s assertion
    1756             ....:                         # that \sigma_n(\sigma_n(\lambda')') = \lambda
     1754            ....:      == p.conjugate().suter_diagonal_slide(8, exp=-1)
     1755            ....:      for p in P7 )
    17571756            True
     1757
     1758        Check of Claim 1 in [Sut2002]_::
     1759
    17581760            sage: P5 = Partitions(5)
    17591761            sage: all( all( (p.suter_diagonal_slide(6) in q.suter_diagonal_slide(6).down())
    17601762            ....:           or (q.suter_diagonal_slide(6) in p.suter_diagonal_slide(6).down())
    17611763            ....:           for p in q.down() )
    1762             ....:      for q in P5 )    # Claim 1 in [Sut2002]_.
     1764            ....:      for q in P5 )
    17631765            True
    17641766
     1767        TESTS:
     1768
     1769        Check for ``exp = 0``::
     1770
     1771            sage: P = Partitions(4)
     1772            sage: all(p == p.suter_diagonal_slide(7, 0) for p in P)
     1773            True
     1774
     1775        Check for invalid input::
     1776
     1777            sage: p = Partition([2,1])
     1778            sage: p.hook_length(0, 0)
     1779            3
     1780            sage: p.suter_diagonal_slide(2)
     1781            Traceback (most recent call last):
     1782            ...
     1783            ValueError: the hook length must be less than n
     1784
    17651785        REFERENCES:
    1766        
     1786
    17671787        .. [Sut2002] Ruedi Suter.
    1768            *Youngs Lattice and Dihedral Symmetries*.
    1769            Europ. J. Combinatorics (2002) 23, 233238.
     1788           *Young's Lattice and Dihedral Symmetries*.
     1789           Europ. J. Combinatorics (2002) 23, 233--238.
    17701790           http://www.sciencedirect.com/science/article/pii/S0195669801905414
    17711791        """
    1772         if iteration == 1:
    1773             # Suter's map \sigma_n
    1774             leng = self.length()
    1775             if leng == 0:   # Taking extra care about the empty partition.
    1776                 return Partition([1] * (n - 1))
    1777             res = [i + 1 for i in self._list[1:]]
    1778             res += [1] * (n - leng - self._list[0])
    1779             return Partition(res)
    1780         elif iteration == -1:
    1781             # inverse map \sigma_n^{-1}
    1782             leng = self.length()
    1783             if leng == 0:   # Taking extra care about the empty partition.
    1784                 return Partition([n - 1])
    1785             res = [n - leng - 1]
    1786             res.extend([i - 1 for i in self._list if i > 1])
    1787             return Partition(res)
    1788         # Arbitrary number of iterations
    1789         iteration = iteration % n
    1790         sc = self
    1791         if iteration < n/2:
    1792             while iteration > 0:
    1793                 iteration -= 1
    1794                 sc = sc.suter_diagonal_slide(n)
    1795         else:
    1796             iteration = -iteration
    1797             while iteration < 0:
    1798                 iteration += 1
    1799                 sc = sc.suter_diagonal_slide(n, iteration=-1)
    1800         return sc
     1792        # Check for valid input
     1793        if len(self) > 0 and len(self) + self._list[0] - 1 >= n: # -1 since we double count the (0,0) cell
     1794            raise ValueError("the hook length must be less than n")
     1795        ret = self
     1796        # Arbitrary exp
     1797        exp = exp % n # It is at most order n
     1798        if exp > n / 2:
     1799            exp -= n
     1800        while exp != 0:
     1801            leng = len(ret)
     1802            if exp > 0:
     1803                # Suter's map \sigma_n
     1804                if leng == 0:   # Taking extra care about the empty partition.
     1805                    ret = Partition([1] * (n - 1))
     1806                    exp -= 1
     1807                    continue
     1808                res = [i + 1 for i in ret._list[1:]]
     1809                res += [1] * (n - leng - ret._list[0])
     1810                ret = Partition(res)
     1811                exp -= 1
     1812            else: # exp < 0 since if exp == 0, we would exit the while loop
     1813                # inverse map \sigma_n^{-1}
     1814                if leng == 0:   # Taking extra care about the empty partition.
     1815                    ret = Partition([n - 1])
     1816                    exp += 1
     1817                    continue
     1818                res = [n - leng - 1]
     1819                res.extend([i - 1 for i in ret._list if i > 1])
     1820                ret = Partition(res)
     1821                exp += 1
     1822        return ret
    18011823
    18021824    @combinatorial_map(name="reading tableau")
    18031825    def reading_tableau(self):
    class Partition(CombinatorialObject, Ele 
    18451867        r"""
    18461868        Return the Garnir tableau of shape ``self`` corresponding to the cell
    18471869        ``cell``. If ``cell`` `= (a,c)` then `(a+1,c)` must belong to the
    1848         diagram of the :class:`Partition` ``self``.
     1870        diagram of ``self``.
    18491871
    18501872        The Garnir tableaux play an important role in integral and
    18511873        non-semisimple representation theory because they determine the