Ticket #13233: trac_13233-add_sstposet.patch

File trac_13233-add_sstposet.patch, 2.4 KB (added by jcbeier, 10 years ago)
  • sage/combinat/posets/poset_examples.py

    # HG changeset patch
    # User J. Beier <hidden adress email>
    # Date 1342190895 14400
    # Node ID 1b88d4f7778e635b7bad83afd1887f8f6777fd7f
    # Parent  1b03835b81c89f2b55d9bca19fcb1a9647c63974
    #13233: add a poset example on SST using a niave ordering
    
    diff --git a/sage/combinat/posets/poset_examples.py b/sage/combinat/posets/poset_examples.py
    a b  
    373373        return Poset(D,cover_relations=False)
    374374
    375375    @staticmethod
     376    def SSTPoset(s,f=None):
     377        """
     378        The poset on semistandard tableaux of shape s and largest entry f that is ordered by componentwise comparison of the entries.
     379   
     380        INPUT:
     381
     382        - ``s`` - shape of the tableaux
     383
     384        - ``f`` - maximum fill number.  This is an optional argument.  If no maximal number is given, it will use the number of cells in the shape.
     385   
     386        NOTE: This is basic implementation and most certainly not the most efficient.
     387   
     388        EXAMPLES::
     389   
     390            sage: Posets.SSTPoset([2,1])
     391            Finite poset containing 8 elements
     392   
     393            sage: Posets.SSTPoset([2,1],4)
     394            Finite poset containing 20 elements
     395
     396            sage: Posets.SSTPoset([2,1],2).cover_relations()
     397            [[[[1, 1], [2]], [[1, 2], [2]]]]
     398
     399            sage: Posets.SSTPoset([3,2]).bottom()
     400            [[1, 1, 1], [2, 2]]
     401
     402            sage: Posets.SSTPoset([3,2],4).maximal_elements()
     403            [[[3, 3, 4], [4, 4]]]
     404        """
     405        from sage.combinat.tableau import SemistandardTableaux
     406        def tableaux_is_less_than(a,b):
     407            atstring = []
     408            btstring = []
     409            c=0
     410            d=0
     411            for i in range(len(a)):
     412                atstring=atstring+a[i]
     413            for i in range(len(b)):
     414                btstring=btstring+b[i]
     415            for i in range(len(atstring)):
     416                if atstring[i] > btstring[i]:
     417                    c = c+1
     418            if c == 0:
     419                return True
     420            else:
     421                return False
     422        if f is None:
     423            f=0
     424            for i in range(len(s)):
     425                f = f+s[i]
     426        E = SemistandardTableaux(s,max_entry=f)
     427        return Poset((E, tableaux_is_less_than ))
     428
     429    @staticmethod
    376430    def SymmetricGroupBruhatOrderPoset(n):
    377431        """
    378432        The poset of permutations with respect to Bruhat order.