Auxiliary functions
Basic geometric data
These are basic functions which depend on the vertex and facet coordinates.
facets — Method
facets(as::Type{T} = AffineHalfspace, P::Polyhedron)Return the facets of P in the format defined by as.
The allowed values for as are
Halfspace(or its subtypeAffineHalfspace),Hyperplane(or its subtypeAffineHyperplane),Polyhedron,Pair.
Examples
We can retrieve the six facets of the 3-dimensional cube this way:
julia> C = cube(3);
julia> facets(Polyhedron, C)
6-element SubObjectIterator{Polyhedron{QQFieldElem}}:
Polytope in ambient dimension 3
Polytope in ambient dimension 3
Polytope in ambient dimension 3
Polytope in ambient dimension 3
Polytope in ambient dimension 3
Polytope in ambient dimension 3
julia> facets(Halfspace, C)
6-element SubObjectIterator{AffineHalfspace{QQFieldElem}} over the halfspaces of R^3 described by:
-x_1 <= 1
x_1 <= 1
-x_2 <= 1
x_2 <= 1
-x_3 <= 1
x_3 <= 1sourcevertices — Method
vertices([as::Type{T} = PointVector,] P::Polyhedron)Return an iterator over the vertices of P in the format defined by as. The vertices are defined to be the zero-dimensional faces, so if P has lineality, there are no vertices, only minimal faces.
See also minimal_faces and rays.
Optional arguments for as include
PointVector.
Examples
The following code computes the vertices of the Minkowski sum of a triangle and a square:
julia> P = simplex(2) + cube(2);
julia> vertices(PointVector, P)
5-element SubObjectIterator{PointVector{QQFieldElem}}:
[-1, -1]
[2, -1]
[2, 1]
[-1, 2]
[1, 2]
julia> point_matrix(vertices(P))
[-1 -1]
[ 2 -1]
[ 2 1]
[-1 2]
[ 1 2]A half-space (here in $3$-space) has no vertices:
julia> UH = polyhedron([-1 0 0], [0])
Polyhedron in ambient dimension 3
julia> vertices(UH)
0-element SubObjectIterator{PointVector{QQFieldElem}}sourcerays — Method
rays([as::Type{T} = RayVector,] P::Polyhedron)Return a minimal set of generators of the cone of unbounded directions of P (i.e. its rays) in the format defined by as. The rays are defined to be the one-dimensional faces of the recession cone, so if P has lineality, there are no rays.
See also rays_modulo_lineality, recession_cone and vertices.
Optional arguments for as include
RayVector.
Examples
We can verify that the positive orthant of the plane is generated by the two rays in positive unit direction:
julia> PO = convex_hull([0 0], [1 0; 0 1]);
julia> rays(RayVector, PO)
2-element SubObjectIterator{RayVector{QQFieldElem}}:
[1, 0]
[0, 1]
julia> rays(PO)
2-element SubObjectIterator{RayVector{QQFieldElem}}:
[1, 0]
[0, 1]
julia> matrix(QQ, rays(PO))
[1 0]
[0 1]
julia> matrix(ZZ, rays(PO))
[1 0]
[0 1]A half-space has no rays:
julia> UH = polyhedron([-1 0 0], [0])
Polyhedron in ambient dimension 3
julia> rays(UH)
0-element SubObjectIterator{RayVector{QQFieldElem}}sourcerays_modulo_lineality — Method
rays_modulo_lineality(as, P::Polyhedron)Return the rays of the recession cone of P up to lineality as a NamedTuple with two iterators. If P has lineality L, then the iterator rays_modulo_lineality iterates over representatives of the rays of P/L. The iterator lineality_basis gives a basis of the lineality space L.
See also rays and lineality_space.
Examples
julia> P = convex_hull([0 0 1], [0 1 0], [1 0 0])
Polyhedron in ambient dimension 3
julia> rmlP = rays_modulo_lineality(P)
(rays_modulo_lineality = RayVector{QQFieldElem}[[0, 1, 0]], lineality_basis = RayVector{QQFieldElem}[[1, 0, 0]])
julia> rmlP.rays_modulo_lineality
1-element SubObjectIterator{RayVector{QQFieldElem}}:
[0, 1, 0]
julia> rmlP.lineality_basis
1-element SubObjectIterator{RayVector{QQFieldElem}}:
[1, 0, 0]sourceminimal_faces — Method
minimal_faces(as, P::Polyhedron)Return the minimal faces of a polyhedron as a NamedTuple with two iterators. For a polyhedron without lineality, the base_points are the vertices. If P has lineality L, then every minimal face is an affine translation p+L, where p is only unique modulo L. The return type is a dict, the key :base_points gives an iterator over such p, and the key :lineality_basis lets one access a basis for the lineality space L of P.
See also vertices and lineality_space.
Examples
The polyhedron P is just a line through the origin:
julia> P = convex_hull([0 0], nothing, [1 0])
Polyhedron in ambient dimension 2
julia> lineality_dim(P)
1
julia> vertices(P)
0-element SubObjectIterator{PointVector{QQFieldElem}}
julia> minimal_faces(P)
(base_points = PointVector{QQFieldElem}[[0, 0]], lineality_basis = RayVector{QQFieldElem}[[1, 0]])sourceaffine_hull — Method
affine_hull(P::Polytope)Return the (affine) hyperplanes generating the affine hull of P.
Examples
This triangle in $\mathbb{R}^4$ is contained in the plane defined by $P = \{ (x_1, x_2, x_3, x_4) | x_3 = 2 ∧ x_4 = 5 \}$.
julia> t = convex_hull([0 0 2 5; 1 0 2 5; 0 1 2 5]);
julia> affine_hull(t)
2-element SubObjectIterator{AffineHyperplane{QQFieldElem}} over the hyperplanes of R^4 described by:
x_3 = 2
x_4 = 5sourceambient_dim — Method
ambient_dim(P::Polyhedron)Return the ambient dimension of P.
Examples
julia> V = [1 2 3; 1 3 2; 2 1 3; 2 3 1; 3 1 2; 3 2 1];
julia> P = convex_hull(V);
julia> ambient_dim(P)
3sourceis_bounded — Method
is_bounded(P::Polyhedron)Check whether P is bounded.
Examples
julia> P = polyhedron([1 -3; -1 1; -1 0; 0 -1],[1,1,1,1]);
julia> is_bounded(P)
falsesourceis_feasible — Method
is_feasible(P::Polyhedron)Check whether P is feasible, i.e. non-empty.
Examples
julia> P = polyhedron([1 -1; -1 1; -1 0; 0 -1],[-1,-1,1,1]);
julia> is_feasible(P)
falsesourceis_fulldimensional — Method
is_fulldimensional(P::Polyhedron)Check whether P is full-dimensional.
Examples
julia> V = [1 2 3; 1 3 2; 2 1 3; 2 3 1; 3 1 2; 3 2 1];
julia> is_fulldimensional(convex_hull(V))
falsesourceis_lattice_polytope — Method
is_lattice_polytope(P::Polyhedron{QQFieldElem})Check whether P is a lattice polytope, i.e. it is bounded and has integral vertices.
Examples
julia> c = cube(3)
Polytope in ambient dimension 3
julia> is_lattice_polytope(c)
true
julia> c = cube(3, 0, 4//3)
Polytope in ambient dimension 3
julia> is_lattice_polytope(c)
falsesourcelineality_dim — Method
lineality_dim(P::Polyhedron)Return the dimension of the lineality space, i.e. the dimension of the largest affine subspace contained in P.
Examples
Polyhedron with one lineality direction.
julia> C = convex_hull([0 0], [1 0], [1 1])
Polyhedron in ambient dimension 2
julia> lineality_dim(C)
1sourcelineality_space — Method
lineality_space(P::Polyhedron)Return a matrix whose row span is the lineality space of P.
Examples
Despite not being reflected in this construction of the upper half-plane, its lineality in $x$-direction is recognized:
julia> UH = convex_hull([0 0],[0 1; 1 0; -1 0]);
julia> lineality_space(UH)
1-element SubObjectIterator{RayVector{QQFieldElem}}:
[1, 0]sourcerecession_cone — Method
recession_cone(P::Polyhedron)Return the recession cone of P.
Examples
julia> P = polyhedron([1 -2; -1 1; -1 0; 0 -1],[2,1,1,1]);
julia> vertices(P)
3-element SubObjectIterator{PointVector{QQFieldElem}}:
[0, -1]
[-1, 0]
[-1, -1]
julia> recession_cone(P)
Polyhedral cone in ambient dimension 2
julia> rays(recession_cone(P))
2-element SubObjectIterator{RayVector{QQFieldElem}}:
[1, 1//2]
[1, 1]sourcerelative_interior_point — Method
relative_interior_point(P::Polyhedron)Compute a point in the relative interior point of P, i.e. a point in P not contained in any facet.
Examples
The square $[-1,1]^3$ has the origin as a relative interior point.
julia> square = cube(2)
Polytope in ambient dimension 2
julia> relative_interior_point(square)
2-element PointVector{QQFieldElem}:
0
0
julia> vertices(square)
4-element SubObjectIterator{PointVector{QQFieldElem}}:
[-1, -1]
[1, -1]
[-1, 1]
[1, 1]
julia> matrix(QQ, vertices(square))
[-1 -1]
[ 1 -1]
[-1 1]
[ 1 1]sourceCombinatorial data
These are functions which only depend on the combinatorial type, i.e., the isomorphism type of the face poset.
n_vertices — Method
n_vertices(P::Polyhedron)Return the number of vertices of P.
Examples
The 3-cube's number of vertices can be obtained with this input:
julia> C = cube(3);
julia> n_vertices(C)
8sourceis_simplicial — Method
is_simplicial(P::Polyhedron)Check whether P is simplicial, i.e., each proper face is a simplex.
is_neighborly — Method
is_neighborly(P::Polyhedron)Check whether P is neighborly, i.e., if the dimension is $d$, each $\lfloor d/2 \rfloor$-subset of the vertices forms a face. Neighborly polytopes in even dimension are necessarily simplicial.
Examples
A 4-polytope is neighborly if and only if the vertex-edge graph is complete.
julia> is_neighborly(cyclic_polytope(4,8))
truesourceis_cubical — Method
is_cubical(P::Polyhedron)Check whether P is cubical, i.e., each proper face is combinatorially equivalent to a cube.
Examples
For details concerning the following construction see [JZ00].
julia> Q = cube(2,-1,1); Q2 = cube(2,-2,2); P = convex_hull(product(Q,Q2), product(Q2,Q))
Polyhedron in ambient dimension 4
julia> is_cubical(P)
truesourceg_vector — Method
g_vector(P::Polyhedron)Return the (toric) $g$-vector of a polytope. Defined by $g_0 = 1$ and $g_k = h_k - h_{k-1}$, for $1 \leq k \leq \lceil (d+1)/2\rceil$ where $h$ is the $h$-vector and $d=\dim(P)$. Undefined for unbounded polyhedra.
Examples
julia> g_vector(cross_polytope(3))
2-element Vector{ZZRingElem}:
1
2sourcefacet_sizes — Method
facet_sizes(P::Polyhedron{T})Number of vertices in each facet.
Examples
julia> p = johnson_solid(4)
Polytope in ambient dimension 3 with EmbeddedAbsSimpleNumFieldElem type coefficients
julia> facet_sizes(p)
10-element Vector{Int64}:
8
4
3
4
4
3
4
3
3
4sourcevertex_sizes — Method
vertex_sizes(P::Polyhedron{T})Number of incident facets for each vertex.
Examples
julia> vertex_sizes(bipyramid(simplex(2)))
5-element Vector{Int64}:
4
4
4
3
3sourceVolume and triangulation related functions
While these functions are geometric, too, they play a special role. In particular, they can be costly.
normalized_volume — Method
normalized_volume(P::Polyhedron)Return the (normalized) volume of P.
Examples
julia> C = cube(2);
julia> normalized_volume(C)
8sourceregular_triangulation — Function
regular_triangulation(pts::AbstractCollection[PointVector]; full=false)Compute ONE regular triangulation on the points given as the rows of pts.
A triangulation is regular if it can be induced by weights, i.e. attach a weight to every point, take the convex hull of these new vectors and then take the subdivision corresponding to the facets visible from below (lower envelope). Optionally specify full, i.e. that every triangulation must use all points.
As for regular_triangulation(pts::AnyVecOrMat; full=false) the return type is Vector{Vector{Vector{Int}}}. Here, only one triangulation is computed, so the outer vector is of length one. Its entry of type Vector{Vector{Int}} encodes the triangulation in question. Recall that a Vector{Int} encodes a simplex as the set of indices of the vertices of the simplex. I.e. the Vector{Int} [1,2,4] corresponds to the simplex that is the convex hull of the first, second, and fourth input point.
Examples
julia> c = cube(2,0,1)
Polytope in ambient dimension 2
julia> V = vertices(c)
4-element SubObjectIterator{PointVector{QQFieldElem}}:
[0, 0]
[1, 0]
[0, 1]
[1, 1]
julia> regular_triangulation(V)
1-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]sourceregular_triangulation(P::Polyhedron)Compute ONE regular triangulation that can be formed using the vertices of the given bounded and full-dimensional polytope P.
A triangulation is regular if it can be induced by weights, i.e. attach a weight to every point, take the convex hull of these new vectors and then take the subdivision corresponding to the facets visible from below (lower envelope).
As for regular_triangulations(P::Polyhedron) the return type is Vector{Vector{Vector{Int}}}. Here, only one triangulation is computed, so the outer vector is of length one. Its entry of type Vector{Vector{Int}} encodes the triangulation in question. Recall that a Vector{Int} encodes a simplex as the set of indices of the vertices of the simplex. I.e. the Vector{Int} [1,2,4] corresponds to the simplex that is the convex hull of the first, second, and fourth input point.
Examples
julia> c = cube(2,0,1)
Polytope in ambient dimension 2
julia> regular_triangulation(c)
1-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]sourceregular_triangulations — Function
regular_triangulations(pts::AbstractCollection[PointVector]; full=false)Compute all regular triangulations on the points given as the rows of pts.
A triangulation is regular if it can be induced by weights, i.e. attach a weight to every point, take the convex hull of these new vectors and then take the subdivision corresponding to the facets visible from below (lower envelope). Optionally specify full, i.e. that every triangulation must use all points.
The return type is a Vector{Vector{Vector{Int}}} where each Vector{Vector{Int}} encodes a triangulation, in which a Vector{Int} encodes a simplex as the set of indices of the vertices of the simplex. I.e. the Vector{Int} [1,2,4] corresponds to the simplex that is the convex hull of the first, second, and fourth input point.
Examples
julia> c = cube(2,0,1)
Polytope in ambient dimension 2
julia> V = vertices(c)
4-element SubObjectIterator{PointVector{QQFieldElem}}:
[0, 0]
[1, 0]
[0, 1]
[1, 1]
julia> regular_triangulations(V)
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 2, 4], [1, 3, 4]]sourceregular_triangulations(P::Polyhedron)Compute all regular triangulations that can be formed using the vertices of the given bounded and full-dimensional polytope P.
A triangulation is regular if it can be induced by weights, i.e. attach a weight to every point, take the convex hull of these new vectors and then take the subdivision corresponding to the facets visible from below (lower envelope).
The return type is a Vector{Vector{Vector{Int}}} where each Vector{Vector{Int}} encodes a triangulation, in which a Vector{Int} encodes a simplex as the set of indices of the vertices of the simplex. I.e. the Vector{Int} [1,2,4] corresponds to the simplex that is the convex hull of the first, second, and fourth input point.
Examples
julia> c = cube(2,0,1)
Polytope in ambient dimension 2
julia> regular_triangulations(c)
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 2, 4], [1, 3, 4]]sourcesecondary_polytope — Function
secondary_polytope(P::Polyhedron)Compute the secondary polytope of a polyhedron, i.e. the convex hull of all the gkz vectors of all its (regular) triangulations. A triangulation here means only using the vertices of P.
Examples
Compute the secondary polytope of the cube.
julia> c = cube(3)
Polytope in ambient dimension 3
julia> sc = secondary_polytope(c)
Polytope in ambient dimension 8sourceall_triangulations — Function
all_triangulations(pts::AbstractCollection[PointVector]; full=false)Compute all triangulations on the points given as the rows of pts. Optionally select full=true to output full triangulations only, i.e. those that use all given points.
The return type is a Vector{Vector{Vector{Int}}} where each Vector{Vector{Int}} encodes a triangulation, in which a Vector{Int} encodes a simplex as the set of indices of the vertices of the simplex. I.e. the Vector{Int} [1,2,4] corresponds to the simplex that is the convex hull of the first, second, and fourth input point.
Examples
julia> c = cube(2,0,1)
Polytope in ambient dimension 2
julia> V = vertices(c)
4-element SubObjectIterator{PointVector{QQFieldElem}}:
[0, 0]
[1, 0]
[0, 1]
[1, 1]
julia> all_triangulations(V)
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 2, 4], [1, 3, 4]]sourceall_triangulations(P::Polyhedron)Compute all triangulations that can be formed using the vertices of the given bounded and full-dimensional polytope P.
The return type is a Vector{Vector{Vector{Int}}} where each Vector{Vector{Int}} encodes a triangulation, in which a Vector{Int} encodes a simplex as the set of indices of the vertices of the simplex. I.e. the Vector{Int} [1,2,4] corresponds to the simplex that is the convex hull of the first, second, and fourth input point.
Examples
julia> c = cube(2,0,1)
Polytope in ambient dimension 2
julia> all_triangulations(c)
2-element Vector{Vector{Vector{Int64}}}:
[[1, 2, 3], [2, 3, 4]]
[[1, 2, 4], [1, 3, 4]]sourceGroups
There are several groups naturally associated to a polytope or polyhedron.
combinatorial_symmetries — Method
combinatorial_symmetries(P::Polyhedron)Compute the combinatorial symmetries (i.e., automorphisms of the face lattice) of a given polytope $P$. The result is given as permutations of the vertices (or rather vertex indices) of $P$. This group contains the linear_symmetries as a subgroup.
Examples
The quadrangle one obtains from moving one vertex of the square out along the diagonal has eight combinatorial symmetries, but only two linear symmetries.
julia> quad = convex_hull([0 0; 1 0; 2 2; 0 1])
Polyhedron in ambient dimension 2
julia> G = combinatorial_symmetries(quad)
Permutation group of degree 4
julia> order(G)
8
julia> G = linear_symmetries(quad)
Permutation group of degree 4
julia> order(G)
2sourcelinear_symmetries — Method
linear_symmetries(P::Polyhedron)Get the group of linear symmetries on the vertices of a polyhedron. These are morphisms of the form $x\mapsto Ax+b$,with $A$ a matrix and $b$ a vector, that preserve the polyhedron $P$. The result is given as permutations of the vertices (or rather vertex indices) of $P$.
Examples
The 3-dimensional cube has 48 linear symmetries.
julia> c = cube(3)
Polytope in ambient dimension 3
julia> G = linear_symmetries(c)
Permutation group of degree 8
julia> order(G)
48The quadrangle one obtains from moving one vertex of the square out along the diagonal has two linear symmetries.
julia> quad = convex_hull([0 0; 1 0; 2 2; 0 1])
Polyhedron in ambient dimension 2
julia> G = linear_symmetries(quad)
Permutation group of degree 4
julia> order(G)
2sourceautomorphism_group — Method
automorphism_group(P::Polyhedron; type = :combinatorial, action = :all)Compute the group of automorphisms of a polyhedron. The parameters and return values are the same as for automorphism_group_generators(P::Polyhedron; type = :combinatorial, action = :all) except that groups are returned instead of generators of groups.
automorphism_group_generators — Method
automorphism_group_generators(P::Polyhedron; type = :combinatorial, action = :all)Compute generators of the group of automorphisms of a polyhedron.
The optional parameter type takes two values:
:combinatorial(default) – Return the combinatorial symmetries, the automorphisms of the face lattice.:linear– Return the linear automorphisms.
The optional parameter action takes three values:
:all(default) – Return the generators of the permutation action on both vertices and facets as a Dict{Symbol, Vector{PermGroupElem}}.:on_vertices– Only return generators of the permutation action on the vertices.:on_facets– Only return generators of the permutation action on the facets.
The return value is a Dict{Symbol, Vector{PermGroupElem}} with two entries, one for the key :on_vertices containing the generators for the action permuting the vertices, and :on_facets for the facets.
Examples
Compute the automorphisms of the 3dim cube:
julia> c = cube(3)
Polytope in ambient dimension 3
julia> automorphism_group_generators(c)
Dict{Symbol, Vector{PermGroupElem}} with 2 entries:
:on_vertices => [(3,5)(4,6), (2,3)(6,7), (1,2)(3,4)(5,6)(7,8)]
:on_facets => [(3,5)(4,6), (1,3)(2,4), (1,2)]
julia> automorphism_group_generators(c; action = :on_vertices)
3-element Vector{PermGroupElem}:
(3,5)(4,6)
(2,3)(6,7)
(1,2)(3,4)(5,6)(7,8)
julia> automorphism_group_generators(c; action = :on_facets)
3-element Vector{PermGroupElem}:
(3,5)(4,6)
(1,3)(2,4)
(1,2)Compute the automorphisms of a non-quadratic quadrangle. Since it has less symmetry than the square, it has less linear symmetries.
julia> quad = convex_hull([0 0; 1 0; 2 2; 0 1])
Polyhedron in ambient dimension 2
julia> automorphism_group_generators(quad)
Dict{Symbol, Vector{PermGroupElem}} with 2 entries:
:on_vertices => [(2,4), (1,2)(3,4)]
:on_facets => [(1,2)(3,4), (1,3)]
julia> automorphism_group_generators(quad; type = :combinatorial)
Dict{Symbol, Vector{PermGroupElem}} with 2 entries:
:on_vertices => [(2,4), (1,2)(3,4)]
:on_facets => [(1,2)(3,4), (1,3)]
julia> automorphism_group_generators(quad; type = :linear)
Dict{Symbol, Vector{PermGroupElem}} with 2 entries:
:on_vertices => [(2,4)]
:on_facets => [(1,2)(3,4)]sourceautomorphism_group — Method
automorphism_group(IM::IncidenceMatrix; action = :all)Compute the group of automorphisms of an IncidenceMatrix. The parameters and return values are the same as for automorphism_group_generators(IM::IncidenceMatrix; action = :all) except that groups are returned instead of generators of groups.
automorphism_group_generators — Method
automorphism_group_generators(IM::IncidenceMatrix; action = :all)Compute the generators of the group of automorphisms of an IncidenceMatrix.
The optional parameter action takes three values:
:all(default) – Return the generators of the permutation action on both columns and rows as a Dict{Symbol, Vector{PermGroupElem}}.:on_cols– Only return generators of the permutation action on the columns.:on_rows– Only return generators of the permutation action on the rows.
Examples
Compute the automorphisms of the incidence matrix of the 3dim cube:
julia> c = cube(3)
Polytope in ambient dimension 3
julia> IM = vertex_indices(facets(c))
6×8 IncidenceMatrix
[1, 3, 5, 7]
[2, 4, 6, 8]
[1, 2, 5, 6]
[3, 4, 7, 8]
[1, 2, 3, 4]
[5, 6, 7, 8]
julia> automorphism_group_generators(IM)
Dict{Symbol, Vector{PermGroupElem}} with 2 entries:
:on_cols => [(3,5)(4,6), (2,3)(6,7), (1,2)(3,4)(5,6)(7,8)]
:on_rows => [(3,5)(4,6), (1,3)(2,4), (1,2)]
julia> automorphism_group_generators(IM; action = :on_rows)
3-element Vector{PermGroupElem}:
(3,5)(4,6)
(1,3)(2,4)
(1,2)
julia> automorphism_group_generators(IM; action = :on_cols)
3-element Vector{PermGroupElem}:
(3,5)(4,6)
(2,3)(6,7)
(1,2)(3,4)(5,6)(7,8)sourceLattice polytopes
Here a polytope is lattice if each vertex has integral coordinates.
boundary_lattice_points — Method
boundary_lattice_points(P::Polyhedron)Return the integer points contained in the boundary of the bounded polyhedron P.
Examples
julia> c = polarize(cube(3))
Polytope in ambient dimension 3
julia> boundary_lattice_points(c)
6-element SubObjectIterator{PointVector{ZZRingElem}}:
[-1, 0, 0]
[0, -1, 0]
[0, 0, -1]
[0, 0, 1]
[0, 1, 0]
[1, 0, 0]
julia> matrix(ZZ, boundary_lattice_points(c))
[-1 0 0]
[ 0 -1 0]
[ 0 0 -1]
[ 0 0 1]
[ 0 1 0]
[ 1 0 0]sourcecastelnuovo_excess — Method
ehrhart_polynomial — Method
ehrhart_polynomial(P::Polyhedron{QQFieldElem})Compute the Ehrhart polynomial of P.
Examples
julia> c = cube(3)
Polytope in ambient dimension 3
julia> ehrhart_polynomial(c)
8*x^3 + 12*x^2 + 6*x + 1sourceehrhart_polynomial — Method
ehrhart_polynomial(R::QQMPolyRing, P::Polyhedron{QQFieldElem})Compute the Ehrhart polynomial of P and return it as a polynomial in R.
Examples
julia> R, x = polynomial_ring(QQ, :x)
(Univariate polynomial ring in x over QQ, x)
julia> c = cube(3)
Polytope in ambient dimension 3
julia> ehrhart_polynomial(R, c)
8*x^3 + 12*x^2 + 6*x + 1sourceh_star_polynomial — Method
h_star_polynomial(P::Polyhedron)Compute the $h^*$ polynomial of P.
Examples
julia> c = cube(3)
Polytope in ambient dimension 3
julia> h_star_polynomial(c)
x^3 + 23*x^2 + 23*x + 1sourceh_star_polynomial — Method
h_star_polynomial(R::QQMPolyRing, P::Polyhedron)Compute the $h^*$ polynomial of P and return it as a polynomial in R.
Examples
julia> R, x = polynomial_ring(QQ, :x)
(Univariate polynomial ring in x over QQ, x)
julia> c = cube(3)
Polytope in ambient dimension 3
julia> h_star_polynomial(R, c)
x^3 + 23*x^2 + 23*x + 1sourceinterior_lattice_points — Method
interior_lattice_points(P::Polyhedron)Return the integer points contained in the interior of the bounded polyhedron P.
Examples
julia> c = cube(3)
Polytope in ambient dimension 3
julia> interior_lattice_points(c)
1-element SubObjectIterator{PointVector{ZZRingElem}}:
[0, 0, 0]
julia> matrix(ZZ, interior_lattice_points(c))
[0 0 0]sourceis_castelnuovo — Method
is_castelnuovo(P::Polyhedron)For an arbitrary lattice polytope, Hibi [Hib94] proved that the normalized volume is always at least as large as a certain lattice point count. This function returns true if both numbers agree.
Examples
julia> is_castelnuovo(cube(2))
true
julia> is_castelnuovo(cube(4))
falsesourceis_very_ample — Method
is_very_ample(P::Polyhedron{QQFieldElem})Check whether P is very ample.
Examples
julia> c = cube(3)
Polytope in ambient dimension 3
julia> is_very_ample(c)
true
julia> P = convex_hull([0 0 0; 1 1 0; 1 0 1; 0 1 1])
Polyhedron in ambient dimension 3
julia> is_very_ample(P)
falsesourcelattice_points — Method
lattice_points(P::Polyhedron)Return the integer points contained in the bounded polyhedron P.
Examples
julia> S = 2 * simplex(2);
julia> lattice_points(S)
6-element SubObjectIterator{PointVector{ZZRingElem}}:
[0, 0]
[0, 1]
[0, 2]
[1, 0]
[1, 1]
[2, 0]
julia> matrix(ZZ, lattice_points(S))
[0 0]
[0 1]
[0 2]
[1 0]
[1 1]
[2 0]sourcelattice_volume — Method
lattice_volume(P::Polyhedron{QQFieldElem})Return the lattice volume of P.
Examples
julia> C = cube(2);
julia> lattice_volume(C)
8sourceOther
demazure_character — Method
demazure_character(lambda::AbstractVector, sigma::PermGroupElem)Construct the Demazure character indexed by a weakly decreasing vector lambda and a permutation sigma.
- [PS09]
For Demazure characters as in [Dem74], i.e. the weights with multiplicities occurring in a Demazure module of a semisimple Lie algebra, see demazure_character(::LieAlgebra, ::WeightLatticeElem, ::WeylGroupElem).
Examples
julia> lambda = partition([3,1,1])
[3, 1, 1]
julia> w0 = @perm (1,3,2)
(1,3,2)
julia> dc = demazure_character(lambda, w0)
x1^3*x2*x3 + x1^2*x2^2*x3 + x1*x2^3*x3sourceis_archimedean_solid — Method
is_archimedean_solid(P::Polyhedron)Check whether P is an Archimedean solid, i.e., a $3$-dimensional vertex transitive polytope with regular facets, but not a prism or antiprism.
See also archimedean_solid.
This will only recognize algebraically precise solids, i.e. no solids with approximate coordinates.
Examples
julia> TO = archimedean_solid("truncated_octahedron")
Polytope in ambient dimension 3
julia> is_archimedean_solid(TO)
true
julia> T = tetrahedron()
Polytope in ambient dimension 3
julia> is_archimedean_solid(T)
falsesourceis_johnson_solid — Method
is_johnson_solid(P::Polyhedron)Check whether P is a Johnson solid, i.e., a $3$-dimensional polytope with regular faces that is not vertex transitive.
See also johnson_solid.
This will only recognize algebraically precise solids, i.e. no solids with approximate coordinates.
Examples
julia> J = johnson_solid(37)
Polytope in ambient dimension 3 with EmbeddedAbsSimpleNumFieldElem type coefficients
julia> is_johnson_solid(J)
truesourceis_platonic_solid — Method
is_platonic_solid(P::Polyhedron)Check whether P is a Platonic solid.
See also platonic_solid.
This will only recognize algebraically precise solids, i.e. no solids with approximate coordinates.
Examples
julia> is_platonic_solid(cube(3))
truesourcepolarize — Method
polarize(P::Polyhedron)Return the polar dual of the polyhedron P, consisting of all linear functions whose evaluation on P does not exceed 1.
Examples
julia> square = cube(2)
Polytope in ambient dimension 2
julia> P = polarize(square)
Polytope in ambient dimension 2
julia> vertices(P)
4-element SubObjectIterator{PointVector{QQFieldElem}}:
[1, 0]
[-1, 0]
[0, 1]
[0, -1]sourceproject_full — Method
project_full(P::Polyhedron)Project the polyhedron down such that it becomes full dimensional in the new ambient space.
Examples
julia> P = convex_hull([1 0 0; 0 0 0])
Polyhedron in ambient dimension 3
julia> is_fulldimensional(P)
false
julia> p = project_full(P)
Polyhedron in ambient dimension 1
julia> is_fulldimensional(p)
truesourceprint_constraints — Method
print_constraints([io = stdout,] A::AnyVecOrMat, b::AbstractVector; trivial = false, numbered = false, cmp = :lte)Pretty print the constraints given by $P(A,b) = \{ x | Ax ≤ b \}$.
Optional & Keyword Arguments
io::IO: TargetIOwhere the constraints are printed to.trivial::Bool: Iftrue, include trivial inequalities.numbered::Bool: Iftrue, the each constraint is printed with the index corresponding to the inputAnyVecOrMat.cmp::Symbol: Defines the string used for the comparison sign; supports:lte(less than or equal) and:eq(equal).
Trivial inequalities are always counted for numbering, even when omitted.
Examples
julia> print_constraints([-1 0 4 5; 4 4 4 3; 1 0 0 0; 0 0 0 0; 0 0 0 0; 9 9 9 9], [0, 1, 2, 3, -4, 5]; numbered = true)
1: -x_1 + 4*x_3 + 5*x_4 <= 0
2: 4*x_1 + 4*x_2 + 4*x_3 + 3*x_4 <= 1
3: x_1 <= 2
5: 0 <= -4
6: 9*x_1 + 9*x_2 + 9*x_3 + 9*x_4 <= 5
julia> print_constraints([-1 0 4 5; 4 4 4 3; 1 0 0 0; 0 0 0 0; 0 0 0 0; 9 9 9 9], [0, 1, 2, 3, -4, 5]; trivial = true)
-x_1 + 4*x_3 + 5*x_4 <= 0
4*x_1 + 4*x_2 + 4*x_3 + 3*x_4 <= 1
x_1 <= 2
0 <= 3
0 <= -4
9*x_1 + 9*x_2 + 9*x_3 + 9*x_4 <= 5sourceprint_constraints — Method
print_constraints([io = stdout,] P::Polyhedron; trivial = false, numbered = false)Pretty print the constraints given by $P(A,b) = \{ x | Ax ≤ b \}$.
Optional & Keyword Arguments
io::IO: TargetIOwhere the constraints are printed to.trivial::Bool: Iftrue, include trivial inequalities.numbered::Bool: Iftrue, the each constraint is printed with the index corresponding to the inputAnyVecOrMat.
Trivial inequalities are always counted for numbering, even when omitted.
Examples
The 3-cube is given by $-1 ≦ x_i ≦ 1 ∀ i ∈ \{1, 2, 3\}$.
julia> print_constraints(cube(3))
-x_1 <= 1
x_1 <= 1
-x_2 <= 1
x_2 <= 1
-x_3 <= 1
x_3 <= 1sourcesolve_ineq — Method
solve_ineq(as::Type{T}, A::ZZMatrix, b::ZZMatrix) where {T}Solve $Ax<=b$, assumes finite set of solutions.
The output type may be specified in the variable as:
ZZMatrix(default) a matrix with integers is returned.SubObjectIterator{PointVector{ZZRingElem}}an iterator over integer points is returned.
Examples
The following gives the vertices of the square. The solutions are the rows of the output. Note that the output can be permuted, hence we sort it.
julia> A = ZZMatrix([1 0; 0 1; -1 0; 0 -1]);
julia> b = zero_matrix(ZZ, 4,1); b[1,1]=1; b[2,1]=1; b[3,1]=0; b[4,1]=0;
julia> sortslices(Matrix{BigInt}(solve_ineq(A, b)), dims=1)
4×2 Matrix{BigInt}:
0 0
0 1
1 0
1 1
julia> typeof(solve_ineq(A,b))
ZZMatrix
julia> typeof(solve_ineq(ZZMatrix, A,b))
ZZMatrix
julia> typeof(solve_ineq(SubObjectIterator{PointVector{ZZRingElem}}, A,b))
SubObjectIterator{PointVector{ZZRingElem}}sourcesolve_mixed — Method
solve_mixed(as::Type{T}, A::ZZMatrix, b::ZZMatrix, C::ZZMatrix, d::ZZMatrix) where {T}Solve $Ax = b$ under $Cx >= d$, assumes a finite solution set.
The output type may be specified in the variable as:
ZZMatrix(default) a matrix with integers is returned. The solutions are the (transposed) rows of the output.SubObjectIterator{PointVector{ZZRingElem}}an iterator over integer points is returned.
Examples
Find all $(x_1, x_2)\in\mathbb{Z}^2$ such that $x_1+x_2=7$, $x_1\ge 2$, and $x_2\ge 3$. Note that the output can be permuted, hence we sort it.
julia> A = ZZMatrix([1 1]);
julia> b = zero_matrix(ZZ, 1,1); b[1,1]=7;
julia> C = ZZMatrix([1 0; 0 1]);
julia> d = zero_matrix(ZZ,2,1); d[1,1]=2; d[2,1]=3;
julia> sortslices(Matrix{BigInt}(solve_mixed(A, b, C, d)), dims=1)
3×2 Matrix{BigInt}:
2 5
3 4
4 3
julia> typeof(solve_mixed(A, b, C, d))
ZZMatrix
julia> typeof(solve_mixed(ZZMatrix, A, b, C, d))
ZZMatrix
julia> it = solve_mixed(SubObjectIterator{PointVector{ZZRingElem}}, A, b, C);
julia> typeof(it)
SubObjectIterator{PointVector{ZZRingElem}}
julia> for x in it
print(A*x," ")
end
[7] [7] [7] [7] [7] [7] [7] [7] sourcesolve_mixed — Method
solve_mixed(as::Type{T}, A::ZZMatrix, b::ZZMatrix, C::ZZMatrix) where {T}Solve $Ax = b$ under $Cx >= 0$, assumes a finite solution set.
The output type may be specified in the variable as:
ZZMatrix(default) a matrix with integers is returned. The solutions are the (transposed) rows of the output.SubObjectIterator{PointVector{ZZRingElem}}an iterator over integer points is returned.
Examples
Find all $(x_1, x_2)\in\mathbb{Z}^2_{\ge 0}$ such that $x_1+x_2=3$. Note that the output can be permuted, hence we sort it.
julia> A = ZZMatrix([1 1]);
julia> b = zero_matrix(ZZ, 1,1); b[1,1]=3;
julia> C = ZZMatrix([1 0; 0 1]);
julia> sortslices(Matrix{BigInt}(solve_mixed(A, b, C)), dims=1)
4×2 Matrix{BigInt}:
0 3
1 2
2 1
3 0
julia> typeof(solve_mixed(A, b, C))
ZZMatrix
julia> typeof(solve_mixed(ZZMatrix, A, b, C))
ZZMatrix
julia> it = solve_mixed(SubObjectIterator{PointVector{ZZRingElem}}, A, b, C);
julia> typeof(it)
SubObjectIterator{PointVector{ZZRingElem}}
julia> for x in it
print(A*x," ")
end
[3] [3] [3] [3] sourcesolve_non_negative — Method
solve_non_negative(as::Type{T}, A::ZZMatrix, b::ZZMatrix) where {T}Find all solutions to $Ax = b$, $x>=0$. Assumes a finite set of solutions.
The output type may be specified in the variable as:
ZZMatrix(default) a matrix with integers is returned.SubObjectIterator{PointVector{ZZRingElem}}an iterator over integer points is returned.
Examples
Find all $(x_1, x_2)\in\mathbb{Z}^2_{\ge 0}$ such that $x_1+x_2=3$. The solutions are the rows of the output. Note that the output can be permuted, hence we sort it.
julia> A = ZZMatrix([1 1]);
julia> b = zero_matrix(ZZ, 1,1); b[1,1]=3;
julia> sortslices(Matrix{BigInt}(solve_non_negative(A, b)), dims=1)
4×2 Matrix{BigInt}:
0 3
1 2
2 1
3 0
julia> typeof(solve_non_negative(A,b))
ZZMatrix
julia> typeof(solve_non_negative(ZZMatrix, A,b))
ZZMatrix
julia> typeof(solve_non_negative(SubObjectIterator{PointVector{ZZRingElem}}, A,b))
SubObjectIterator{PointVector{ZZRingElem}}sourcesupport_function — Method
support_function(P::Polyhedron; convention::Symbol = :max)Produce a function $h(ω) = max\{dot(x,ω)\ |\ x \in P\}$. $max$ may be changed to $min$ by setting convention = :min.
Examples
julia> P = cube(3) + simplex(3);
julia> φ = support_function(P);
julia> φ([1,2,3])
9
julia> ψ = support_function(P, convention = :min);
julia> ψ([1,2,3])
-6source