Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
r""" Interval Exchange Transformations and Linear Involution
.. WARNING::
This module is deprecated. You are advised to install and use the surface_dynamics package instead available at https://pypi.python.org/pypi/surface_dynamics/
An interval exchange transformation is a map defined on an interval (see help(iet.IntervalExchangeTransformation) for a more complete help.
EXAMPLES:
Initialization of a simple iet with integer lengths::
sage: T = iet.IntervalExchangeTransformation(Permutation([3,2,1]), [3,1,2]) doctest:warning ... DeprecationWarning: IntervalExchangeTransformation is deprecated and will be removed from Sage. You are advised to install the surface_dynamics package via: sage -pip install surface_dynamics If you do not have write access to the Sage installation you can alternatively do sage -pip install surface_dynamics --user The package surface_dynamics subsumes all flat surface related computation that are currently available in Sage. See more information at http://www.labri.fr/perso/vdelecro/surface-dynamics/latest/ See http://trac.sagemath.org/20695 for details. doctest:warning ... DeprecationWarning: Permutation is deprecated and will be removed from Sage. You are advised to install the surface_dynamics package via: sage -pip install surface_dynamics If you do not have write access to the Sage installation you can alternatively do sage -pip install surface_dynamics --user The package surface_dynamics subsumes all flat surface related computation that are currently available in Sage. See more information at http://www.labri.fr/perso/vdelecro/surface-dynamics/latest/ See http://trac.sagemath.org/20695 for details. sage: T Interval exchange transformation of [0, 6[ with permutation 1 2 3 3 2 1
Rotation corresponds to iet with two intervals::
sage: p = iet.Permutation('a b', 'b a') sage: T = iet.IntervalExchangeTransformation(p, [1, (sqrt(5)-1)/2]) sage: print(T.in_which_interval(0)) a sage: print(T.in_which_interval(T(0))) a sage: print(T.in_which_interval(T(T(0)))) b sage: print(T.in_which_interval(T(T(T(0))))) a
There are two plotting methods for iet::
sage: p = iet.Permutation('a b c','c b a') sage: T = iet.IntervalExchangeTransformation(p, [1, 2, 3])
.. plot the domain and the range of T::
sage: T.plot_two_intervals() Graphics object consisting of 12 graphics primitives
.. plot T as a function::
sage: T.plot_function() Graphics object consisting of 3 graphics primitives """
r""" Interval exchange transformation
INPUT:
- ``permutation`` - a permutation (LabelledPermutationIET)
- ``lengths`` - the list of lengths
EXAMPLES:
Direct initialization::
sage: p = iet.IET(('a b c','c b a'),{'a':1,'b':1,'c':1}) sage: p.permutation() a b c c b a sage: p.lengths() [1, 1, 1]
Initialization from a iet.Permutation::
sage: perm = iet.Permutation('a b c','c b a') sage: l = [0.5,1,1.2] sage: t = iet.IET(perm,l) sage: t.permutation() == perm True sage: t.lengths() == l True
Initialization from a Permutation::
sage: p = Permutation([3,2,1]) sage: iet.IET(p, [1,1,1]) Interval exchange transformation of [0, 3[ with permutation 1 2 3 3 2 1
If it is not possible to convert lengths to real values an error is raised::
sage: iet.IntervalExchangeTransformation(('a b','b a'),['e','f']) Traceback (most recent call last): ... TypeError: unable to convert 'e' to a float
The value for the lengths must be positive::
sage: iet.IET(('a b','b a'),[-1,-1]) Traceback (most recent call last): ... ValueError: lengths must be positive """ r""" INPUT:
- ``permutation`` - a permutation (LabelledPermutationIET)
- ``lengths`` - the list of lengths
TESTS::
sage: p=iet.IntervalExchangeTransformation(('a','a'),[1]) sage: p == loads(dumps(p)) True """ else:
r""" Returns the permutation associated to this iet.
OUTPUT:
permutation -- the permutation associated to this iet
EXAMPLES::
sage: perm = iet.Permutation('a b c','c b a') sage: p = iet.IntervalExchangeTransformation(perm,(1,2,1)) sage: p.permutation() == perm True """
r""" Returns the total length of the interval.
OUTPUT:
real -- the length of the interval
EXAMPLES::
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1]) sage: t.length() 2 """
r""" Returns the list of lengths associated to this iet.
OUTPUT:
list -- the list of lengths of subinterval
EXAMPLES::
sage: p = iet.IntervalExchangeTransformation(('a b','b a'),[1,3]) sage: p.lengths() [1, 3] """
r""" Returns a interval exchange transformation of normalized lengths.
The normalization consists in multiplying all lengths by a constant in such way that their sum is given by ``total`` (default is 1).
INPUT:
- ``total`` - (default: 1) The total length of the interval
OUTPUT:
iet -- the normalized iet
EXAMPLES::
sage: t = iet.IntervalExchangeTransformation(('a b','b a'), [1,3]) sage: t.length() 4 sage: s = t.normalize(2) sage: s.length() 2 sage: s.lengths() [1/2, 3/2]
TESTS::
sage: s = t.normalize('bla') Traceback (most recent call last): ... TypeError: unable to convert 'bla' to a float sage: s = t.normalize(-691) Traceback (most recent call last): ... ValueError: the total length must be positive """
r""" Multiplies the lengths of self by x (no verification on x).
INPUT:
- ``x`` - a positive number
TESTS::
sage: t = iet.IET(("a","a"), [1]) sage: t.lengths() [1] sage: t._multiply_lengths(2) sage: t.lengths() [2] """
r""" A representation string.
EXAMPLES::
sage: a = iet.IntervalExchangeTransformation(('a','a'),[1]) sage: a # indirect doctest Interval exchange transformation of [0, 1[ with permutation a a """
r""" Returns True if self is the identity.
OUTPUT:
boolean -- the answer
EXAMPLES::
sage: p = iet.Permutation("a b","b a") sage: q = iet.Permutation("c d","d c") sage: s = iet.IET(p, [1,5]) sage: t = iet.IET(q, [5,1]) sage: (s*t).is_identity() True sage: (t*s).is_identity() True """
r""" Returns the inverse iet.
OUTPUT:
iet -- the inverse interval exchange transformation
EXAMPLES::
sage: p = iet.Permutation("a b","b a") sage: s = iet.IET(p, [1,sqrt(2)-1]) sage: t = s.inverse() sage: t.permutation() b a a b sage: t.lengths() [1, sqrt(2) - 1] sage: t*s Interval exchange transformation of [0, sqrt(2)[ with permutation aa bb aa bb
We can verify with the method .is_identity()::
sage: p = iet.Permutation("a b c d","d a c b") sage: s = iet.IET(p, [1, sqrt(2), sqrt(3), sqrt(5)]) sage: (s * s.inverse()).is_identity() True sage: (s.inverse() * s).is_identity() True """
r""" Composition of iet.
The domain (i.e. the length) of the two iets must be the same). The alphabet choosen depends on the permutation.
TESTS:
::
sage: p = iet.Permutation("a b", "a b") sage: t = iet.IET(p, [1,1]) sage: r = t*t sage: r.permutation() aa bb aa bb sage: r.lengths() [1, 1]
::
sage: p = iet.Permutation("a b","b a") sage: t = iet.IET(p, [1,1]) sage: r = t*t sage: r.permutation() ab ba ab ba sage: r.lengths() [1, 1]
::
sage: p = iet.Permutation("1 2 3 4 5","5 4 3 2 1") sage: q = iet.Permutation("a b","b a") sage: s = iet.IET(p, [1]*5) sage: t = iet.IET(q, [1/2, 9/2]) sage: r = s*t sage: r.permutation() a5 b1 b2 b3 b4 b5 b5 a5 b4 b3 b2 b1 sage: r.lengths() [1/2, 1, 1, 1, 1, 1/2] sage: r = t*s sage: r.permutation() 1b 2b 3b 4b 5a 5b 5b 4b 3b 2b 1b 5a sage: r.lengths() [1, 1, 1, 1, 1/2, 1/2] sage: t = iet.IET(q, [3/2, 7/2]) sage: r = s*t sage: r.permutation() a4 a5 b1 b2 b3 b4 a5 b4 a4 b3 b2 b1 sage: r.lengths() [1/2, 1, 1, 1, 1, 1/2] sage: t = iet.IET(q, [5/2,5/2]) sage: r = s*t sage: r.permutation() a3 a4 a5 b1 b2 b3 a5 a4 b3 a3 b2 b1 sage: r = t*s sage: r.permutation() 1b 2b 3a 3b 4a 5a 3b 2b 1b 5a 4a 3a
::
sage: p = iet.Permutation("a b","b a") sage: s = iet.IET(p, [4,2]) sage: q = iet.Permutation("c d","d c") sage: t = iet.IET(q, [3, 3]) sage: r1 = t * s sage: r1.permutation() ac ad bc ad bc ac sage: r1.lengths() [1, 3, 2] sage: r2 = s * t sage: r2.permutation() ca cb da cb da ca sage: r2.lengths() [1, 2, 3]
::
sage: r * s Traceback (most recent call last): ... ValueError: self and other are not IET of the same length """ self.length() == other.length()):
else:
r""" Tests equality
TESTS::
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1]) sage: t == t True """ type(self) is type(other) and self._permutation == other._permutation and self._lengths == other._lengths)
r""" Tests difference
TESTS::
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1]) sage: t != t False """ type(self) is not type(other) or self._permutation != other._permutation or self._lengths != other._lengths)
r""" Returns the letter for which x is in this interval.
INPUT:
- ``x`` - a positive number
- ``interval`` - (default: 'top') 'top' or 'bottom'
OUTPUT:
label -- a label corresponding to an interval
TESTS:
::
sage: t = iet.IntervalExchangeTransformation(('a b c','c b a'),[1,1,1]) sage: t.in_which_interval(0) 'a' sage: t.in_which_interval(0.3) 'a' sage: t.in_which_interval(1) 'b' sage: t.in_which_interval(1.9) 'b' sage: t.in_which_interval(2) 'c' sage: t.in_which_interval(2.1) 'c' sage: t.in_which_interval(3) Traceback (most recent call last): ... ValueError: your value does not lie in [0;l[
.. and for the bottom interval::
sage: t.in_which_interval(0,'bottom') 'c' sage: t.in_which_interval(1.2,'bottom') 'b' sage: t.in_which_interval(2.9,'bottom') 'a'
TESTS::
sage: t.in_which_interval(-2.9,'bottom') Traceback (most recent call last): ... ValueError: your value does not lie in [0;l[ """
r""" The list of singularities of `T` and `T^{-1}`.
OUTPUT:
list -- two lists of positive numbers which corresponds to extremities of subintervals
EXAMPLES::
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1/2,3/2]) sage: t.singularities() [[0, 1/2, 2], [0, 3/2, 2]] """
r""" Returns the list of singularities of T
OUTPUT:
list -- positive reals that corresponds to singularities in the top interval
EXAMPLES::
sage: t = iet.IET(("a b","b a"), [1, sqrt(2)]) sage: t.domain_singularities() [0, 1, sqrt(2) + 1] """
r""" Returns the list of singularities of `T^{-1}`
OUTPUT:
list -- real numbers that are singular for `T^{-1}`
EXAMPLES::
sage: t = iet.IET(("a b","b a"), [1, sqrt(2)]) sage: t.range_singularities() [0, sqrt(2), sqrt(2) + 1] """
r""" Return the image of value by this transformation
EXAMPLES::
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1/2,3/2]) sage: t(0) 3/2 sage: t(1/2) 0 sage: t(1) 1/2 sage: t(3/2) 1
TESTS::
sage: t(-3/2) Traceback (most recent call last): ... ValueError: value must positive and smaller than length """
r""" Performs a Rauzy move.
INPUT:
- ``side`` - 'left' (or 'l' or 0) or 'right' (or 'r' or 1)
- ``iterations`` - integer (default :1) the number of iteration of Rauzy moves to perform
OUTPUT:
iet -- the Rauzy move of self
EXAMPLES::
sage: phi = QQbar((sqrt(5)-1)/2) sage: t1 = iet.IntervalExchangeTransformation(('a b','b a'),[1,phi]) sage: t2 = t1.rauzy_move().normalize(t1.length()) sage: l2 = t2.lengths() sage: l1 = t1.lengths() sage: l2[0] == l1[1] and l2[1] == l1[0] True """
r""" Performs a Rauzy move
INPUT:
- ``side`` - must be 0 or -1 (no verification)
TESTS::
sage: t = iet.IntervalExchangeTransformation(('a b c','c b a'),[1,1,3]) sage: t Interval exchange transformation of [0, 5[ with permutation a b c c b a sage: t1 = t.rauzy_move() #indirect doctest sage: t1 Interval exchange transformation of [0, 4[ with permutation a b c c a b sage: t2 = t1.rauzy_move() #indirect doctest sage: t2 Interval exchange transformation of [0, 3[ with permutation a b c c b a sage: t2.rauzy_move() #indirect doctest Traceback (most recent call last): ... ValueError: top and bottom extrem intervals have equal lengths """
else:
r""" Returns a copy of this interval exchange transformation.
EXAMPLES::
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1]) sage: s = copy(t) sage: s == t True sage: s is t False """
r""" Return a plot of the interval exchange transformation as a function.
INPUT:
- Any option that is accepted by line2d
OUTPUT:
2d plot -- a plot of the iet as a function
EXAMPLES::
sage: t = iet.IntervalExchangeTransformation(('a b c d','d a c b'),[1,1,1,1]) sage: t.plot_function(rgbcolor=(0,1,0)) Graphics object consisting of 4 graphics primitives """
position=(0,0), vertical_alignment='center', horizontal_alignment='left', interval_height=0.1, labels_height=0.05, fontsize=14, labels=True, colors=None): r""" Returns a picture of the interval exchange transformation.
INPUT:
- ``position`` - a 2-uple of the position
- ``horizontal_alignment`` - left (default), center or right
- ``labels`` - boolean (default: True)
- ``fontsize`` - the size of the label
OUTPUT:
2d plot -- a plot of the two intervals (domain and range)
EXAMPLES::
sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,1]) sage: t.plot_two_intervals() Graphics object consisting of 8 graphics primitives """
elif horizontal_alignment == 'center': s = position[0] - total_length / 2 elif horizontal_alignment == 'right': s = position[0] - total_length else: raise ValueError("horizontal_alignement must be left, center or right")
rgbcolor=colors[i]) (s+float(lengths[i])/2, top_height+labels_height), horizontal_alignment='center', rgbcolor=colors[i], fontsize=fontsize)
elif horizontal_alignment == 'center': s = position[0] - total_length / 2 elif horizontal_alignment == 'right': s = position[0] - total_length else: raise ValueError("horizontal_alignement must be left, center or right")
rgbcolor=colors[i]) (s+float(lengths[i])/2, bottom_height-labels_height), horizontal_alignment='center', rgbcolor=colors[i], fontsize=fontsize)
r""" Shows a picture of the interval exchange transformation
EXAMPLES::
sage: phi = QQbar((sqrt(5)-1)/2) sage: t = iet.IntervalExchangeTransformation(('a b','b a'),[1,phi]) sage: t.show() """
#TODO # class LinearInvolution(SageObject): # r"""_ # Linear involutions # """ # pass |