passagemath-polyhedra 10.6.37__cp314-cp314-musllinux_1_2_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passagemath_polyhedra/__init__.py +3 -0
- passagemath_polyhedra-10.6.37.dist-info/METADATA +367 -0
- passagemath_polyhedra-10.6.37.dist-info/METADATA.bak +369 -0
- passagemath_polyhedra-10.6.37.dist-info/RECORD +209 -0
- passagemath_polyhedra-10.6.37.dist-info/WHEEL +5 -0
- passagemath_polyhedra-10.6.37.dist-info/top_level.txt +3 -0
- passagemath_polyhedra.libs/libgcc_s-0cd532bd.so.1 +0 -0
- passagemath_polyhedra.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
- passagemath_polyhedra.libs/libgomp-8949ffbe.so.1.0.0 +0 -0
- passagemath_polyhedra.libs/libstdc++-5d72f927.so.6.0.33 +0 -0
- sage/all__sagemath_polyhedra.py +50 -0
- sage/game_theory/all.py +8 -0
- sage/game_theory/catalog.py +6 -0
- sage/game_theory/catalog_normal_form_games.py +923 -0
- sage/game_theory/cooperative_game.py +844 -0
- sage/game_theory/matching_game.py +1181 -0
- sage/game_theory/normal_form_game.py +2697 -0
- sage/game_theory/parser.py +275 -0
- sage/geometry/all__sagemath_polyhedra.py +22 -0
- sage/geometry/cone.py +6940 -0
- sage/geometry/cone_catalog.py +847 -0
- sage/geometry/cone_critical_angles.py +1027 -0
- sage/geometry/convex_set.py +1119 -0
- sage/geometry/fan.py +3743 -0
- sage/geometry/fan_isomorphism.py +389 -0
- sage/geometry/fan_morphism.py +1884 -0
- sage/geometry/hasse_diagram.py +202 -0
- sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
- sage/geometry/hyperplane_arrangement/all.py +1 -0
- sage/geometry/hyperplane_arrangement/arrangement.py +3905 -0
- sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
- sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
- sage/geometry/hyperplane_arrangement/library.py +825 -0
- sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
- sage/geometry/hyperplane_arrangement/plot.py +520 -0
- sage/geometry/integral_points.py +35 -0
- sage/geometry/integral_points_generic_dense.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/integral_points_generic_dense.pyx +7 -0
- sage/geometry/lattice_polytope.py +5894 -0
- sage/geometry/linear_expression.py +773 -0
- sage/geometry/newton_polygon.py +767 -0
- sage/geometry/point_collection.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/point_collection.pyx +1008 -0
- sage/geometry/polyhedral_complex.py +2616 -0
- sage/geometry/polyhedron/all.py +8 -0
- sage/geometry/polyhedron/backend_cdd.py +460 -0
- sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
- sage/geometry/polyhedron/backend_field.py +347 -0
- sage/geometry/polyhedron/backend_normaliz.py +2503 -0
- sage/geometry/polyhedron/backend_number_field.py +168 -0
- sage/geometry/polyhedron/backend_polymake.py +765 -0
- sage/geometry/polyhedron/backend_ppl.py +582 -0
- sage/geometry/polyhedron/base.py +1206 -0
- sage/geometry/polyhedron/base0.py +1444 -0
- sage/geometry/polyhedron/base1.py +886 -0
- sage/geometry/polyhedron/base2.py +812 -0
- sage/geometry/polyhedron/base3.py +1845 -0
- sage/geometry/polyhedron/base4.py +1262 -0
- sage/geometry/polyhedron/base5.py +2700 -0
- sage/geometry/polyhedron/base6.py +1741 -0
- sage/geometry/polyhedron/base7.py +997 -0
- sage/geometry/polyhedron/base_QQ.py +1258 -0
- sage/geometry/polyhedron/base_RDF.py +98 -0
- sage/geometry/polyhedron/base_ZZ.py +934 -0
- sage/geometry/polyhedron/base_mutable.py +215 -0
- sage/geometry/polyhedron/base_number_field.py +122 -0
- sage/geometry/polyhedron/cdd_file_format.py +155 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
- sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
- sage/geometry/polyhedron/constructor.py +773 -0
- sage/geometry/polyhedron/double_description.py +753 -0
- sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
- sage/geometry/polyhedron/face.py +1060 -0
- sage/geometry/polyhedron/generating_function.py +1810 -0
- sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
- sage/geometry/polyhedron/library.py +3502 -0
- sage/geometry/polyhedron/misc.py +121 -0
- sage/geometry/polyhedron/modules/all.py +1 -0
- sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
- sage/geometry/polyhedron/palp_database.py +447 -0
- sage/geometry/polyhedron/parent.py +1279 -0
- sage/geometry/polyhedron/plot.py +1986 -0
- sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
- sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
- sage/geometry/polyhedron/representation.py +1723 -0
- sage/geometry/pseudolines.py +515 -0
- sage/geometry/relative_interior.py +445 -0
- sage/geometry/toric_plotter.py +1103 -0
- sage/geometry/triangulation/all.py +2 -0
- sage/geometry/triangulation/base.cpython-314-x86_64-linux-musl.so +0 -0
- sage/geometry/triangulation/base.pyx +963 -0
- sage/geometry/triangulation/data.h +147 -0
- sage/geometry/triangulation/data.pxd +4 -0
- sage/geometry/triangulation/element.py +914 -0
- sage/geometry/triangulation/functions.h +10 -0
- sage/geometry/triangulation/functions.pxd +4 -0
- sage/geometry/triangulation/point_configuration.py +2256 -0
- sage/geometry/triangulation/triangulations.h +49 -0
- sage/geometry/triangulation/triangulations.pxd +7 -0
- sage/geometry/voronoi_diagram.py +319 -0
- sage/interfaces/all__sagemath_polyhedra.py +1 -0
- sage/interfaces/polymake.py +2028 -0
- sage/numerical/all.py +13 -0
- sage/numerical/all__sagemath_polyhedra.py +11 -0
- sage/numerical/backends/all.py +1 -0
- sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
- sage/numerical/backends/cvxopt_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/cvxopt_backend.pyx +1006 -0
- sage/numerical/backends/cvxopt_backend_test.py +19 -0
- sage/numerical/backends/cvxopt_sdp_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
- sage/numerical/backends/cvxpy_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/cvxpy_backend.pxd +41 -0
- sage/numerical/backends/cvxpy_backend.pyx +934 -0
- sage/numerical/backends/cvxpy_backend_test.py +13 -0
- sage/numerical/backends/generic_backend_test.py +24 -0
- sage/numerical/backends/interactivelp_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/interactivelp_backend.pxd +36 -0
- sage/numerical/backends/interactivelp_backend.pyx +1231 -0
- sage/numerical/backends/interactivelp_backend_test.py +12 -0
- sage/numerical/backends/logging_backend.py +391 -0
- sage/numerical/backends/matrix_sdp_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
- sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
- sage/numerical/backends/ppl_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/ppl_backend.pyx +1126 -0
- sage/numerical/backends/ppl_backend_test.py +13 -0
- sage/numerical/backends/scip_backend.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/backends/scip_backend.pxd +22 -0
- sage/numerical/backends/scip_backend.pyx +1289 -0
- sage/numerical/backends/scip_backend_test.py +13 -0
- sage/numerical/interactive_simplex_method.py +5338 -0
- sage/numerical/knapsack.py +665 -0
- sage/numerical/linear_functions.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/linear_functions.pxd +31 -0
- sage/numerical/linear_functions.pyx +1648 -0
- sage/numerical/linear_tensor.py +470 -0
- sage/numerical/linear_tensor_constraints.py +448 -0
- sage/numerical/linear_tensor_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/linear_tensor_element.pxd +6 -0
- sage/numerical/linear_tensor_element.pyx +459 -0
- sage/numerical/mip.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/mip.pxd +40 -0
- sage/numerical/mip.pyx +3667 -0
- sage/numerical/sdp.cpython-314-x86_64-linux-musl.so +0 -0
- sage/numerical/sdp.pxd +39 -0
- sage/numerical/sdp.pyx +1433 -0
- sage/rings/all__sagemath_polyhedra.py +3 -0
- sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
- sage/rings/polynomial/omega.py +982 -0
- sage/schemes/all__sagemath_polyhedra.py +2 -0
- sage/schemes/toric/all.py +10 -0
- sage/schemes/toric/chow_group.py +1248 -0
- sage/schemes/toric/divisor.py +2082 -0
- sage/schemes/toric/divisor_class.cpython-314-x86_64-linux-musl.so +0 -0
- sage/schemes/toric/divisor_class.pyx +322 -0
- sage/schemes/toric/fano_variety.py +1606 -0
- sage/schemes/toric/homset.py +650 -0
- sage/schemes/toric/ideal.py +451 -0
- sage/schemes/toric/library.py +1322 -0
- sage/schemes/toric/morphism.py +1958 -0
- sage/schemes/toric/points.py +1032 -0
- sage/schemes/toric/sheaf/all.py +1 -0
- sage/schemes/toric/sheaf/constructor.py +302 -0
- sage/schemes/toric/sheaf/klyachko.py +921 -0
- sage/schemes/toric/toric_subscheme.py +905 -0
- sage/schemes/toric/variety.py +3460 -0
- sage/schemes/toric/weierstrass.py +1078 -0
- sage/schemes/toric/weierstrass_covering.py +457 -0
- sage/schemes/toric/weierstrass_higher.py +288 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
- sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
- sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
- sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
- sage_wheels/share/reflexive_polytopes/reflexive_polytopes_3d +37977 -0
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-polyhedra
|
|
2
|
+
"""
|
|
3
|
+
The PPL (Parma Polyhedra Library) backend for polyhedral computations
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from sage.structure.element import Element
|
|
7
|
+
from sage.rings.integer_ring import ZZ
|
|
8
|
+
from sage.rings.integer import Integer
|
|
9
|
+
from sage.arith.functions import LCM_list
|
|
10
|
+
from sage.misc.functional import denominator
|
|
11
|
+
from .base_mutable import Polyhedron_mutable
|
|
12
|
+
from .base_QQ import Polyhedron_QQ
|
|
13
|
+
from .base_ZZ import Polyhedron_ZZ
|
|
14
|
+
from .representation import VERTEX, RAY, LINE, INEQUALITY, EQUATION
|
|
15
|
+
|
|
16
|
+
from sage.misc.lazy_import import lazy_import
|
|
17
|
+
from sage.features import PythonModule
|
|
18
|
+
lazy_import('ppl', ['C_Polyhedron', 'Generator_System', 'Constraint_System',
|
|
19
|
+
'Linear_Expression', 'line', 'ray', 'point'],
|
|
20
|
+
feature=PythonModule("ppl", spkg='pplpy', type='standard'))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#########################################################################
|
|
24
|
+
class Polyhedron_ppl(Polyhedron_mutable):
|
|
25
|
+
"""
|
|
26
|
+
Polyhedra with ppl.
|
|
27
|
+
|
|
28
|
+
INPUT:
|
|
29
|
+
|
|
30
|
+
- ``Vrep`` -- list ``[vertices, rays, lines]`` or ``None``
|
|
31
|
+
|
|
32
|
+
- ``Hrep`` -- list ``[ieqs, eqns]`` or ``None``
|
|
33
|
+
|
|
34
|
+
EXAMPLES::
|
|
35
|
+
|
|
36
|
+
sage: p = Polyhedron(vertices=[(0,0),(1,0),(0,1)], rays=[(1,1)], lines=[], backend='ppl')
|
|
37
|
+
sage: TestSuite(p).run()
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
_backend_object_name = "ppl_polyhedron"
|
|
41
|
+
_is_mutable = True
|
|
42
|
+
|
|
43
|
+
def __init__(self, parent, Vrep, Hrep, ppl_polyhedron=None, mutable=False, **kwds):
|
|
44
|
+
"""
|
|
45
|
+
Initialize the polyhedron.
|
|
46
|
+
|
|
47
|
+
See :class:`Polyhedron_ppl` for a description of the input
|
|
48
|
+
data.
|
|
49
|
+
|
|
50
|
+
TESTS::
|
|
51
|
+
|
|
52
|
+
sage: p = Polyhedron()
|
|
53
|
+
sage: TestSuite(p).run()
|
|
54
|
+
sage: p = Polyhedron(vertices=[(1, 1)], rays=[(0, 1)])
|
|
55
|
+
sage: TestSuite(p).run()
|
|
56
|
+
sage: q = polytopes.cube()
|
|
57
|
+
sage: p = q.parent().element_class(q.parent(), None, None, q._ppl_polyhedron)
|
|
58
|
+
sage: TestSuite(p).run()
|
|
59
|
+
"""
|
|
60
|
+
# This is important. For some reason the element constructor copies the list sometimes.
|
|
61
|
+
self._dependent_objects = []
|
|
62
|
+
if ppl_polyhedron:
|
|
63
|
+
if Hrep is not None or Vrep is not None:
|
|
64
|
+
raise ValueError("only one of Vrep, Hrep, or ppl_polyhedron can be different from None")
|
|
65
|
+
Element.__init__(self, parent=parent)
|
|
66
|
+
minimize = bool('minimize' in kwds and kwds['minimize'])
|
|
67
|
+
self._init_from_ppl_polyhedron(ppl_polyhedron, minimize)
|
|
68
|
+
else:
|
|
69
|
+
Polyhedron_mutable.__init__(self, parent, Vrep, Hrep, **kwds)
|
|
70
|
+
if not mutable:
|
|
71
|
+
self.set_immutable()
|
|
72
|
+
|
|
73
|
+
def _init_from_Vrepresentation(self, vertices, rays, lines, minimize=True, verbose=False):
|
|
74
|
+
"""
|
|
75
|
+
Construct polyhedron from V-representation data.
|
|
76
|
+
|
|
77
|
+
INPUT:
|
|
78
|
+
|
|
79
|
+
- ``vertices`` -- list of point. Each point can be specified
|
|
80
|
+
as any iterable container of
|
|
81
|
+
:meth:`~sage.geometry.polyhedron.base.base_ring` elements.
|
|
82
|
+
|
|
83
|
+
- ``rays`` -- list of rays. Each ray can be specified as any
|
|
84
|
+
iterable container of
|
|
85
|
+
:meth:`~sage.geometry.polyhedron.base.base_ring` elements.
|
|
86
|
+
|
|
87
|
+
- ``lines`` -- list of lines. Each line can be specified as
|
|
88
|
+
any iterable container of
|
|
89
|
+
:meth:`~sage.geometry.polyhedron.base.base_ring` elements.
|
|
90
|
+
|
|
91
|
+
- ``verbose`` -- boolean (default: ``False``); whether to print
|
|
92
|
+
verbose output for debugging purposes
|
|
93
|
+
|
|
94
|
+
EXAMPLES::
|
|
95
|
+
|
|
96
|
+
sage: p = Polyhedron(backend='ppl')
|
|
97
|
+
sage: from sage.geometry.polyhedron.backend_ppl import Polyhedron_ppl
|
|
98
|
+
sage: Polyhedron_ppl._init_from_Vrepresentation(p, [], [], [])
|
|
99
|
+
"""
|
|
100
|
+
gs = self._convert_generators_to_ppl(vertices, rays, lines)
|
|
101
|
+
if gs.empty():
|
|
102
|
+
ppl_polyhedron = C_Polyhedron(self.ambient_dim(), 'empty')
|
|
103
|
+
else:
|
|
104
|
+
ppl_polyhedron = C_Polyhedron(gs)
|
|
105
|
+
self._init_from_ppl_polyhedron(ppl_polyhedron, minimize)
|
|
106
|
+
|
|
107
|
+
def _init_from_Hrepresentation(self, ieqs, eqns, minimize=True, verbose=False):
|
|
108
|
+
"""
|
|
109
|
+
Construct polyhedron from H-representation data.
|
|
110
|
+
|
|
111
|
+
INPUT:
|
|
112
|
+
|
|
113
|
+
- ``ieqs`` -- list of inequalities. Each line can be specified
|
|
114
|
+
as any iterable container of
|
|
115
|
+
:meth:`~sage.geometry.polyhedron.base.base_ring` elements.
|
|
116
|
+
|
|
117
|
+
- ``eqns`` -- list of equalities. Each line can be specified
|
|
118
|
+
as any iterable container of
|
|
119
|
+
:meth:`~sage.geometry.polyhedron.base.base_ring` elements.
|
|
120
|
+
|
|
121
|
+
- ``verbose`` -- boolean (default: ``False``); whether to print
|
|
122
|
+
verbose output for debugging purposes
|
|
123
|
+
|
|
124
|
+
EXAMPLES::
|
|
125
|
+
|
|
126
|
+
sage: p = Polyhedron(backend='ppl')
|
|
127
|
+
sage: from sage.geometry.polyhedron.backend_ppl import Polyhedron_ppl
|
|
128
|
+
sage: Polyhedron_ppl._init_from_Hrepresentation(p, [], [])
|
|
129
|
+
"""
|
|
130
|
+
cs = self._convert_constraints_to_ppl(ieqs, eqns)
|
|
131
|
+
if cs.empty():
|
|
132
|
+
ppl_polyhedron = C_Polyhedron(self.ambient_dim(), 'universe')
|
|
133
|
+
else:
|
|
134
|
+
ppl_polyhedron = C_Polyhedron(cs)
|
|
135
|
+
self._init_from_ppl_polyhedron(ppl_polyhedron, minimize)
|
|
136
|
+
|
|
137
|
+
def _init_from_ppl_polyhedron(self, ppl_polyhedron, minimize=True):
|
|
138
|
+
"""
|
|
139
|
+
Create the V-/Hrepresentation objects from the ppl polyhedron.
|
|
140
|
+
|
|
141
|
+
TESTS::
|
|
142
|
+
|
|
143
|
+
sage: p = Polyhedron(backend='ppl')
|
|
144
|
+
sage: from sage.geometry.polyhedron.backend_ppl import Polyhedron_ppl
|
|
145
|
+
sage: Polyhedron_ppl._init_from_Hrepresentation(p, [], []) # indirect doctest
|
|
146
|
+
"""
|
|
147
|
+
self._ppl_polyhedron = ppl_polyhedron
|
|
148
|
+
|
|
149
|
+
def set_immutable(self):
|
|
150
|
+
r"""
|
|
151
|
+
Make this polyhedron immutable. This operation cannot be undone.
|
|
152
|
+
|
|
153
|
+
EXAMPLES::
|
|
154
|
+
|
|
155
|
+
sage: p = Polyhedron([[1, 1]], mutable=True)
|
|
156
|
+
sage: p.is_mutable()
|
|
157
|
+
True
|
|
158
|
+
sage: hasattr(p, "_Vrepresentation")
|
|
159
|
+
False
|
|
160
|
+
sage: p.set_immutable()
|
|
161
|
+
sage: hasattr(p, "_Vrepresentation")
|
|
162
|
+
True
|
|
163
|
+
|
|
164
|
+
TESTS:
|
|
165
|
+
|
|
166
|
+
Check that :issue:`33666` is fixed::
|
|
167
|
+
|
|
168
|
+
sage: cube = polytopes.cube()
|
|
169
|
+
sage: parent = cube.parent()
|
|
170
|
+
sage: smaller_cube_ZZ = parent._element_constructor_(1/2 * cube, mutable=True)
|
|
171
|
+
sage: smaller_cube_ZZ.set_immutable()
|
|
172
|
+
Traceback (most recent call last):
|
|
173
|
+
...
|
|
174
|
+
TypeError: no conversion of this rational to integer
|
|
175
|
+
sage: smaller_cube_ZZ.is_immutable()
|
|
176
|
+
False
|
|
177
|
+
sage: smaller_cube_ZZ.set_immutable()
|
|
178
|
+
Traceback (most recent call last):
|
|
179
|
+
...
|
|
180
|
+
TypeError: no conversion of this rational to integer
|
|
181
|
+
sage: smaller_cube_ZZ.is_immutable()
|
|
182
|
+
False
|
|
183
|
+
sage: smaller_cube_QQ = smaller_cube_ZZ.base_extend(QQ)
|
|
184
|
+
sage: smaller_cube_QQ.set_immutable()
|
|
185
|
+
sage: smaller_cube_QQ.is_immutable()
|
|
186
|
+
True
|
|
187
|
+
"""
|
|
188
|
+
if not hasattr(self, '_Vrepresentation'):
|
|
189
|
+
try:
|
|
190
|
+
self._init_Vrepresentation_from_ppl(True)
|
|
191
|
+
except TypeError as e:
|
|
192
|
+
# Apparently the polyhedron is (no longer) integral.
|
|
193
|
+
self._clear_cache()
|
|
194
|
+
raise e
|
|
195
|
+
if not hasattr(self, '_Hrepresentation'):
|
|
196
|
+
self._init_Hrepresentation_from_ppl(True)
|
|
197
|
+
self._is_mutable = False
|
|
198
|
+
|
|
199
|
+
def Vrepresentation(self, index=None):
|
|
200
|
+
"""
|
|
201
|
+
Return the objects of the V-representation. Each entry is
|
|
202
|
+
either a vertex, a ray, or a line.
|
|
203
|
+
|
|
204
|
+
See :mod:`sage.geometry.polyhedron.constructor` for a
|
|
205
|
+
definition of vertex/ray/line.
|
|
206
|
+
|
|
207
|
+
INPUT:
|
|
208
|
+
|
|
209
|
+
- ``index`` -- either an integer or ``None``
|
|
210
|
+
|
|
211
|
+
OUTPUT:
|
|
212
|
+
|
|
213
|
+
The optional argument is an index running from ``0`` to
|
|
214
|
+
``self.n_Vrepresentation()-1``. If present, the
|
|
215
|
+
V-representation object at the given index will be
|
|
216
|
+
returned. Without an argument, returns the list of all
|
|
217
|
+
V-representation objects.
|
|
218
|
+
|
|
219
|
+
EXAMPLES::
|
|
220
|
+
|
|
221
|
+
sage: p = polytopes.cube()
|
|
222
|
+
sage: p.Vrepresentation(0)
|
|
223
|
+
A vertex at (1, -1, -1)
|
|
224
|
+
|
|
225
|
+
::
|
|
226
|
+
|
|
227
|
+
sage: P = p.parent()
|
|
228
|
+
sage: p = P._element_constructor_(p, mutable=True)
|
|
229
|
+
sage: p.Vrepresentation(0)
|
|
230
|
+
A vertex at (-1, -1, -1)
|
|
231
|
+
sage: p._clear_cache()
|
|
232
|
+
sage: p.Vrepresentation(0)
|
|
233
|
+
A vertex at (-1, -1, -1)
|
|
234
|
+
sage: TestSuite(p).run()
|
|
235
|
+
|
|
236
|
+
TESTS:
|
|
237
|
+
|
|
238
|
+
Check that :issue:`33666` is fixed::
|
|
239
|
+
|
|
240
|
+
sage: cube = polytopes.cube()
|
|
241
|
+
sage: parent = cube.parent()
|
|
242
|
+
sage: smaller_cube_ZZ = parent._element_constructor_(1/2 * cube, mutable=True)
|
|
243
|
+
sage: smaller_cube_ZZ.Hrepresentation()
|
|
244
|
+
(An inequality (0, 0, -2) x + 1 >= 0,
|
|
245
|
+
An inequality (0, -2, 0) x + 1 >= 0,
|
|
246
|
+
An inequality (-2, 0, 0) x + 1 >= 0,
|
|
247
|
+
An inequality (2, 0, 0) x + 1 >= 0,
|
|
248
|
+
An inequality (0, 0, 2) x + 1 >= 0,
|
|
249
|
+
An inequality (0, 2, 0) x + 1 >= 0)
|
|
250
|
+
sage: smaller_cube_ZZ.Vrepresentation()
|
|
251
|
+
Traceback (most recent call last):
|
|
252
|
+
...
|
|
253
|
+
TypeError: the polyhedron is not integral; do a base extension ``self.base_extend(QQ)``
|
|
254
|
+
sage: smaller_cube_ZZ.Vrepresentation()
|
|
255
|
+
Traceback (most recent call last):
|
|
256
|
+
...
|
|
257
|
+
TypeError: the polyhedron is not integral; do a base extension ``self.base_extend(QQ)``
|
|
258
|
+
sage: smaller_cube_QQ = smaller_cube_ZZ.base_extend(QQ)
|
|
259
|
+
sage: smaller_cube_QQ.Hrepresentation()
|
|
260
|
+
(An inequality (0, 0, -2) x + 1 >= 0,
|
|
261
|
+
An inequality (0, -2, 0) x + 1 >= 0,
|
|
262
|
+
An inequality (-2, 0, 0) x + 1 >= 0,
|
|
263
|
+
An inequality (2, 0, 0) x + 1 >= 0,
|
|
264
|
+
An inequality (0, 0, 2) x + 1 >= 0,
|
|
265
|
+
An inequality (0, 2, 0) x + 1 >= 0)
|
|
266
|
+
"""
|
|
267
|
+
if not hasattr(self, '_Vrepresentation'):
|
|
268
|
+
try:
|
|
269
|
+
self._init_Vrepresentation_from_ppl(True)
|
|
270
|
+
except TypeError:
|
|
271
|
+
# Apparently the polyhedron is (no longer) integral.
|
|
272
|
+
self._clear_cache()
|
|
273
|
+
raise TypeError("the polyhedron is not integral; do a base extension ``self.base_extend(QQ)``")
|
|
274
|
+
if index is None:
|
|
275
|
+
return self._Vrepresentation
|
|
276
|
+
else:
|
|
277
|
+
return self._Vrepresentation[index]
|
|
278
|
+
|
|
279
|
+
def _init_Vrepresentation_from_ppl(self, minimize):
|
|
280
|
+
"""
|
|
281
|
+
Create the Vrepresentation objects from the ppl polyhedron.
|
|
282
|
+
|
|
283
|
+
EXAMPLES::
|
|
284
|
+
|
|
285
|
+
sage: p = Polyhedron(vertices=[(0,1/2), (2,0), (4,5/6)], # indirect doctest
|
|
286
|
+
....: backend='ppl')
|
|
287
|
+
sage: p.Hrepresentation()
|
|
288
|
+
(An inequality (1, 4) x - 2 >= 0,
|
|
289
|
+
An inequality (1, -12) x + 6 >= 0,
|
|
290
|
+
An inequality (-5, 12) x + 10 >= 0)
|
|
291
|
+
sage: p._ppl_polyhedron.minimized_constraints()
|
|
292
|
+
Constraint_System {x0+4*x1-2>=0, x0-12*x1+6>=0, -5*x0+12*x1+10>=0}
|
|
293
|
+
sage: p.Vrepresentation()
|
|
294
|
+
(A vertex at (0, 1/2), A vertex at (2, 0), A vertex at (4, 5/6))
|
|
295
|
+
sage: p._ppl_polyhedron.minimized_generators()
|
|
296
|
+
Generator_System {point(0/2, 1/2), point(2/1, 0/1), point(24/6, 5/6)}
|
|
297
|
+
"""
|
|
298
|
+
if not self._is_mutable:
|
|
299
|
+
raise TypeError("Vrepresentation of mutable polyhedra cannot be recomputed")
|
|
300
|
+
self._Vrepresentation = []
|
|
301
|
+
gs = self._ppl_polyhedron.minimized_generators()
|
|
302
|
+
parent = self.parent()
|
|
303
|
+
for g in gs:
|
|
304
|
+
coefficients = [Integer(mpz) for mpz in g.coefficients()]
|
|
305
|
+
if g.is_point():
|
|
306
|
+
d = Integer(g.divisor())
|
|
307
|
+
if d.is_one():
|
|
308
|
+
parent._make_Vertex(self, coefficients)
|
|
309
|
+
else:
|
|
310
|
+
parent._make_Vertex(self, [x/d for x in coefficients])
|
|
311
|
+
elif g.is_ray():
|
|
312
|
+
parent._make_Ray(self, coefficients)
|
|
313
|
+
elif g.is_line():
|
|
314
|
+
parent._make_Line(self, coefficients)
|
|
315
|
+
else:
|
|
316
|
+
assert False
|
|
317
|
+
self._Vrepresentation = tuple(self._Vrepresentation)
|
|
318
|
+
|
|
319
|
+
def _init_Hrepresentation_from_ppl(self, minimize):
|
|
320
|
+
"""
|
|
321
|
+
Create the Hrepresentation objects from the ppl polyhedron.
|
|
322
|
+
|
|
323
|
+
EXAMPLES::
|
|
324
|
+
|
|
325
|
+
sage: p = Polyhedron(vertices=[(0,1/2), (2,0), (4,5/6)], # indirect doctest
|
|
326
|
+
....: backend='ppl')
|
|
327
|
+
sage: p.Hrepresentation()
|
|
328
|
+
(An inequality (1, 4) x - 2 >= 0,
|
|
329
|
+
An inequality (1, -12) x + 6 >= 0,
|
|
330
|
+
An inequality (-5, 12) x + 10 >= 0)
|
|
331
|
+
sage: p._ppl_polyhedron.minimized_constraints()
|
|
332
|
+
Constraint_System {x0+4*x1-2>=0, x0-12*x1+6>=0, -5*x0+12*x1+10>=0}
|
|
333
|
+
sage: p.Vrepresentation()
|
|
334
|
+
(A vertex at (0, 1/2), A vertex at (2, 0), A vertex at (4, 5/6))
|
|
335
|
+
sage: p._ppl_polyhedron.minimized_generators()
|
|
336
|
+
Generator_System {point(0/2, 1/2), point(2/1, 0/1), point(24/6, 5/6)}
|
|
337
|
+
"""
|
|
338
|
+
if not self._is_mutable:
|
|
339
|
+
raise TypeError("Hrepresentation of mutable polyhedra cannot be recomputed")
|
|
340
|
+
self._Hrepresentation = []
|
|
341
|
+
cs = self._ppl_polyhedron.minimized_constraints()
|
|
342
|
+
parent = self.parent()
|
|
343
|
+
for c in cs:
|
|
344
|
+
if c.is_inequality():
|
|
345
|
+
parent._make_Inequality(self, (c.inhomogeneous_term(),) + c.coefficients())
|
|
346
|
+
elif c.is_equality():
|
|
347
|
+
parent._make_Equation(self, (c.inhomogeneous_term(),) + c.coefficients())
|
|
348
|
+
self._Hrepresentation = tuple(self._Hrepresentation)
|
|
349
|
+
|
|
350
|
+
def Hrepresentation(self, index=None):
|
|
351
|
+
"""
|
|
352
|
+
Return the objects of the H-representation. Each entry is
|
|
353
|
+
either an inequality or a equation.
|
|
354
|
+
|
|
355
|
+
INPUT:
|
|
356
|
+
|
|
357
|
+
- ``index`` -- either an integer or ``None``
|
|
358
|
+
|
|
359
|
+
OUTPUT:
|
|
360
|
+
|
|
361
|
+
The optional argument is an index running from ``0`` to
|
|
362
|
+
``self.n_Hrepresentation()-1``. If present, the
|
|
363
|
+
H-representation object at the given index will be
|
|
364
|
+
returned. Without an argument, returns the list of all
|
|
365
|
+
H-representation objects.
|
|
366
|
+
|
|
367
|
+
EXAMPLES::
|
|
368
|
+
|
|
369
|
+
sage: p = polytopes.hypercube(3)
|
|
370
|
+
sage: p.Hrepresentation(0)
|
|
371
|
+
An inequality (-1, 0, 0) x + 1 >= 0
|
|
372
|
+
sage: p.Hrepresentation(0) == p.Hrepresentation()[0]
|
|
373
|
+
True
|
|
374
|
+
|
|
375
|
+
::
|
|
376
|
+
|
|
377
|
+
sage: P = p.parent()
|
|
378
|
+
sage: p = P._element_constructor_(p, mutable=True)
|
|
379
|
+
sage: p.Hrepresentation(0)
|
|
380
|
+
An inequality (0, 0, -1) x + 1 >= 0
|
|
381
|
+
sage: p._clear_cache()
|
|
382
|
+
sage: p.Hrepresentation(0)
|
|
383
|
+
An inequality (0, 0, -1) x + 1 >= 0
|
|
384
|
+
sage: TestSuite(p).run()
|
|
385
|
+
"""
|
|
386
|
+
if not hasattr(self, '_Hrepresentation'):
|
|
387
|
+
self._init_Hrepresentation_from_ppl(True)
|
|
388
|
+
if index is None:
|
|
389
|
+
return self._Hrepresentation
|
|
390
|
+
else:
|
|
391
|
+
return self._Hrepresentation[index]
|
|
392
|
+
|
|
393
|
+
def _init_empty_polyhedron(self):
|
|
394
|
+
"""
|
|
395
|
+
Initialize an empty polyhedron.
|
|
396
|
+
|
|
397
|
+
TESTS::
|
|
398
|
+
|
|
399
|
+
sage: empty = Polyhedron(backend='ppl'); empty
|
|
400
|
+
The empty polyhedron in ZZ^0
|
|
401
|
+
sage: empty.Vrepresentation()
|
|
402
|
+
()
|
|
403
|
+
sage: empty.Hrepresentation()
|
|
404
|
+
(An equation -1 == 0,)
|
|
405
|
+
sage: Polyhedron(vertices = [], backend='ppl')
|
|
406
|
+
The empty polyhedron in ZZ^0
|
|
407
|
+
sage: Polyhedron(backend='ppl')._init_empty_polyhedron()
|
|
408
|
+
"""
|
|
409
|
+
super()._init_empty_polyhedron()
|
|
410
|
+
self._ppl_polyhedron = C_Polyhedron(self.ambient_dim(), 'empty')
|
|
411
|
+
|
|
412
|
+
@staticmethod
|
|
413
|
+
def _convert_generator_to_ppl(v, typ):
|
|
414
|
+
r"""
|
|
415
|
+
Convert a generator to ``ppl``.
|
|
416
|
+
|
|
417
|
+
INPUT:
|
|
418
|
+
|
|
419
|
+
- ``v`` -- a vertex, ray, or line
|
|
420
|
+
|
|
421
|
+
- ``typ`` -- integer according to
|
|
422
|
+
`:sage:`~sage.geometry.polyhedron.representation.LINE` etc.
|
|
423
|
+
|
|
424
|
+
EXAMPLES::
|
|
425
|
+
|
|
426
|
+
sage: from sage.geometry.polyhedron.representation import VERTEX, RAY, LINE
|
|
427
|
+
sage: P = Polyhedron()
|
|
428
|
+
sage: P._convert_generator_to_ppl([1, 1/2, 3], VERTEX)
|
|
429
|
+
point(2/2, 1/2, 6/2)
|
|
430
|
+
sage: P._convert_generator_to_ppl([1, 1/2, 3], RAY)
|
|
431
|
+
ray(2, 1, 6)
|
|
432
|
+
sage: P._convert_generator_to_ppl([1, 1/2, 3], LINE)
|
|
433
|
+
line(2, 1, 6)
|
|
434
|
+
"""
|
|
435
|
+
if typ == VERTEX:
|
|
436
|
+
ob = point
|
|
437
|
+
elif typ == RAY:
|
|
438
|
+
ob = ray
|
|
439
|
+
else:
|
|
440
|
+
ob = line
|
|
441
|
+
|
|
442
|
+
d = LCM_list([denominator(v_i) for v_i in v])
|
|
443
|
+
if d.is_one():
|
|
444
|
+
return ob(Linear_Expression(v, 0))
|
|
445
|
+
else:
|
|
446
|
+
dv = [ d*v_i for v_i in v ]
|
|
447
|
+
if typ == VERTEX:
|
|
448
|
+
return ob(Linear_Expression(dv, 0), d)
|
|
449
|
+
else:
|
|
450
|
+
return ob(Linear_Expression(dv, 0))
|
|
451
|
+
|
|
452
|
+
@staticmethod
|
|
453
|
+
def _convert_generators_to_ppl(vertices, rays, lines):
|
|
454
|
+
r"""
|
|
455
|
+
Convert generators to a ``ppl`` generator system.
|
|
456
|
+
|
|
457
|
+
INPUT:
|
|
458
|
+
|
|
459
|
+
- ``vertices`` -- iterable of vertices or ``None``
|
|
460
|
+
|
|
461
|
+
- ``rays`` -- iterable of rays or ``None``
|
|
462
|
+
|
|
463
|
+
- ``lines`` -- iterable of lines or ``None``
|
|
464
|
+
|
|
465
|
+
EXAMPLES::
|
|
466
|
+
|
|
467
|
+
sage: P = Polyhedron()
|
|
468
|
+
sage: P._convert_generators_to_ppl([[1, 1/2, 3]], [[0, 1, 3/2]], [[0, 0, 1]])
|
|
469
|
+
Generator_System {point(2/2, 1/2, 6/2), ray(0, 2, 3), line(0, 0, 1)}
|
|
470
|
+
"""
|
|
471
|
+
gs = Generator_System()
|
|
472
|
+
if vertices is None:
|
|
473
|
+
vertices = []
|
|
474
|
+
for v in vertices:
|
|
475
|
+
gs.insert(Polyhedron_ppl._convert_generator_to_ppl(v, VERTEX))
|
|
476
|
+
if rays is None:
|
|
477
|
+
rays = []
|
|
478
|
+
for r in rays:
|
|
479
|
+
gs.insert(Polyhedron_ppl._convert_generator_to_ppl(r, RAY))
|
|
480
|
+
if lines is None:
|
|
481
|
+
lines = []
|
|
482
|
+
for l in lines:
|
|
483
|
+
gs.insert(Polyhedron_ppl._convert_generator_to_ppl(l, LINE))
|
|
484
|
+
return gs
|
|
485
|
+
|
|
486
|
+
@staticmethod
|
|
487
|
+
def _convert_constraint_to_ppl(c, typ):
|
|
488
|
+
r"""
|
|
489
|
+
Convert a constraint to ``ppl``.
|
|
490
|
+
|
|
491
|
+
INPUT:
|
|
492
|
+
|
|
493
|
+
- ``c`` -- an inequality or equation
|
|
494
|
+
|
|
495
|
+
- ``typ`` -- integer according to
|
|
496
|
+
`:sage:`~sage.geometry.polyhedron.representation.INEQUALITY` etc.
|
|
497
|
+
|
|
498
|
+
EXAMPLES::
|
|
499
|
+
|
|
500
|
+
sage: from sage.geometry.polyhedron.representation import INEQUALITY, EQUATION
|
|
501
|
+
sage: P = Polyhedron()
|
|
502
|
+
sage: P._convert_constraint_to_ppl([1, 1/2, 3], INEQUALITY)
|
|
503
|
+
x0+6*x1+2>=0
|
|
504
|
+
sage: P._convert_constraint_to_ppl([1, 1/2, 3], EQUATION)
|
|
505
|
+
x0+6*x1+2==0
|
|
506
|
+
"""
|
|
507
|
+
d = LCM_list([denominator(c_i) for c_i in c])
|
|
508
|
+
dc = [ ZZ(d*c_i) for c_i in c ]
|
|
509
|
+
b = dc[0]
|
|
510
|
+
A = dc[1:]
|
|
511
|
+
if typ == INEQUALITY:
|
|
512
|
+
return Linear_Expression(A, b) >= 0
|
|
513
|
+
else:
|
|
514
|
+
return Linear_Expression(A, b) == 0
|
|
515
|
+
|
|
516
|
+
@staticmethod
|
|
517
|
+
def _convert_constraints_to_ppl(ieqs, eqns):
|
|
518
|
+
r"""
|
|
519
|
+
Convert constraints to a ``ppl`` constraint system.
|
|
520
|
+
|
|
521
|
+
INPUT:
|
|
522
|
+
|
|
523
|
+
- ``ieqs`` -- iterable of inequalities or ``None``
|
|
524
|
+
|
|
525
|
+
- ``eqns`` -- iterable of equations or ``None``
|
|
526
|
+
|
|
527
|
+
EXAMPLES::
|
|
528
|
+
|
|
529
|
+
sage: P = Polyhedron()
|
|
530
|
+
sage: P._convert_constraints_to_ppl([[1, 1/2, 3]], None)
|
|
531
|
+
Constraint_System {x0+6*x1+2>=0}
|
|
532
|
+
"""
|
|
533
|
+
cs = Constraint_System()
|
|
534
|
+
if ieqs is None:
|
|
535
|
+
ieqs = []
|
|
536
|
+
for ieq in ieqs:
|
|
537
|
+
cs.insert(Polyhedron_ppl._convert_constraint_to_ppl(ieq, INEQUALITY))
|
|
538
|
+
if eqns is None:
|
|
539
|
+
eqns = []
|
|
540
|
+
for eqn in eqns:
|
|
541
|
+
cs.insert(Polyhedron_ppl._convert_constraint_to_ppl(eqn, EQUATION))
|
|
542
|
+
return cs
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
#########################################################################
|
|
546
|
+
class Polyhedron_QQ_ppl(Polyhedron_ppl, Polyhedron_QQ):
|
|
547
|
+
r"""
|
|
548
|
+
Polyhedra over `\QQ` with ppl.
|
|
549
|
+
|
|
550
|
+
INPUT:
|
|
551
|
+
|
|
552
|
+
- ``Vrep`` -- list ``[vertices, rays, lines]`` or ``None``
|
|
553
|
+
|
|
554
|
+
- ``Hrep`` -- list ``[ieqs, eqns]`` or ``None``
|
|
555
|
+
|
|
556
|
+
EXAMPLES::
|
|
557
|
+
|
|
558
|
+
sage: p = Polyhedron(vertices=[(0,0),(1,0),(0,1)], rays=[(1,1)], lines=[],
|
|
559
|
+
....: backend='ppl', base_ring=QQ)
|
|
560
|
+
sage: TestSuite(p).run()
|
|
561
|
+
"""
|
|
562
|
+
pass
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
#########################################################################
|
|
566
|
+
class Polyhedron_ZZ_ppl(Polyhedron_ppl, Polyhedron_ZZ):
|
|
567
|
+
r"""
|
|
568
|
+
Polyhedra over `\ZZ` with ppl.
|
|
569
|
+
|
|
570
|
+
INPUT:
|
|
571
|
+
|
|
572
|
+
- ``Vrep`` -- list ``[vertices, rays, lines]`` or ``None``
|
|
573
|
+
|
|
574
|
+
- ``Hrep`` -- list ``[ieqs, eqns]`` or ``None``
|
|
575
|
+
|
|
576
|
+
EXAMPLES::
|
|
577
|
+
|
|
578
|
+
sage: p = Polyhedron(vertices=[(0,0),(1,0),(0,1)], rays=[(1,1)], lines=[],
|
|
579
|
+
....: backend='ppl', base_ring=ZZ)
|
|
580
|
+
sage: TestSuite(p).run()
|
|
581
|
+
"""
|
|
582
|
+
pass
|