Skip to content

Commit

Permalink
Trac #28650: Fix the dimension of PolyhedronFace
Browse files Browse the repository at this point in the history
In this ticket, I am going to fix the implementation of the method `dim`
of `PolyhedronFace`. This problem occurs when we have a vertex and a ray
(or a line) with the same vector.
See the following example.
{{{
sage: P = Polyhedron(vertices=[[1,0]], rays=[[1,0],[0,1]]); P
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 1
vertex and 2 rays
sage: P.faces(P.dim())[0]
A 1-dimensional face of a Polyhedron in QQ^2 defined as the convex hull
of 1 vertex and 2 rays
}}}

URL: https://trac.sagemath.org/28650
Reported by: gh-LaisRast
Ticket author(s): Laith Rastanawi
Reviewer(s): Jonathan Kliem
  • Loading branch information
Release Manager committed Oct 30, 2019
2 parents e16cfda + 67d3ce0 commit 4243350
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/sage/geometry/polyhedron/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,23 @@ def dim(self):
[-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]
TESTS:
Check that :trac:`28650` is fixed::
sage: P = Polyhedron(vertices=[[1,0]], rays=[[1,0],[0,1]])
sage: P.faces(2)
(A 2-dimensional face of a Polyhedron in QQ^2 defined as the convex hull of 1 vertex and 2 rays,)
"""
if self.n_ambient_Vrepresentation() == 0:
return -1
else:
origin = vector(self.ambient_Vrepresentation(0))
v_list = [ vector(v)-origin for v in self.ambient_Vrepresentation() ]
origin = self.vertices()[0].vector()
v_list = [vector(v) - origin for v in
self.ambient_Vrepresentation() if v.is_vertex()]
v_list += [vector(v) for v in self.ambient_Vrepresentation()
if v.is_ray() or v.is_line()]
return matrix(v_list).rank()

def _repr_(self):
Expand Down

0 comments on commit 4243350

Please sign in to comment.