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

Commit 12a15b8

Browse files
author
Thierry Monteil
committed
#28464 : fix the construction of a simplex of vertices in Polyhedron_base.is_inscribed
1 parent bdf4b23 commit 12a15b8

File tree

1 file changed

+62
-6
lines changed
  • src/sage/geometry/polyhedron

1 file changed

+62
-6
lines changed

src/sage/geometry/polyhedron/base.py

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,6 +2553,55 @@ def is_inscribed(self, certificate=False):
25532553
Traceback (most recent call last):
25542554
...
25552555
NotImplementedError: this function is not implemented for unbounded polyhedron
2556+
2557+
TESTS:
2558+
2559+
We check that :trac:`28464` is fixed::
2560+
2561+
sage: P = Polyhedron(vertices=[(-130658298093891402635075/416049251842505144482473,
2562+
....: 177469511761879509172000/1248147755527515433447419,
2563+
....: 485550543257132133136169/2496295511055030866894838,
2564+
....: 2010744967797898733758669/2496295511055030866894838),
2565+
....: (-146945725603929909850/706333405676769433081,
2566+
....: -84939725782618445000/706333405676769433081,
2567+
....: 560600045283000988081/1412666811353538866162,
2568+
....: 969778382942371268081/1412666811353538866162),
2569+
....: (-46275018824497300/140422338198040641,
2570+
....: -5747688262110000/46807446066013547, 1939357556329/7033601552658,
2571+
....: 1939357556329/7033601552658), (-17300/59929, -10000/59929, 39929/119858,
2572+
....: 39929/119858), (-4700/32209, -10000/32209, 12209/64418, 12209/64418),
2573+
....: (QQ(0), QQ(0), QQ(0), QQ(1)), (QQ(0), QQ(0), 1/2, 1/2), (300/10027,
2574+
....: -10000/30081, 10081/60162, 10081/60162), (112393975400/1900567733649,
2575+
....: 117311600000/633522577883, 43678681/95197362, 43678681/95197362),
2576+
....: (6109749955400/133380598418321, 37106807920000/133380598418321,
2577+
....: 2677964249/6680888498, 2677964249/6680888498),
2578+
....: (29197890764005600/402876806828660641,
2579+
....: -2150510776960000/402876806828660641,
2580+
....: 398575785274740641/805753613657321282,
2581+
....: 398575785274740641/805753613657321282),
2582+
....: (5576946899441759759983005325/110078073300232813237456943251,
2583+
....: -29071211718677797926570478000/110078073300232813237456943251,
2584+
....: 59439312069347378584317232001/220156146600465626474913886502,
2585+
....: 181346577228466312205473034501/220156146600465626474913886502),
2586+
....: (150040732779124914266530235300/6774574358246204311268446913881,
2587+
....: -2813827375989039189507000218000/6774574358246204311268446913881,
2588+
....: 1260217414021285074925933133881/13549148716492408622536893827762,
2589+
....: 3232518047094242684574253773881/13549148716492408622536893827762),
2590+
....: (3816349407976279597850158016285000/88842127448735433741180809504357161,
2591+
....: 27965821247423216557301387453968000/88842127448735433741180809504357161,
2592+
....: 68546256000224819256028677086357161/177684254897470867482361619008714322,
2593+
....: 86062257922545755787315412690197161/177684254897470867482361619008714322)])
2594+
sage: P.is_inscribed()
2595+
True
2596+
2597+
sage: P = Polyhedron(vertices=[[0, -1, 0, 0],
2598+
....: [0, 0, -1, 0],
2599+
....: [0, 0, 0, -1],
2600+
....: [0, 0, +1, 0],
2601+
....: [0, 0, 0, +1],
2602+
....: [+1, 0, 0, 0]])
2603+
sage: P.is_inscribed()
2604+
True
25562605
"""
25572606

25582607
if not self.is_compact():
@@ -2563,13 +2612,20 @@ def is_inscribed(self, certificate=False):
25632612

25642613
dimension = self.dimension()
25652614
vertices = self.vertices()
2566-
vertex = vertices[0]
2567-
vertex_neighbors = vertex.neighbors()
25682615

2569-
# The following simplex is full-dimensional because `self` is assumed
2570-
# to be: every vertex has at least `dimension` neighbors and they form
2571-
# a full simplex with `vertex`.
2572-
simplex_vertices = [vertex] + [next(vertex_neighbors) for i in range(dimension)]
2616+
# We greedily construct a full-dimensional simplex made of vertices
2617+
# around some vertex of self.
2618+
vertex = vertices[0]
2619+
v0 = vertex.vector()
2620+
M = matrix(self.base_ring(), dimension, 0)
2621+
simplex_vertices = [vertex]
2622+
for v in vertex.neighbors():
2623+
MA = M.augment(v.vector()-v0)
2624+
if MA.rank() > M.rank():
2625+
simplex_vertices.append(v)
2626+
M = MA
2627+
if M.rank() == dimension:
2628+
break
25732629

25742630
raw_data = []
25752631
for vertex in simplex_vertices:

0 commit comments

Comments
 (0)