Ticket #14427: trac_14427-key_tableau-review-ts.patch

File trac_14427-key_tableau-review-ts.patch, 5.9 KB (added by tscrim, 9 years ago)
  • sage/combinat/tableau.py

    # HG changeset patch
    # User Travis Scrimshaw <tscrim@ucdavis.edu>
    # Date 1365524085 25200
    # Node ID 2d70ce411f15ce69563fe18f55b1b469aae37856
    # Parent a00158b9aee92e21e5870ef015e0686c27c0da71
    #14427: Review patch.
    
    diff --git a/sage/combinat/tableau.py b/sage/combinat/tableau.py
    a b class Tableau(CombinatorialObject, Eleme 
    21882188
    21892189    def is_key_tableau(self):
    21902190        """
    2191         Returns ``True`` if ``self`` is a key tableau. Returns
    2192         ``False`` otherwise.
    2193        
    2194         A tableau is a key tableau if the set of entries in the j-th
    2195         column are a subset of the set of entries in the (j-1)-st column.
    2196        
     2191        Return ``True`` if ``self`` is a key tableau or ``False`` otherwise.
     2192
     2193        A tableau is a *key tableau* if the set of entries in the `j`-th
     2194        column are a subset of the set of entries in the `(j-1)`-st column.
     2195
     2196        REFERENCES:
     2197
     2198        .. [LS90] A. Lascoux, M.-P. Schutzenberger.
     2199           Keys and standard bases, invariant theory and tableaux.
     2200           IMA Volumes in Math and its Applications (D. Stanton, ED.).
     2201           Southend on Sea, UK, 19 (1990). 125-144.
     2202           
     2203        .. [Willis10] M. Willis. A direct way to find the right key of
     2204           a semistandard Young tableau. :arxiv:`1110.6184v1`.
     2205
    21972206        EXAMPLES::
    2198        
     2207
    21992208            sage: t = Tableau([[1,1,1],[2,3],[3]])
    22002209            sage: t.is_key_tableau()
    22012210            True
    2202            
     2211
    22032212            sage: t = Tableau([[1,1,2],[2,3],[3]])
    22042213            sage: t.is_key_tableau()
    22052214            False
    2206                
    22072215        """
    22082216        itr = enumerate(self.conjugate()[1:],1)
    2209                                                      
    2210         return all(x in self.conjugate()[i-1] for i, col in itr for x in col)
    2211    
     2217        return all(x in self.conjugate()[i-1] for i, col in itr for x in col)
     2218
    22122219    def right_key_tableau(self):
    22132220        """
    2214         Returns the right key tableau of ``self``.
    2215        
     2221        Return the right key tableau of ``self``.
     2222
     2223        The right key tableau of a tableau `T` is the key tableau whose entries
     2224        are weakly greater than the corresponding entries `T`. For a decription
     2225        of how to compute the right key tableau, see [Willis10]_.
     2226
     2227        .. SEEALSO::
     2228
     2229            - :meth:`is_key_tableau()`
     2230
    22162231        EXAMPLES::
    2217        
     2232
    22182233            sage: t = Tableau([[1,2],[2,3]])
    22192234            sage: t.right_key_tableau()
    22202235            [[2, 2], [3, 3]]
    2221 
    22222236            sage: t = Tableau([[1,1,2,4],[2,3,3],[4],[5]])
    22232237            sage: t.right_key_tableau()
    22242238            [[2, 2, 2, 4], [3, 4, 4], [4], [5]]
    22252239
    2226         REFERENCES:
    2227             - A. Lascoux, M.-P. Schutzenberger, Keys and Standard Bases, Invariant Theory and Tableaux, IMA Volumes in Math and its Applications (D. Stanton, ED.), Southend on Sea, UK, 19 (1990), 125-144.
    2228            
    2229             - M. Willis, A direct way to find the right key of a semistandard Young tableau, arXiv:1110.6184v1. 
    2230         """
    2231        
     2240        TESTS:
     2241
     2242        We check that if we have a key tableau, we return the same tableau::
     2243
     2244            sage: t = Tableau([[1,1,1,2], [2,2,2], [4], [5]])
     2245            sage: t.is_key_tableau()
     2246            True
     2247            sage: t.right_key_tableau() == t
     2248            True
     2249        """
     2250        if self.is_key_tableau():
     2251            return self
     2252
    22322253        key = [[] for row in self.conjugate()]
    22332254        cols_list = self.conjugate().to_list()
    2234        
     2255
    22352256        for i, col_a in enumerate(cols_list):
    22362257            right_cols = cols_list[i+1:]
    22372258            for elem in reversed(col_a):
    class Tableau(CombinatorialObject, Eleme 
    22492270               
    22502271    def left_key_tableau(self):
    22512272        """
    2252         Returns the left key tableau of ``self``.
    2253        
     2273        Return the left key tableau of ``self``.
     2274
     2275        The left key tableau of a tableau `T` is the key tableau whose entries
     2276        are weakly lesser than the corresponding entries in `T`. For a
     2277        decription of how to compute the left key tableau, see [Willis10]_.
     2278
     2279        .. SEEALSO::
     2280
     2281            - :meth:`is_key_tableau()`
     2282
    22542283        EXAMPLES::
    2255        
     2284
    22562285            sage: t = Tableau([[1,2],[2,3]])
    22572286            sage: t.left_key_tableau()
    22582287            [[1, 1], [2, 2]]
    2259 
    22602288            sage: t = Tableau([[1,1,2,4],[2,3,3],[4],[5]])
    22612289            sage: t.left_key_tableau()
    22622290            [[1, 1, 1, 2], [2, 2, 2], [4], [5]]
    22632291
    2264         REFERENCES:
    2265             - A. Lascoux, M.-P. Schutzenberger, Keys and Standard Bases, Invariant Theory and Tableaux, IMA Volumes in Math and its Applications (D. Stanton, ED.), Southend on Sea, UK, 19 (1990), 125-144.
    2266            
    2267             - M. Willis, A direct way to find the right key of a semistandard Young tableau, arXiv:1110.6184v1.             
    2268         """
    2269        
     2292        TESTS:
     2293
     2294        We check that if we have a key tableau, we return the same tableau::
     2295
     2296            sage: t = Tableau([[1,1,1,2], [2,2,2], [4], [5]])
     2297            sage: t.is_key_tableau()
     2298            True
     2299            sage: t.left_key_tableau() == t
     2300            True
     2301        """
     2302        if self.is_key_tableau():
     2303            return self
     2304
    22702305        key = [[] for row in self.conjugate()]
    22712306        key[0] = self.conjugate()[0]
    22722307        cols_list = self.conjugate().to_list()
    2273        
     2308
    22742309        from bisect import bisect_right
    2275        
    22762310        for i, col_a in enumerate(cols_list[1:],1):
    22772311            left_cols = cols_list[:i]
    22782312            for elem in reversed(col_a):
    class Tableau(CombinatorialObject, Eleme 
    22812315                for col_b in reversed(left_cols):
    22822316                    j = bisect_right(col_b, key_val) - 1
    22832317                    key_val = col_b[j]
    2284                     update.insert(0, col_b[:j]) 
     2318                    update.insert(0, col_b[:j])
    22852319                left_cols = update
    22862320                key[i].insert(0,key_val)
    22872321        return Tableau(key).conjugate()