Skip to content

Commit

Permalink
simplified construction of H, small changes mostly in the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Aug 26, 2019
1 parent 73dac03 commit 38944ad
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2757,14 +2757,14 @@ def normal_fan(self, direction='inner'):
r"""
Return the normal fan of a compact full-dimensional rational polyhedron.
This returns the inner normal fan of ``self``. For the outer normal fan,
This returns the inner normal fan of ``self``. For the outer normal fan,
use ``direction='outer'``.
INPUT:
- ``direction`` -- either ``'inner'`` (default) or ``'outer'``; if
set to ``'inner'``, use the inner normal vectors to span the cones of
the fan, if set to ``'outer'``, use the outer normal vectors.
- ``direction`` -- either ``'inner'`` (default) or ``'outer'``; if
set to ``'inner'``, use the inner normal vectors to span the cones of
the fan, if set to ``'outer'``, use the outer normal vectors.
OUTPUT:
Expand Down Expand Up @@ -4172,12 +4172,12 @@ def wedge(self, face, width=1):
- ``face`` -- a PolyhedronFace of ``self``, the face which we take
the wedge over
- ``width`` -- a nonzero number (default: ``1``), indicates how wide
the resulted wedge should be
- ``width`` -- a nonzero number (default: ``1``);
specifies how wide the wedge will be
OUTPUT:
A (bounded) Polyhedron object
A (bounded) polyhedron
EXAMPLES::
Expand Down Expand Up @@ -4228,9 +4228,9 @@ def wedge(self, face, width=1):
TESTS::
The backend should be preserved as long as this is possible. The
base_ring will change to the field of fractions of the current
base_ring, if width takes the default value 1.
The backend should be preserved as long as the value of width permits.
The base_ring will change to the field of fractions of the current
base_ring, unless width forces a different ring.
sage: P = polytopes.cyclic_polytope(3,7, base_ring=ZZ, backend='field')
sage: W1 = P.wedge(P.faces(2)[0]); W1.base_ring(); W1.backend()
Expand All @@ -4254,7 +4254,12 @@ def wedge(self, face, width=1):
A vertex at (4, 16, 64, 2),
A vertex at (6, 36, 216, 10),
A vertex at (5, 25, 125, 5))
sage: W2 = P.wedge(P.faces(2)[0], width=1.0); W2.base_ring(); W2.backend()
Real Double Field
'cdd'
"""
width = width*ZZ.one()

if not self.is_compact():
raise ValueError("polyhedron 'self' must be a polytope")

Expand All @@ -4271,13 +4276,16 @@ def wedge(self, face, width=1):
F_Hrep = F_Hrep + facet.vector()
F_Hrep = list(F_Hrep)

# Preserve the backend, if value of ``width`` permits.
backend = None
from .parent import does_backend_handle_base_ring
if does_backend_handle_base_ring(width.base_ring().fraction_field(), self.backend()):
backend = self.backend()

L = Polyhedron(lines=[[1]])
Q = self.product(L)

parent = self.parent().base_extend(ZZ.one()/width,\
ambient_dim=self.ambient_dim()+1)
ieqs = [F_Hrep + [width], F_Hrep + [-width]]
H = parent(None, [ieqs, []], convert=True)
H = Polyhedron(ieqs=ieqs, backend=backend)
return Q.intersection(H)

def lawrence_extension(self, v):
Expand Down

0 comments on commit 38944ad

Please sign in to comment.