Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168722
Image: ubuntu2004
IntervalExchangeMap Iem class
Yuki Tangiku : [email protected]
#EXAMPLE abc -> cba a:1 b:2 c:3 U = Iem(('a b c','c b a'),[1,2,3]) U.show_new() U.normalize_permutation();U.matrix_omega()
'321' [ 0 1 1] [-1 0 1] [-1 -1 0]
#Notice!!preparation! looking for iet.iet #<class 'sage.combinat.iet.iet.IntervalExchangeTransformation'> T = iet.IntervalExchangeTransformation(('a b','b a'),(sqrt(2),1)) print type(T)
<class 'sage.combinat.iet.iet.IntervalExchangeTransformation'>
r""" =========================================== IntervalExchangeMap Iem class show_new() by Yuki Tangiku [email protected] using iet package =========================================== sage: U = Iem(('a b c','c b a'),[1,2,3]) sage: U.show_new() sage: U.normalize_permutation() '321' """ import sage.combinat.iet as s class Iem(s.iet.IntervalExchangeTransformation): def __init__(self,permutation,lenths): super(Iem, self).__init__(permutation,lenths) if type(permutation) == tuple: self._permutation = s.constructors.Permutation(permutation) self.letter = len(self._permutation) def plot_new(self ,v ,w): r""" show a picure of the interval exchange map with "[ )" and so on. v - interval height w - distance between "[" and ")" """ from sage.plot.plot import line2d from sage.plot.colors import rainbow cl = rainbow(len(self._permutation),'rgbtuple') G = Graphics() G = self.plot_two_intervals(interval_height=v,colors=cl) u = self.length() lengths = map(float,self._lengths) l = len(self._lengths) G += line2d([(0,-v),(0,v)],linestyle='dotted',rgbcolor=(1/4,1/8,3/4)) G += line2d([(u,-v),(u,v)],linestyle='dotted',rgbcolor=(1/4,1/8,3/4)) G += text("[",(0,v),fontsize=15,rgbcolor='maroon') G += text("[",(0,-v),fontsize=15,rgbcolor='maroon') G += text(")",(u,v),fontsize=15,rgbcolor='maroon') G += text(")",(u,-v),fontsize=15,rgbcolor='maroon') s=0 for i in self._permutation._intervals[0]: l = 0 k = self._permutation._intervals[1].index(i) j = 0 while j < k: l += lengths[self._permutation._intervals[1][j]] j += 1 G += line2d([(s,v),(l,-v)],linestyle='dotted',rgbcolor=cl[i]) d = lengths[i] G += line2d([(s+d,v),(l+d,-v)],linestyle='dotted',rgbcolor=cl[i]) s += d if i != len(self._lengths)-1: G += text("[",(s,v),fontsize=15,rgbcolor='maroon') G += text(")",(s-w,v),fontsize=15,rgbcolor='maroon') s=0 for i in self._permutation._intervals[1][:-1]: s += lengths[i] G += text("[",(s,-v),fontsize=15,rgbcolor='maroon') G += text(")",(s-w,-v),fontsize=15,rgbcolor='maroon') return G def show_new(self,v=0.5,w=0.05): self.plot_new(v,w).show(axes = False) def normalize_permutation(self): t = '' for i in self._permutation[1]: k = self._permutation[0].index(i) t += str(int(k)+1) return t def _maptoindex(self,k): k = str(k) return self.normalize_permutation().index(k)+1 def maptoindex_str(self): t = '' for i in range(self.letter): t += str(self._maptoindex(i+1)) return t def _position(self,i,j): l = self.maptoindex_str() u = int(l[i-1]) v = int(l[j-1]) if i > j and u < v: return -1 elif i < j and u > v: return 1 else: return 0 def matrix_omega(self): return matrix(self.letter, lambda i,j: self._position(i+1,j+1))
V = Iem(('a b c d e','b d a e c'),[2,1,2,4,3]) V.show_new(0.5,0.1)
V.normalize_permutation()
'24153'
V.matrix_omega()
[ 0 1 0 1 0] [-1 0 0 0 0] [ 0 0 0 1 1] [-1 0 -1 0 0] [ 0 0 -1 0 0]