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

Commit 1c6c90a

Browse files
author
Jonathan Kliem
committed
stable position for equations for backend cdd
1 parent 9d686f2 commit 1c6c90a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/sage/geometry/polyhedron/backend_cdd.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,22 @@ def _init_from_cdd_output(self, cddout):
238238
sage: V.points()[1], R[V.points()[1]]
239239
(P(-2686.81000000000, -2084.19000000000),
240240
A 2-dimensional polyhedron in RDF^2 defined as the convex hull of 1 vertex, 1 ray, 1 line)
241+
242+
Check that :trac:`31253` is fixed::
243+
244+
sage: P = polytopes.permutahedron(2, backend='cdd')
245+
sage: P.Hrepresentation()
246+
(An inequality (0, 1) x - 1 >= 0,
247+
An inequality (1, 0) x - 1 >= 0,
248+
An equation (1, 1) x - 3 == 0)
249+
sage: Q = Polyhedron(P.vertices(), backend='cdd')
250+
sage: Q.Hrepresentation()
251+
(An inequality (-1, 0) x + 2 >= 0,
252+
An inequality (1, 0) x - 1 >= 0,
253+
An equation (1, 1) x - 3 == 0)
254+
sage: [x.ambient_Hrepresentation() for x in P.facets()]
255+
[(An equation (1, 1) x - 3 == 0, An inequality (1, 0) x - 1 >= 0),
256+
(An equation (1, 1) x - 3 == 0, An inequality (0, 1) x - 1 >= 0)]
241257
"""
242258
cddout = cddout.splitlines()
243259

@@ -271,7 +287,12 @@ def parse_H_representation(intro, data):
271287
assert self.ambient_dim() == dimension - 1, "Unexpected ambient dimension"
272288
assert len(data) == count, "Unexpected number of lines"
273289
R = self.base_ring()
274-
for i, line in enumerate(data):
290+
from itertools import chain
291+
# We add equations to the end of the Hrepresentation.
292+
for i in chain(
293+
(j for j in range(len(data)) if not j in equations),
294+
equations):
295+
line = data[i]
275296
coefficients = [R(x) for x in line]
276297
if coefficients[0] != 0 and all(e == 0 for e in coefficients[1:]):
277298
# cddlib sometimes includes an implicit plane at infinity: 1 0 0 ... 0

0 commit comments

Comments
 (0)