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

Commit

Permalink
fixed 28506 by always taking fraction field
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Sep 16, 2019
1 parent fa1a517 commit 20ad51f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
12 changes: 8 additions & 4 deletions src/sage/geometry/polyhedron/base.py
Expand Up @@ -3467,7 +3467,7 @@ def minkowski_difference(self, other):
sage: four_cube = polytopes.hypercube(4)
sage: four_simplex = Polyhedron(vertices = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]])
sage: four_cube - four_simplex
A 4-dimensional polyhedron in ZZ^4 defined as the convex hull of 16 vertices
A 4-dimensional polyhedron in QQ^4 defined as the convex hull of 16 vertices
sage: four_cube.minkowski_difference(four_simplex) == four_cube - four_simplex
True
Expand Down Expand Up @@ -3521,7 +3521,9 @@ def minkowski_difference(self, other):
ieq = list(ieq)
ieq[0] += min(values) # shift constant term
new_ieqs.append(ieq)
P = self.parent()

# Some vertices might need fractions.
P = self.parent().change_ring(self.base_ring().fraction_field())
return P.element_class(P, None, [new_ieqs, new_eqns])

def __sub__(self, other):
Expand Down Expand Up @@ -3884,7 +3886,8 @@ def direct_sum(self, other):
sage: t = s2.direct_sum(s3)
"""
try:
new_ring = self.parent()._coerce_base_ring(other)
# Some vertices might need fractions.
new_ring = self.parent()._coerce_base_ring(other).fraction_field()
except TypeError:
raise TypeError("no common canonical parent for objects with parents: " + str(self.parent())
+ " and " + str(other.parent()))
Expand Down Expand Up @@ -4358,7 +4361,8 @@ def face_truncation(self, face, linear_coefficients=None, cut_frac=None):
new_ieqs = self.inequalities_list() + [ineq_vector]
new_eqns = self.equations_list()

parent = self.parent().base_extend(cut_frac)
# Some vertices might need fractions.
parent = self.parent().base_extend(cut_frac/1)
return parent.element_class(parent, None, [new_ieqs, new_eqns])

def stack(self, face, position=None):
Expand Down
20 changes: 10 additions & 10 deletions src/sage/geometry/polyhedron/base_ZZ.py
Expand Up @@ -483,31 +483,31 @@ def minkowski_decompositions(self):
sage: square = Polyhedron(vertices=[(0,0),(1,0),(0,1),(1,1)])
sage: square.minkowski_decompositions()
((A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex,
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 4 vertices),
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 4 vertices),
(A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices,
A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices))
A 1-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices))
Example from http://cgi.di.uoa.gr/~amantzaf/geo/ ::
sage: Q = Polyhedron(vertices=[(4,0), (6,0), (0,3), (4,3)])
sage: R = Polyhedron(vertices=[(0,0), (5,0), (8,4), (3,2)])
sage: (Q+R).minkowski_decompositions()
((A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex,
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 7 vertices),
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 7 vertices),
(A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 4 vertices,
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 4 vertices),
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 4 vertices),
(A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices,
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 7 vertices),
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 7 vertices),
(A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 5 vertices,
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 4 vertices),
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 4 vertices),
(A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices,
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 7 vertices),
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 7 vertices),
(A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 5 vertices,
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 3 vertices),
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 3 vertices),
(A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices,
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 7 vertices),
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 7 vertices),
(A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices,
A 2-dimensional polyhedron in ZZ^2 defined as the convex hull of 6 vertices))
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 6 vertices))
sage: [ len(square.dilation(i).minkowski_decompositions())
....: for i in range(6) ]
Expand Down

0 comments on commit 20ad51f

Please sign in to comment.