Attachment 'Gaelans_Functions.py'

Download

   1 ############################################################
   2 # Preliminary functions that are used in combining posets: #
   3 ############################################################
   4 
   5 def max_j_value(p):
   6     m = 0
   7     for i in range(len(p.list())):
   8         if p.list()[i].element[1]>m:
   9             m = p.list()[i].element[1]
  10     return(m)
  11     
  12 def max_i_value(p):
  13     m = 0
  14     for i in range(len(p.list())):
  15         if p.list()[i].element[0]>m:
  16             m = p.list()[i].element[0]
  17     return(m)
  18     
  19 def determining_fxn(p,x):
  20     return( (max_j_value(p)/max_i_value(p))*x )
  21 
  22 ##################################
  23 # Function for combining posets: #
  24 ##################################
  25 
  26 r"""
  27 Combine two Posets, A and B, by making some b in B a cover of some a in A
  28 
  29 This function only works for posets A and B, whose elements are of the form (i,j), where i and j are integers. Also, B must contain the element (0,0)
  30 By inputting two posets A,B, and an ordered pair (x,y) (which is an element of A), the function will perform a translation, phi, on all the vertices and relations in B, so that A and phi(B) have no common elements. It will then make phi((0,0)) a cover of (x,y).
  31 Finally, the function will output the poset created from the elements of A and phi(B) and the relations of A, phi(B), and [(x,y),phi(0,0)]
  32 
  33 AUTHORS:
  34 
  35 - Gaelan Hanlon (2011-05-05): initial version
  36 
  37 Example
  38     
  39     sage: elms1 = [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)]
  40     sage: rels1 = [[(0,0),(0,1)],[(0,0),(1,0)],[(0,1),(1,1)],[(0,1),(0,2)],[(0,2),(1,2)],[(1,1),(1,2)],[(1,0),(1,1)]]
  41     sage: elms2 = [(0,0),(0,1),(1,0),(1,1),(2,0)]
  42     sage: rels2 = [[(0,0),(0,1)],[(0,0),(1,0)],[(0,1),(1,1)],[(1,0),(1,1)],[(1,0),(2,0)]]
  43     sage: P1 = Poset((elms1, rels1), cover_relations = True)
  44     sage: P2 = Poset((elms2, rels2), cover_relations = True)
  45     
  46     sage: P = join_posets(P1,P2,(0,1))
  47     Sage: P
  48     Finite poset containing 11 elements
  49     Sage: P.list()
  50     [(0, 0), (1, 0), (0, 1), (-1, 4), (-1, 5), (0, 4), (0, 5), (1, 4), (0,
  51     2), (1, 1), (1, 2)]
  52     Sage: P.cover_relations()
  53     [[(0, 0), (1, 0)], [(0, 0), (0, 1)], [(1, 0), (1, 1)], [(0, 1), (-1,
  54     4)], [(0, 1), (0, 2)], [(0, 1), (1, 1)], [(-1, 4), (-1, 5)], [(-1, 4),
  55     (0, 4)], [(-1, 5), (0, 5)], [(0, 4), (0, 5)], [(0, 4), (1, 4)], [(0, 2),
  56     (1, 2)], [(1, 1), (1, 2)]]
  57         
  58 """
  59 
  60 #*****************************************************************************
  61 #       Copyright (C) 2010 YOUR NAME <your email>
  62 #
  63 #  Distributed under the terms of the GNU General Public License (GPL)
  64 #  as published by the Free Software Foundation; either version 2 of
  65 #  the License, or (at your option) any later version.
  66 #                  http://www.gnu.org/licenses/
  67 #*****************************************************************************
  68 
  69 def join_posets(p1,p2,x):      
  70 
  71     i,j = x
  72     new_coords = []
  73     new_rels = []
  74       
  75     ##Case 1
  76     if determining_fxn(p1,i)<j:
  77         for k in range(len(p2.list())):
  78             new_coords.append( ((p2.list()[k].element[0] + i-1, p2.list()[k].element[1] + max_j_value(p1) + 2)) )
  79         for k in range(len(p2.cover_relations()) ):
  80             new_rels.append( [(p2.cover_relations()[k][0].element[0] + i-1, p2.cover_relations()[k][0].element[1] + max_j_value(p1) + 2), (p2.cover_relations()[k][1].element[0] + i-1, p2.cover_relations()[k][1].element[1] + max_j_value(p1) + 2)] )
  81         new_rels = new_rels + [ [(i,j),(i-1,max_j_value(p1) + 2)] ]
  82        
  83     ##Case 2
  84     if determining_fxn(p1,i)>=j:
  85         for k in range(len(p2.list())):
  86             new_coords.append( ((p2.list()[k].element[0] + max_i_value(p1)+2, p2.list()[k].element[1] + j-1)) )
  87         for k in range(len(p2.cover_relations()) ):
  88             new_rels.append( [(p2.cover_relations()[k][0].element[0] + max_i_value(p1)+2, p2.cover_relations()[k][0].element[1] + j-1), (p2.cover_relations()[k][1].element[0] + max_i_value(p1)+2, p2.cover_relations()[k][1].element[1] + j-1)] )
  89         new_rels = new_rels + [ [(i,j),(max_i_value(p1)+2,j-1)] ]
  90             
  91     L1=[a.element for a in p1.list()]
  92     L2=new_coords+L1
  93     R1=[[P1.cover_relations()[i][0].element,P1.cover_relations()[i][1].element] for i in range(len(P1.cover_relations()))]
  94     R2=new_rels + R1
  95        
  96     return(Poset((L2,R2)))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2011-05-06 17:55:48, 4.3 KB) [[attachment:Gaelans_Functions.py]]
  • [get | view] (2011-05-06 17:55:41, 15.9 KB) [[attachment:dcomp-poset-eric.sage]]
  • [get | view] (2011-05-06 18:26:47, 4.8 KB) [[attachment:jeu_taquin.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.