linalg#

Some linear algebra routines

surface_dynamics.misc.linalg.cone_triangulate(C, hyperplane=None)#

Triangulation of rational cone contained in the positive quadrant.

EXAMPLES:

sage: from surface_dynamics.misc.linalg import cone_triangulate
sage: P = Polyhedron(rays=[(1,0,0),(0,1,0),(1,0,1),(0,1,1)])
sage: list(cone_triangulate(P)) # random
[[(0, 1, 1), (0, 1, 0), (1, 0, 0)], [(0, 1, 1), (1, 0, 1), (1, 0, 0)]]
sage: len(_)
2

sage: rays = [(0, 1, 0, -1, 0, 0),
....: (1, 0, -1, 0, 0, -1),
....: (0, 1, -1, 0, 0, -1),
....: (0, 0, 1, 0, 0, 0),
....: (0, 0, 0, 1, 0, -1),
....: (1, -1, 0, 0, 1, -1),
....: (0, 0, 0, 0, 1, -1),
....: (0, 0, 1, -1, 1, 0),
....: (0, 0, 1, -1, 0, 0),
....: (0, 0, 1, 0, -1, 0),
....: (0, 0, 0, 1, -1, -1),
....: (1, -1, 0, 0, 0, -1),
....: (0, 0, 0, 0, 0, -1)]
sage: P = Polyhedron(rays=rays)
sage: list(cone_triangulate(P, hyperplane=(1, 2, 3, -1, 0, -5))) # random
[[(0, 0, 0, 0, 0, -1),
  (0, 0, 0, 0, 1, -1),
  (0, 0, 0, 1, -1, -1),
  (0, 0, 1, 0, 0, 0),
  (0, 1, -1, 0, 0, -1),
  (1, -1, 0, 0, 1, -1)],
  ...
  (0, 0, 1, 0, 0, 0),
  (0, 1, -1, 0, 0, -1),
  (0, 1, 0, -1, 0, 0),
  (1, -1, 0, 0, 1, -1),
  (1, 0, -1, 0, 0, -1)]]
sage: len(_)
16
surface_dynamics.misc.linalg.deformation_cone(v)#

Return the deformation cone of the given vector v

EXAMPLES:

sage: from surface_dynamics.misc.linalg import deformation_cone
sage: K.<sqrt2> = QuadraticField(2)
sage: v3 = vector([sqrt2, 1, 1+sqrt2])
sage: P = deformation_cone(v3)
sage: P
A 2-dimensional polyhedron in QQ^3 defined as the convex hull of 1 vertex and 2 rays
sage: P.rays_list()
[[1, 0, 1], [0, 1, 1]]
surface_dynamics.misc.linalg.deformation_space(lengths)#

Deformation space of the given lengths

This is the smallest vector space defined over QQ that contains the vector lengths. Its dimension is rank.

EXAMPLES:

sage: from surface_dynamics.misc.linalg import deformation_space
sage: K.<sqrt2> = QuadraticField(2)
sage: v3 = vector([sqrt2, 1, 1+sqrt2])
sage: deformation_space(v3)
Vector space of degree 3 and dimension 2 over Rational Field
Basis matrix:
[1 0 1]
[0 1 1]
sage: v4 = vector([sqrt2, 1, 1+sqrt2, 1-sqrt2])
sage: deformation_space(v4)
Vector space of degree 4 and dimension 2 over Rational Field
Basis matrix:
[ 1  0  1 -1]
[ 0  1  1  1]

sage: v = vector([1, 5, 2, 9])
sage: deformation_space(v)
Vector space of degree 4 and dimension 1 over Rational Field
Basis matrix:
[1 5 2 9]

The deformation space has some covariance relation with respect to matrix actions:

sage: m3 = matrix(3, [1,-1,0,2,-3,4,5,-2,2])
sage: deformation_space(v3 * m3) == deformation_space(v3) * m3
True
sage: deformation_space(m3 * v3) == deformation_space(v3) * m3.transpose()
True

sage: m4 = matrix(4, [1,-1,0,1,2,-3,0,4,5,3,-2,2,1,1,1,1])
sage: deformation_space(v4 * m4) == deformation_space(v4) * m4
True
sage: deformation_space(m4 * v4) == deformation_space(v4) * m4.transpose()
True
surface_dynamics.misc.linalg.relation_space(v)#

Relation space of the given vector v

This is the sub vector space of QQ^d given as the kernel of the map n mapsto n cdot lambda. The dimension is d - rank.

EXAMPLES:

sage: from surface_dynamics.misc.linalg import relation_space
sage: K.<sqrt2> = QuadraticField(2)
sage: v3 = vector([sqrt2, 1, 1+sqrt2])
sage: relation_space(v3)
Vector space of degree 3 and dimension 1 over Rational Field
Basis matrix:
[ 1  1 -1]
sage: v4 = vector([sqrt2, 1, 1+sqrt2, 1-sqrt2])
sage: relation_space(v4)
Vector space of degree 4 and dimension 2 over Rational Field
Basis matrix:
[   1    0 -1/2  1/2]
[   0    1 -1/2 -1/2]

sage: v = vector([1,2,5,3])
sage: relation_space(v)
Vector space of degree 4 and dimension 3 over Rational Field
Basis matrix:
[   1    0    0 -1/3]
[   0    1    0 -2/3]
[   0    0    1 -5/3]

The relation space has some covariance relation with respect to matrix actions:

sage: m3 = matrix(3, [1,-1,0,2,-3,4,5,-2,2])
sage: relation_space(v3 * m3) == relation_space(v3) * ~m3.transpose()
True
sage: relation_space(m3 * v3) == relation_space(v3) * ~m3
True

sage: m4 = matrix(4, [1,-1,0,1,2,-3,0,4,5,3,-2,2,1,1,1,1])
sage: relation_space(v4 * m4) == relation_space(v4) * ~m4.transpose()
True
sage: relation_space(m4 * v4) == relation_space(v4) * ~m4
True
surface_dynamics.misc.linalg.symbolic_matrix_power(M, n)#

Return the symbolic power M^n of the unipotent matrix M.

EXAMPLES:

sage: from surface_dynamics.misc.linalg import symbolic_matrix_power
sage: m = matrix(3, [1,1,1,0,1,1,0,0,1])
sage: n = polygen(QQ, 'n')
sage: symbolic_matrix_power(m, n)
[              1               n 1/2*n^2 + 1/2*n]
[              0               1               n]
[              0               0               1]

sage: m = matrix(2, [2,1,1,1])
sage: symbolic_matrix_power(m, n)
Traceback (most recent call last):
...
NotImplementedError: power only implemented for unipotent matrices