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

Commit

Permalink
double description for pyramid
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Jul 7, 2021
1 parent 473cd41 commit 2b1c64b
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7788,13 +7788,25 @@ def pyramid(self):
'cdd'
"""
assert self.is_compact(), "Not a polytope."
c = self.center()

new_verts = \
[[0] + x for x in self.Vrep_generator()] + \
[[1] + list(self.center())]
from itertools import chain
new_verts = chain(([0] + x for x in self.Vrep_generator()),
[[1] + list(c)])
new_ieqs = chain(([i.b()] + [-c*i.A() - i.b()] + list(i.A()) for i in self.inequalities()),
[[0, 1] + [0]*self.ambient_dim()])
new_eqns = ([e.b()] + [0] + list(e.A()) for e in self.equations())

pref_rep = 'Hrep' if self.n_vertices() > self.n_inequalities() else 'Vrep'
parent = self.parent().base_extend(self.center().parent(), ambient_dim=self.ambient_dim()+1)
return parent.element_class(parent, [new_verts, [], []], None)

if self.n_vertices() == 1:
# Fix the polyhedron with one vertex.
return parent.element_class(parent, [new_verts, [], []], None)

return parent.element_class(parent, [new_verts, [], []],
[new_ieqs, new_eqns],
Vrep_minimal=True, Hrep_minimal=True, pref_rep=pref_rep)

def _test_pyramid(self, tester=None, **options):
"""
Expand Down Expand Up @@ -7844,6 +7856,18 @@ def check_pyramid_certificate(P, cert):

tester.assertTrue(pyr_polar.is_combinatorially_isomorphic(pyr_polar))

# Basic properties of the pyramid.

# Check that the prism preserves the backend.
tester.assertEqual(pyr.backend(), self.backend())

tester.assertEqual(1 + self.n_vertices(), pyr.n_vertices())
tester.assertEqual(self.n_equations(), pyr.n_equations())
tester.assertEqual(1 + self.n_inequalities(), pyr.n_inequalities())

if self.n_vertices() < 15 and self.n_facets() < 15:
pyr._test_basic_properties()

def bipyramid(self):
"""
Return a polyhedron that is a bipyramid over the original.
Expand Down

0 comments on commit 2b1c64b

Please sign in to comment.