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

Commit

Permalink
tuple -> generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed May 11, 2020
1 parent 5d2e748 commit dd259d7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
50 changes: 25 additions & 25 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,50 +1508,50 @@ def Hrepresentation_str(self, separator='\n', latex=False, style='>=', align=Non
sage: P = polytopes.permutahedron(3)
sage: print(P.Hrepresentation_str())
x0 + x1 + x2 == 6
-x1 - x2 >= -5
-x2 >= -3
-x1 >= -3
x0 + x1 >= 3
-x0 - x1 >= -5
x1 >= 1
x1 + x2 >= 3
x2 >= 1
-x0 >= -3
x0 >= 1
-x1 >= -3
sage: print(P.Hrepresentation_str(style='<='))
-x0 - x1 - x2 == -6
x1 + x2 <= 5
x2 <= 3
x1 <= 3
-x0 - x1 <= -3
x0 + x1 <= 5
-x1 <= -1
-x1 - x2 <= -3
-x2 <= -1
x0 <= 3
-x0 <= -1
x1 <= 3
sage: print(P.Hrepresentation_str(style='positive'))
x0 + x1 + x2 == 6
5 >= x1 + x2
3 >= x2
3 >= x1
x0 + x1 >= 3
5 >= x0 + x1
x1 >= 1
x1 + x2 >= 3
x2 >= 1
3 >= x0
x0 >= 1
3 >= x1
sage: print(P.Hrepresentation_str(latex=True))
\begin{array}{rcl}
x_{0} + x_{1} + x_{2} & = & 6 \\
-x_{1} - x_{2} & \geq & -5 \\
-x_{2} & \geq & -3 \\
-x_{1} & \geq & -3 \\
x_{0} + x_{1} & \geq & 3 \\
-x_{0} - x_{1} & \geq & -5 \\
x_{1} & \geq & 1 \\
x_{1} + x_{2} & \geq & 3 \\
x_{2} & \geq & 1
-x_{0} & \geq & -3 \\
x_{0} & \geq & 1 \\
-x_{1} & \geq & -3
\end{array}
sage: print(P.Hrepresentation_str(align=False))
x0 + x1 + x2 == 6
-x1 - x2 >= -5
-x2 >= -3
-x1 >= -3
x0 + x1 >= 3
-x0 - x1 >= -5
x1 >= 1
x1 + x2 >= 3
x2 >= 1
-x0 >= -3
x0 >= 1
-x1 >= -3
sage: c = polytopes.cube()
sage: c.Hrepresentation_str(separator=', ', style='positive')
Expand Down
16 changes: 8 additions & 8 deletions src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,12 @@ cdef class CombinatorialPolyhedron(SageObject):
sage: C = CombinatorialPolyhedron(P)
sage: C.Hrepresentation()
(An equation (1, 1, 1) x - 6 == 0,
An inequality (0, -1, -1) x + 5 >= 0,
An inequality (0, 0, -1) x + 3 >= 0,
An inequality (0, -1, 0) x + 3 >= 0,
An inequality (1, 1, 0) x - 3 >= 0,
An inequality (-1, -1, 0) x + 5 >= 0,
An inequality (0, 1, 0) x - 1 >= 0,
An inequality (0, 1, 1) x - 3 >= 0,
An inequality (0, 0, 1) x - 1 >= 0)
An inequality (-1, 0, 0) x + 3 >= 0,
An inequality (1, 0, 0) x - 1 >= 0,
An inequality (0, -1, 0) x + 3 >= 0)
sage: points = [(1,0,0), (0,1,0), (0,0,1),
....: (-1,0,0), (0,-1,0), (0,0,-1)]
Expand Down Expand Up @@ -1223,10 +1223,10 @@ cdef class CombinatorialPolyhedron(SageObject):
sage: P = polytopes.permutahedron(2)
sage: C = CombinatorialPolyhedron(P)
sage: C.ridges()
((An inequality (0, -1) x + 2 >= 0, An inequality (0, 1) x - 1 >= 0),)
((An inequality (1, 0) x - 1 >= 0, An inequality (-1, 0) x + 2 >= 0),)
sage: C.ridges(add_equalities=True)
(((An inequality (0, -1) x + 2 >= 0, An equation (1, 1) x - 3 == 0),
(An inequality (0, 1) x - 1 >= 0, An equation (1, 1) x - 3 == 0)),)
(((An inequality (1, 0) x - 1 >= 0, An equation (1, 1) x - 3 == 0),
(An inequality (-1, 0) x + 2 >= 0, An equation (1, 1) x - 3 == 0)),)
sage: P = polytopes.cyclic_polytope(4,5)
sage: C = CombinatorialPolyhedron(P)
Expand Down
10 changes: 5 additions & 5 deletions src/sage/geometry/polyhedron/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -2535,7 +2535,7 @@ def permutahedron(self, n, project=False, backend=None):
sage: assert P == Polyhedron(P.vertices())
sage: assert P == Polyhedron(ieqs=P.inequalities(), eqns=P.equations())
"""
verts = tuple(itertools.permutations(range(1, n + 1)))
verts = itertools.permutations(range(1, n + 1))
if project:
verts = project_points(*verts)
return Polyhedron(vertices=verts, backend=backend)
Expand All @@ -2547,15 +2547,15 @@ def tri(m):
# Each proper `S \subset [n]` corresponds exactly to
# a facet that minimizes the coordinates in `S`.
# The minimal sum for `m` coordinates is `(m*(m+1))/2`.
ieqs = tuple((-tri(sum(x)),) + x
for x in itertools.product([0,1], repeat=n)
if 0 < sum(x) < n)
ieqs = ((-tri(sum(x)),) + x
for x in itertools.product([0,1], repeat=n)
if 0 < sum(x) < n)

# Adding the defining equality.
eqns = ((-tri(n),) + tuple(1 for _ in range(n)),)

return parent([verts, [], []], [ieqs, eqns],
Vrep_minimal=True, Hrep_minimal=True)
Vrep_minimal=True, Hrep_minimal=True, pref_rep="Hrep")


def generalized_permutahedron(self, coxeter_type, point=None, exact=True, regular=False, backend=None):
Expand Down

0 comments on commit dd259d7

Please sign in to comment.