Пример #1
0
 def fixed_points_iterator(self, i=0):
     """Same as fixed_points() but acts as an interator.
     See doc string for fixed_points().
     
     NOTES: The iterator takes dramatically less time than
     fixed_points() when i gets large. For example:
     
     sage: ## TEST THE ITERATOR
     sage: plist=[8,7,6,5,4,3,2,1]
     sage: g = incidence_graph(plist)
     sage: w = ig_weights(plist,plist)
     sage: FP = fixed_points_iterator(g,w,len(plist)+1,len(plist))
     sage: t0 = cputime()
     sage: count=0
     sage: for i,fp in enumerate(FP):
     ...       if i%50000 == 0:
     ...           print cputime()-t0,",",
     ...
     sage: print "Total Time (iterator):",cputime()-t0
     0.000598000000011 , 6.469392 , 12.936641 , 19.405214 ,
     25.886539 , 32.357304 , 38.827102 , 45.297906 , Total Time
     (iterator): 46.964347
     
     Compare to 557.46 s for the same call to fixed_points()
     """
     
     # conversion of names to class context
     g = self.graph
     w = self.weights
     n = self.ic_size
     
     if i == 0:
         i = self.num_nodes
     
     (pred,succ) = self.bounds[i-1]
     node_weight = w[n+i-1]
     pred_weight = w[pred]
     weight_diff = node_weight - pred_weight
     
     # base of induction
     if i == 1:
         pred_index_set = set(self.ic_fix[pred])
         succ_index_set = set(self.ic_fix[succ])
         diff_index_set = succ_index_set.difference(pred_index_set)
         C = combinations_iterator( list(diff_index_set), weight_diff )
         for c in C:
             yield [self.ic_fix[pred] + c]
     
     elif i > 1:
         # get a fixed point associated to i-1
         FPI = self.fixed_points_iterator(i-1)
         for fp in FPI:
             fpp = self.ic_fix + fp  # tack on the initial data
             pred_index_set = set(fpp[pred])
             succ_index_set = set(fpp[succ])
             diff_index_set = succ_index_set.difference(pred_index_set)
             C = combinations_iterator( list(diff_index_set), weight_diff )
             for c in C:
                 yield fp+[fpp[pred]+c]
     else:
         yield None
Пример #2
0
 def fixed_points(self, i=0):
     """Returns a list of fixed points of the (projection of the) incidence
     variety assoc. to g,w (where we project to include only nodes 1..i). This
     allows us to build a list of fixed points for the whole incidence variety
     inductively.
     
     INPUT:
         i = How many nodes to include
             This defaults to i = num_nodes (or if i=0)
         (from self)
         g = incidence graph (result of calling incidence_graph(n,plist)
         w = weights for the nodes (result of calling ig_weights(part,plist)
             for the same plist)
         n = length of init. chain (optional). defaults to (len(w)+1)/2
     
     OUTPUT: [ fp_1, fp_2, ... ] where each fp_i is itself a list of
     index sets, one for each node from 1..i. An index set is a list of
     indices which determines the character of the $T$ action on the
     fiber of the corresponding universal bundle at the fixed point
     fp_i.
     
     NOTES:
     Tends to bog down around 8 levels of recursion, i.e.
     p=[8,7,6,5,4,3,2,1] # part and plist will be the same here
     g=incidence_graph(9,p)
     w=ig_weights(p,p)
     FP = fixed_points(g,w,9,7)   # runs for 10 sec
     FP = fixed_points(g,w,9,8)   # runs for a LONG time
     
     or...
     
     sage: plist=[8,7,6,5,4,3,2,1]
     sage: g = incidence_graph(plist)
     sage: w = ig_weights(plist,plist)
     sage: time FP2 = fixed_points(g,w,len(plist)+1,len(plist)-2)
     sage: time FP1 = fixed_points(g,w,len(plist)+1,len(plist)-1)
     sage: time FP0 = fixed_points(g,w,len(plist)+1,len(plist))
     Time: CPU 0.54 s, Wall: 0.54 s
     Time: CPU 9.14 s, Wall: 9.15 s
     Time: CPU 557.46 s, Wall: 558.66 s
     sage: len(FP2)
     5040
     sage: len(FP1)
     40320
     sage: len(FP0)
     362880
     """
     
     # conversion of names to class context
     g = self.graph
     w = self.weights
     n = self.ic_size
     
     # i defaults to 0 -- meaning i = num_nodes
     if i == 0:
         i = self.num_nodes
     
     (pred,succ) = self.bounds[i-1]
     node_weight = w[n+i-1]
     pred_weight = w[pred]
     weight_diff = node_weight - pred_weight
     
     # base of induction
     if i == 1:
         pred_index_set = set(self.ic_fix[pred])
         succ_index_set = set(self.ic_fix[succ])
         diff_index_set = succ_index_set.difference(pred_index_set)
         C = combinations_iterator( list(diff_index_set), weight_diff )
         poss = [ [self.ic_fix[pred]+c]  for c in C ]
         return poss
     elif i > 1:
         # get the result for i-1
         induct = self.fixed_points(i-1)
         poss = []
         for fp in induct:
             fpp = self.ic_fix + fp  # tack on the initial data
             pred_index_set = set(fpp[pred])
             succ_index_set = set(fpp[succ])
             diff_index_set = succ_index_set.difference(pred_index_set)
             C = combinations_iterator( list(diff_index_set), weight_diff )
             newfps = [ fp+[fpp[pred]+c] for c in C ]
             poss = poss + newfps
         return poss
     else:
         return None