Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/combinat/iet/iet.py
4072 views
1
r"""
2
Interval Exchange Transformations and Linear Involution
3
4
An interval exchage transformation is a map defined on an interval (see
5
help(iet.IntervalExchangeTransformation) for a more complete help.
6
7
EXAMPLES:
8
9
Initialization of a simple iet with integer lengths::
10
11
sage: T = iet.IntervalExchangeTransformation(Permutation([3,2,1]), [3,1,2])
12
sage: print T
13
Interval exchange transformation of [0, 6[ with permutation
14
1 2 3
15
3 2 1
16
17
Rotation corresponds to iet with two intervals::
18
19
sage: p = iet.Permutation('a b', 'b a')
20
sage: T = iet.IntervalExchangeTransformation(p, [1, (sqrt(5)-1)/2])
21
sage: print T.in_which_interval(0)
22
a
23
sage: print T.in_which_interval(T(0))
24
a
25
sage: print T.in_which_interval(T(T(0)))
26
b
27
sage: print T.in_which_interval(T(T(T(0))))
28
a
29
30
There are two plotting methods for iet::
31
32
sage: p = iet.Permutation('a b c','c b a')
33
sage: T = iet.IntervalExchangeTransformation(p, [1, 2, 3])
34
35
.. plot the domain and the range of T::
36
37
sage: T.plot_two_intervals()
38
39
.. plot T as a function::
40
41
sage: T.plot_function()
42
"""
43
from copy import copy
44
from sage.structure.sage_object import SageObject
45
46
from template import side_conversion, interval_conversion
47
48
class IntervalExchangeTransformation(SageObject):
49
r"""
50
Interval exchange transformation
51
52
INPUT:
53
54
- ``permutation`` - a permutation (LabelledPermutationIET)
55
56
- ``lengths`` - the list of lengths
57
58
EXAMPLES:
59
60
Direct initialization::
61
62
sage: p = iet.IET(('a b c','c b a'),{'a':1,'b':1,'c':1})
63
sage: p.permutation()
64
a b c
65
c b a
66
sage: p.lengths()
67
[1, 1, 1]
68
69
Initialization from a iet.Permutation::
70
71
sage: perm = iet.Permutation('a b c','c b a')
72
sage: l = [0.5,1,1.2]
73
sage: t = iet.IET(perm,l)
74
sage: t.permutation() == perm
75
True
76
sage: t.lengths() == l
77
True
78
79
Initialization from a Permutation::
80
81
sage: p = Permutation([3,2,1])
82
sage: iet.IET(p, [1,1,1])
83
Interval exchange transformation of [0, 3[ with permutation
84
1 2 3
85
3 2 1
86
87
If it is not possible to convert lengths to real values an error is raised::
88
89
sage: iet.IntervalExchangeTransformation(('a b','b a'),['e','f'])
90
Traceback (most recent call last):
91
...
92
TypeError: unable to convert x (='e') into a real number
93
94
The value for the lengths must be positive::
95
96
sage: iet.IET(('a b','b a'),[-1,-1])
97
Traceback (most recent call last):
98
...
99
ValueError: lengths must be positive
100
"""
101
def __init__(self,permutation=None,lengths=None):
102
r"""
103
INPUT:
104
105
- ``permutation`` - a permutation (LabelledPermutationIET)
106
107
- ``lengths`` - the list of lengths
108
109
TEST::
110
111
sage: p=iet.IntervalExchangeTransformation(('a','a'),[1])
112
sage: p == loads(dumps(p))
113
True
114
"""
115
from labelled import LabelledPermutationIET
116
if permutation is None or lengths is None:
117
self._permutation = LabelledPermutationIET()
118
self._lengths = []
119
else:
120
self._permutation = permutation
121
self._lengths = lengths
122
123
def permutation(self):
124
r"""
125
Returns the permutation associated to this iet.
126
127
OUTPUT:
128
129
permutation -- the permutation associated to this iet
130
131
EXAMPLES::
132
133
sage: perm = iet.Permutation('a b c','c b a')
134
sage: p = iet.IntervalExchangeTransformation(perm,(1,2,1))
135
sage: p.permutation() == perm
136
True
137
"""
138
return copy(self._permutation)
139
140
def length(self):
141
r"""
142
Returns the total length of the interval.
143
144
OUTPUT:
145
146
real -- the length of the interval
147
148
EXAMPLES::
149
150
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1])
151
sage: t.length()
152
2
153
"""
154
return sum(self._lengths)
155
156
def lengths(self):
157
r"""
158
Returns the list of lengths associated to this iet.
159
160
OUTPUT:
161
162
list -- the list of lengths of subinterval
163
164
EXAMPLES::
165
166
sage: p = iet.IntervalExchangeTransformation(('a b','b a'),[1,3])
167
sage: p.lengths()
168
[1, 3]
169
"""
170
return copy(self._lengths)
171
172
def normalize(self, total=1):
173
r"""
174
Returns a interval exchange transformation of normalized lengths.
175
176
The normalization consist in consider a constant homothetic value for
177
each lengths in such way that the sum is given (default is 1).
178
179
INPUT:
180
181
- ``total`` - (default: 1) The total length of the interval
182
183
OUTPUT:
184
185
iet -- the normalized iet
186
187
EXAMPLES::
188
189
sage: t = iet.IntervalExchangeTransformation(('a b','b a'), [1,3])
190
sage: t.length()
191
4
192
sage: s = t.normalize(2)
193
sage: s.length()
194
2
195
sage: s.lengths()
196
[1/2, 3/2]
197
"""
198
try:
199
y = float(total)
200
except ValueError:
201
raise TypeError, "unable to convert x (='%s') into a real number" %(str(x))
202
203
if total <= 0:
204
raise ValueError, "the total length must be positive"
205
206
res = copy(self)
207
coeff = total / res.length()
208
res._multiply_lengths(coeff)
209
return res
210
211
def _multiply_lengths(self,x):
212
r"""
213
Multiplies the lengths of self by x (no verification on x).
214
215
INPUT:
216
217
- ``x`` - a positive number
218
219
TESTS::
220
221
sage: t = iet.IET(("a","a"), [1])
222
sage: t.lengths()
223
[1]
224
sage: t._multiply_lengths(2)
225
sage: t.lengths()
226
[2]
227
"""
228
self._lengths = map(lambda t: t*x, self._lengths)
229
230
def _repr_(self):
231
r"""
232
A representation string.
233
234
EXAMPLES::
235
236
sage: a = iet.IntervalExchangeTransformation(('a','a'),[1])
237
sage: a #indirect doctest
238
Interval exchange transformation of [0, 1[ with permutation
239
a
240
a
241
"""
242
interval = "[0, %s["%self.length()
243
s = "Interval exchange transformation of %s "%interval
244
s += "with permutation\n%s"%self._permutation
245
return s
246
247
def is_identity(self):
248
r"""
249
Returns True if self is the identity.
250
251
OUTPUT:
252
253
boolean -- the answer
254
255
EXAMPLES::
256
257
sage: p = iet.Permutation("a b","b a")
258
sage: q = iet.Permutation("c d","d c")
259
sage: s = iet.IET(p, [1,5])
260
sage: t = iet.IET(q, [5,1])
261
sage: (s*t).is_identity()
262
True
263
sage: (t*s).is_identity()
264
True
265
"""
266
return self._permutation.is_identity()
267
268
def inverse(self):
269
r"""
270
Returns the inverse iet.
271
272
OUTPUT:
273
274
iet -- the inverse interval exchange transformation
275
276
EXAMPLES::
277
278
sage: p = iet.Permutation("a b","b a")
279
sage: s = iet.IET(p, [1,sqrt(2)-1])
280
sage: t = s.inverse()
281
sage: t.permutation()
282
b a
283
a b
284
sage: t.lengths()
285
[1, sqrt(2) - 1]
286
sage: t*s
287
Interval exchange transformation of [0, sqrt(2)[ with permutation
288
aa bb
289
aa bb
290
291
We can verify with the method .is_identity()::
292
293
sage: p = iet.Permutation("a b c d","d a c b")
294
sage: s = iet.IET(p, [1, sqrt(2), sqrt(3), sqrt(5)])
295
sage: (s * s.inverse()).is_identity()
296
True
297
sage: (s.inverse() * s).is_identity()
298
True
299
"""
300
res = copy(self)
301
res._permutation._inversed()
302
return res
303
304
def __mul__(self, other):
305
r"""
306
Composition of iet.
307
308
The domain (i.e. the length) of the two iets must be the same). The
309
alphabet choosen depends on the permutation.
310
311
TESTS:
312
313
::
314
315
sage: p = iet.Permutation("a b", "a b")
316
sage: t = iet.IET(p, [1,1])
317
sage: r = t*t
318
sage: r.permutation()
319
aa bb
320
aa bb
321
sage: r.lengths()
322
[1, 1]
323
324
::
325
326
sage: p = iet.Permutation("a b","b a")
327
sage: t = iet.IET(p, [1,1])
328
sage: r = t*t
329
sage: r.permutation()
330
ab ba
331
ab ba
332
sage: r.lengths()
333
[1, 1]
334
335
::
336
337
sage: p = iet.Permutation("1 2 3 4 5","5 4 3 2 1")
338
sage: q = iet.Permutation("a b","b a")
339
sage: s = iet.IET(p, [1]*5)
340
sage: t = iet.IET(q, [1/2, 9/2])
341
sage: r = s*t
342
sage: r.permutation()
343
a5 b1 b2 b3 b4 b5
344
b5 a5 b4 b3 b2 b1
345
sage: r.lengths()
346
[1/2, 1, 1, 1, 1, 1/2]
347
sage: r = t*s
348
sage: r.permutation()
349
1b 2b 3b 4b 5a 5b
350
5b 4b 3b 2b 1b 5a
351
sage: r.lengths()
352
[1, 1, 1, 1, 1/2, 1/2]
353
sage: t = iet.IET(q, [3/2, 7/2])
354
sage: r = s*t
355
sage: r.permutation()
356
a4 a5 b1 b2 b3 b4
357
a5 b4 a4 b3 b2 b1
358
sage: r.lengths()
359
[1/2, 1, 1, 1, 1, 1/2]
360
sage: t = iet.IET(q, [5/2,5/2])
361
sage: r = s*t
362
sage: r.permutation()
363
a3 a4 a5 b1 b2 b3
364
a5 a4 b3 a3 b2 b1
365
sage: r = t*s
366
sage: r.permutation()
367
1b 2b 3a 3b 4a 5a
368
3b 2b 1b 5a 4a 3a
369
370
::
371
372
sage: p = iet.Permutation("a b","b a")
373
sage: s = iet.IET(p, [4,2])
374
sage: q = iet.Permutation("c d","d c")
375
sage: t = iet.IET(q, [3, 3])
376
sage: r1 = t * s
377
sage: r1.permutation()
378
ac ad bc
379
ad bc ac
380
sage: r1.lengths()
381
[1, 3, 2]
382
sage: r2 = s * t
383
sage: r2.permutation()
384
ca cb da
385
cb da ca
386
sage: r2.lengths()
387
[1, 2, 3]
388
"""
389
assert(
390
isinstance(other, IntervalExchangeTransformation) and
391
self.length() == other.length())
392
393
from labelled import LabelledPermutationIET
394
from sage.combinat.words.words import Words
395
396
other_sg = other.range_singularities()[1:]
397
self_sg = self.domain_singularities()[1:]
398
399
n_other = len(other._permutation)
400
n_self = len(self._permutation)
401
402
interval_other = other._permutation._intervals[1]
403
interval_self = self._permutation._intervals[0]
404
405
d_other = dict([(i,[]) for i in interval_other])
406
d_self = dict([(i,[]) for i in interval_self])
407
408
i_other = 0
409
i_self = 0
410
411
x = 0
412
l_lengths = []
413
while i_other < n_other and i_self < n_self:
414
j_other = interval_other[i_other]
415
j_self = interval_self[i_self]
416
417
d_other[j_other].append(j_self)
418
d_self[j_self].append(j_other)
419
420
if other_sg[i_other] < self_sg[i_self]:
421
l = other_sg[i_other] - x
422
x = other_sg[i_other]
423
i_other += 1
424
elif other_sg[i_other] > self_sg[i_self]:
425
l = self_sg[i_self] - x
426
x = self_sg[i_self]
427
i_self += 1
428
else:
429
l = self_sg[i_self] - x
430
x = self_sg[i_self]
431
i_other += 1
432
i_self += 1
433
434
l_lengths.append(((j_other,j_self),l))
435
436
alphabet_other = other._permutation.alphabet()
437
alphabet_self = self._permutation.alphabet()
438
439
d_lengths = dict(l_lengths)
440
441
l_lengths = []
442
top_interval = []
443
for i in other._permutation._intervals[0]:
444
for j in d_other[i]:
445
a = alphabet_other.unrank(i)
446
b = alphabet_self.unrank(j)
447
top_interval.append(str(a)+str(b))
448
l_lengths.append(d_lengths[(i,j)])
449
450
bottom_interval = []
451
for i in self._permutation._intervals[1]:
452
for j in d_self[i]:
453
a = alphabet_other.unrank(j)
454
b = alphabet_self.unrank(i)
455
bottom_interval.append(str(a)+str(b))
456
457
p = LabelledPermutationIET((top_interval,bottom_interval))
458
return IntervalExchangeTransformation(p,l_lengths)
459
460
def __eq__(self, other):
461
r"""
462
Tests equality
463
464
TESTS::
465
466
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1])
467
sage: t == t
468
True
469
"""
470
return (
471
type(self) == type(other) and
472
self._permutation == other._permutation and
473
self._lengths == other._lengths)
474
475
def __ne__(self, other):
476
r"""
477
Tests difference
478
479
TESTS::
480
481
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1])
482
sage: t != t
483
False
484
"""
485
return (
486
type(self) != type(other) or
487
self._permutation != other._permutation or
488
self._lengths != other._lengths)
489
490
def in_which_interval(self, x, interval=0):
491
r"""
492
Returns the letter for which x is in this interval.
493
494
INPUT:
495
496
- ``x`` - a positive number
497
498
- ``interval`` - (default: 'top') 'top' or 'bottom'
499
500
501
OUTPUT:
502
503
label -- a label corresponding to an interval
504
505
TEST:
506
507
::
508
509
sage: t = iet.IntervalExchangeTransformation(('a b c','c b a'),[1,1,1])
510
sage: t.in_which_interval(0)
511
'a'
512
sage: t.in_which_interval(0.3)
513
'a'
514
sage: t.in_which_interval(1)
515
'b'
516
sage: t.in_which_interval(1.9)
517
'b'
518
sage: t.in_which_interval(2)
519
'c'
520
sage: t.in_which_interval(2.1)
521
'c'
522
sage: t.in_which_interval(3)
523
Traceback (most recent call last):
524
...
525
ValueError: your value does not lie in [0;l[
526
527
.. and for the bottom interval::
528
529
sage: t.in_which_interval(0,'bottom')
530
'c'
531
sage: t.in_which_interval(1.2,'bottom')
532
'b'
533
sage: t.in_which_interval(2.9,'bottom')
534
'a'
535
"""
536
interval = interval_conversion(interval)
537
538
if x < 0 or x >= self.length():
539
raise ValueError, "your value does not lie in [0;l["
540
541
i = 0
542
543
while x >= 0:
544
x -= self._lengths[self._permutation._intervals[interval][i]]
545
i += 1
546
547
i -= 1
548
x += self._lengths[self._permutation._intervals[interval][i]]
549
550
j = self._permutation._intervals[interval][i]
551
return self._permutation._alphabet.unrank(j)
552
553
def singularities(self):
554
r"""
555
The list of singularities of 'T' and 'T^{-1}'.
556
557
OUTPUT:
558
559
list -- two lists of positive numbers which corresponds to extremities
560
of subintervals
561
562
EXAMPLE::
563
564
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1/2,3/2])
565
sage: t.singularities()
566
[[0, 1/2, 2], [0, 3/2, 2]]
567
"""
568
return [self.domain_singularities(),self.range_singularities()]
569
570
def domain_singularities(self):
571
r"""
572
Returns the list of singularities of T
573
574
OUTPUT:
575
576
list -- positive reals that corresponds to singularities in the top
577
interval
578
579
EXAMPLES::
580
581
sage: t = iet.IET(("a b","b a"), [1, sqrt(2)])
582
sage: t.domain_singularities()
583
[0, 1, sqrt(2) + 1]
584
"""
585
l = [0]
586
for j in self._permutation._intervals[0]:
587
l.append(l[-1] + self._lengths[j])
588
return l
589
590
def range_singularities(self):
591
r"""
592
Returns the list of singularities of `T^{-1}`
593
594
OUTPUT:
595
596
list -- real numbers that are singular for `T^{-1}`
597
598
599
EXAMPLES::
600
601
sage: t = iet.IET(("a b","b a"), [1, sqrt(2)])
602
sage: t.range_singularities()
603
[0, sqrt(2), sqrt(2) + 1]
604
"""
605
l = [0]
606
for j in self._permutation._intervals[1]:
607
l.append(l[-1] + self._lengths[j])
608
return l
609
610
def __call__(self, value):
611
r"""
612
Return the image of value by this transformation
613
614
EXAMPLES::
615
616
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1/2,3/2])
617
sage: t(0)
618
3/2
619
sage: t(1/2)
620
0
621
sage: t(1)
622
1/2
623
sage: t(3/2)
624
1
625
"""
626
assert(value >= 0 and value < self.length())
627
628
dom_sg = self.domain_singularities()
629
im_sg = self.range_singularities()
630
631
a = self.in_which_interval(value)
632
633
i0 = self._permutation[0].index(a)
634
i1 = self._permutation[1].index(a)
635
636
return value - dom_sg[i0] + im_sg[i1]
637
638
def rauzy_move(self, side='right', iterations=1):
639
r"""
640
Performs a Rauzy move.
641
642
INPUT:
643
644
- ``side`` - 'left' (or 'l' or 0) or 'right' (or 'r' or 1)
645
646
- ``iterations`` - integer (default :1) the number of iteration of Rauzy
647
moves to perform
648
649
OUTPUT:
650
651
iet -- the Rauzy move of self
652
653
EXAMPLES::
654
655
sage: phi = QQbar((sqrt(5)-1)/2)
656
sage: t1 = iet.IntervalExchangeTransformation(('a b','b a'),[1,phi])
657
sage: t2 = t1.rauzy_move().normalize(t1.length())
658
sage: l2 = t2.lengths()
659
sage: l1 = t1.lengths()
660
sage: l2[0] == l1[1] and l2[1] == l1[0]
661
True
662
"""
663
side = side_conversion(side)
664
665
res = copy(self)
666
for i in range(iterations):
667
res = res._rauzy_move(side)
668
return res
669
670
def _rauzy_move(self,side=-1):
671
r"""
672
Performs a Rauzy move
673
674
INPUT:
675
676
- ``side`` - must be 0 or -1 (no verification)
677
678
TEST:
679
680
sage: t = iet.IntervalExchangeTransformation(('a b c','c b a'),[1,1,3])
681
sage: t
682
Interval exchange transformation of [0, 5[ with permutation
683
a b c
684
c b a
685
sage: t1 = t.rauzy_move() #indirect doctest
686
sage: t1
687
Interval exchange transformation of [0, 4[ with permutation
688
a b c
689
c a b
690
sage: t2 = t1.rauzy_move() #indirect doctest
691
sage: t2
692
Interval exchange transformation of [0, 3[ with permutation
693
a b c
694
c b a
695
sage: t2.rauzy_move() #indirect doctest
696
Traceback (most recent call last):
697
...
698
ValueError: top and bottom extrem intervals have equal lengths
699
"""
700
top = self._permutation._intervals[0][side]
701
bottom = self._permutation._intervals[1][side]
702
703
length_top = self._lengths[top]
704
length_bottom = self._lengths[bottom]
705
706
if length_top > length_bottom:
707
winner = 0
708
winner_interval = top
709
loser_interval = bottom
710
elif length_top < length_bottom:
711
winner = 1
712
winner_interval = bottom
713
loser_interval = top
714
else:
715
raise ValueError, "top and bottom extrem intervals have equal lengths"
716
717
res = IntervalExchangeTransformation(([],[]),{})
718
res._permutation = self._permutation.rauzy_move(winner=winner,side=side)
719
res._lengths = self._lengths[:]
720
res._lengths[winner_interval] -= res._lengths[loser_interval]
721
722
return res
723
724
def __copy__(self):
725
r"""
726
Returns a copy of this interval exchange transformation.
727
728
EXAMPLES::
729
730
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1])
731
sage: s = copy(t)
732
sage: s == t
733
True
734
sage: s is t
735
False
736
"""
737
res = self.__class__()
738
res._permutation = copy(self._permutation)
739
res._lengths = copy(self._lengths)
740
return res
741
742
def plot_function(self,**d):
743
r"""
744
Return a plot of the interval exchange transformation as a
745
function.
746
747
INPUT:
748
749
- Any option that is accepted by line2d
750
751
OUTPUT:
752
753
2d plot -- a plot of the iet as a function
754
755
EXAMPLES::
756
757
sage: t = iet.IntervalExchangeTransformation(('a b c d','d a c b'),[1,1,1,1])
758
sage: t.plot_function(rgbcolor=(0,1,0))
759
"""
760
from sage.plot.all import Graphics
761
from sage.plot.plot import line2d
762
763
G = Graphics()
764
l = self.singularities()
765
t = self._permutation._twin
766
767
for i in range(len(self._permutation)):
768
j = t[0][i]
769
G += line2d([(l[0][i],l[1][j]),(l[0][i+1],l[1][j+1])],**d)
770
771
return G
772
773
def plot_two_intervals(
774
self,
775
position=(0,0),
776
vertical_alignment = 'center',
777
horizontal_alignment = 'left',
778
interval_height=0.1,
779
labels_height=0.05,
780
fontsize=14,
781
labels=True,
782
colors=None):
783
r"""
784
Returns a picture of the interval exchange transformation.
785
786
INPUT:
787
788
- ``position`` - a 2-uple of the position
789
790
- ``horizontal_alignment`` - left (defaut), center or right
791
792
- ``labels`` - boolean (defaut: True)
793
794
- ``fontsize`` - the size of the label
795
796
797
OUTPUT:
798
799
2d plot -- a plot of the two intervals (domain and range)
800
801
EXAMPLES::
802
803
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1])
804
sage: t.plot_two_intervals()
805
"""
806
from sage.plot.all import Graphics
807
from sage.plot.plot import line2d
808
from sage.plot.plot import text
809
from sage.plot.colors import rainbow
810
811
G = Graphics()
812
813
lengths = map(float,self._lengths)
814
total_length = sum(lengths)
815
816
if colors is None:
817
colors = rainbow(len(self._permutation), 'rgbtuple')
818
819
if horizontal_alignment == 'left':
820
s = position[0]
821
elif horizontal_alignment == 'center':
822
s = position[0] - total_length / 2
823
elif horizontal_alignment == 'right':
824
s = position[0] - total_length
825
else:
826
raise ValueError, "horizontal_alignement must be left, center or right"
827
828
top_height = position[1] + interval_height
829
for i in self._permutation._intervals[0]:
830
G += line2d([(s,top_height),(s+lengths[i],top_height)],
831
rgbcolor=colors[i])
832
if labels == True:
833
G += text(str(self._permutation._alphabet.unrank(i)),
834
(s+float(lengths[i])/2,top_height+labels_height),
835
horizontal_alignment='center',
836
rgbcolor=colors[i],
837
fontsize=fontsize)
838
839
s += lengths[i]
840
841
if horizontal_alignment == 'left':
842
s = position[0]
843
elif horizontal_alignment == 'center':
844
s = position[0] - total_length / 2
845
elif horizontal_alignment == 'right':
846
s = position[0] - total_length
847
else:
848
raise ValueError, "horizontal_alignement must be left, center or right"
849
850
bottom_height = position[1] - interval_height
851
for i in self._permutation._intervals[1]:
852
G += line2d([(s,bottom_height), (s+lengths[i],bottom_height)],
853
rgbcolor=colors[i])
854
if labels == True:
855
G += text(str(self._permutation._alphabet.unrank(i)),
856
(s+float(lengths[i])/2,bottom_height-labels_height),
857
horizontal_alignment='center',
858
rgbcolor=colors[i],
859
fontsize=fontsize)
860
s += lengths[i]
861
862
return G
863
864
plot = plot_two_intervals
865
866
def show(self):
867
r"""
868
Shows a picture of the interval exchange transformation
869
870
EXAMPLES::
871
872
sage: phi = QQbar((sqrt(5)-1)/2)
873
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,phi])
874
sage: t.show()
875
"""
876
self.plot_two_intervals().show(axes=False)
877
878
#TODO
879
# class LinearInvolution(SageObject):
880
# r"""_
881
# Linear involutions
882
# """
883
# pass
884
885