Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
add wedge method in Polyhedron class in base.py
Browse files Browse the repository at this point in the history
  • Loading branch information
LaisRast committed Jul 23, 2019
1 parent a1e1a8f commit d0be5c6
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/doc/en/reference/references/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,10 @@ REFERENCES:
and Genocchi numbers <https://www.lri.fr/~hivert/PAPER/kshapes.pdf>`_,
in FPSAC 2011, Reykjav´k, Iceland DMTCS proc. AO, 2011, 493-504.
.. [HoDaCG17] Toth, Csaba D., Joseph O'Rourke, and Jacob E. Goodman.
Handbook of Discrete and Computational Geometry (3rd Edition).
Chapman and Hall/CRC, 2017.
.. [Hoc] Winfried Hochstaettler, "About the Tic-Tac-Toe Matroid",
preprint.
Expand Down Expand Up @@ -2555,7 +2559,7 @@ REFERENCES:
Compositio Mathematica, **149** (2013), no. 10.
:arxiv:`1111.3660`.
.. [Kly1990] Klyachko, Aleksandr Anatolevich.
.. [Kly1990] Klyachko, Aleksandr Anatolevich.
Equivariant Bundles on Toral Varieties,
Math USSR Izv. 35 (1990), 337-375.
http://iopscience.iop.org/0025-5726/35/2/A04/pdf/0025-5726_35_2_A04.pdf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ List of Polyhedron methods
:meth:`~sage.geometry.polyhedron.base.Polyhedron_base.truncation` | truncates all vertices simultaneously
:meth:`~sage.geometry.polyhedron.base.Polyhedron_base.lawrence_extension` | returns the Lawrence extension of self on a given point
:meth:`~sage.geometry.polyhedron.base.Polyhedron_base.lawrence_polytope` | returns the Lawrence polytope of self
:meth:`~sage.geometry.polyhedron.base.Polyhedron_base.wedge` | returns the wedge over a face of self

**Combinatorics**

Expand Down
85 changes: 85 additions & 0 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4118,6 +4118,91 @@ def stack(self, face, position=None):
parent = self.parent().base_extend(new_vertex)
return parent.element_class(parent, [self.vertices() + (new_vertex,), self.rays(), self.lines()], None)

def wedge(self, face, width=1):
r"""
Return the wedge over a ``face`` of ``self``. ``self`` must be a
polytope and ``width`` must be nonzero.
The wedge over a face `F` of a polytope `P` with width `w \not\eq 0`
is defined as:
.. MATH::
(P \times \mathbb{R}) \cap \{a^\top x + |w x_{d+1}| \leq b\}
where `a^\top x = b` is a supporting hyperplane for `F`.
INPUT:
- ``face`` -- a PolyhedronFace of ``self``, the face which we take
the wedge over
- ``width`` -- a nonzero number (default: ``1``), the width of the
resulting polytope
OUTPUT:
A (bounded) Polyhedron object
EXAMPLES::
sage: P = polytopes.regular_polygon(4)
sage: W1 = wedge(P, P.faces(1)[0]); W1
A 3-dimensional polyhedron in AA^3 defined as the convex hull of 6 vertices
sage: W1.is_simple()
True
sage: Q = polytopes.hypersimplex(4,2)
sage: W2 = wedge(Q, Q.faces(2)[0]); W2
A 4-dimensional polyhedron in QQ^5 defined as the convex hull of 9 vertices
sage: W2.vertices()
(A vertex at (0, 1, 0, 1, 0),
A vertex at (0, 0, 1, 1, 0),
A vertex at (1, 0, 0, 1, -1),
A vertex at (1, 0, 0, 1, 1),
A vertex at (1, 0, 1, 0, 1),
A vertex at (1, 1, 0, 0, -1),
A vertex at (0, 1, 1, 0, 0),
A vertex at (1, 0, 1, 0, -1),
A vertex at (1, 1, 0, 0, 1))
sage: W3 = wedge(Q, Q.faces(1)[0]); W3
A 4-dimensional polyhedron in QQ^5 defined as the convex hull of 10 vertices
sage: W3.vertices()
(A vertex at (0, 1, 0, 1, 0),
A vertex at (0, 0, 1, 1, 0),
A vertex at (1, 0, 0, 1, -1),
A vertex at (1, 0, 0, 1, 1),
A vertex at (1, 0, 1, 0, 2),
A vertex at (0, 1, 1, 0, 1),
A vertex at (1, 0, 1, 0, -2),
A vertex at (1, 1, 0, 0, 2),
A vertex at (0, 1, 1, 0, -1),
A vertex at (1, 1, 0, 0, -2))
REFERENCES:
For more information, see Chapter 15 of [HoDaCG17]_.
"""
if not self.is_compact():
raise NotImplementedError("polyhedron `self` must be a polytope")

if width == 0:
raise ValueError("the width should be nonzero")

from sage.geometry.polyhedron.face import PolyhedronFace
if not isinstance(face, PolyhedronFace):
raise TypeError("{} should be a PolyhedronFace of {}".format(face, self))

F_Hrep = vector([0]*(self.ambient_dim()+1))
for facet in face.ambient_Hrepresentation():
if facet.is_inequality():
F_Hrep = F_Hrep + facet.vector()

L = Polyhedron(rays=[[1],[-1]])
Q = self.product(L)
H = Polyhedron(ieqs=[list(F_Hrep) + [width], list(F_Hrep) + [-width]])
return Q.intersection(H)

def lawrence_extension(self, v):
"""
Return the Lawrence extension of ``self`` on the point ``v``.
Expand Down

0 comments on commit d0be5c6

Please sign in to comment.