passagemath-polyhedra 10.6.31rc3__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.

Potentially problematic release.


This version of passagemath-polyhedra might be problematic. Click here for more details.

Files changed (208) hide show
  1. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA +367 -0
  2. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA.bak +369 -0
  3. passagemath_polyhedra-10.6.31rc3.dist-info/RECORD +208 -0
  4. passagemath_polyhedra-10.6.31rc3.dist-info/WHEEL +5 -0
  5. passagemath_polyhedra-10.6.31rc3.dist-info/top_level.txt +2 -0
  6. passagemath_polyhedra.libs/libgcc_s-0cd532bd.so.1 +0 -0
  7. passagemath_polyhedra.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
  8. passagemath_polyhedra.libs/libgomp-8949ffbe.so.1.0.0 +0 -0
  9. passagemath_polyhedra.libs/libstdc++-5d72f927.so.6.0.33 +0 -0
  10. sage/all__sagemath_polyhedra.py +50 -0
  11. sage/game_theory/all.py +8 -0
  12. sage/game_theory/catalog.py +6 -0
  13. sage/game_theory/catalog_normal_form_games.py +923 -0
  14. sage/game_theory/cooperative_game.py +844 -0
  15. sage/game_theory/matching_game.py +1181 -0
  16. sage/game_theory/normal_form_game.py +2697 -0
  17. sage/game_theory/parser.py +275 -0
  18. sage/geometry/all__sagemath_polyhedra.py +22 -0
  19. sage/geometry/cone.py +6940 -0
  20. sage/geometry/cone_catalog.py +847 -0
  21. sage/geometry/cone_critical_angles.py +1027 -0
  22. sage/geometry/convex_set.py +1119 -0
  23. sage/geometry/fan.py +3743 -0
  24. sage/geometry/fan_isomorphism.py +389 -0
  25. sage/geometry/fan_morphism.py +1884 -0
  26. sage/geometry/hasse_diagram.py +202 -0
  27. sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
  28. sage/geometry/hyperplane_arrangement/all.py +1 -0
  29. sage/geometry/hyperplane_arrangement/arrangement.py +3895 -0
  30. sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
  31. sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
  32. sage/geometry/hyperplane_arrangement/library.py +825 -0
  33. sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
  34. sage/geometry/hyperplane_arrangement/plot.py +520 -0
  35. sage/geometry/integral_points.py +35 -0
  36. sage/geometry/integral_points_generic_dense.cpython-314-x86_64-linux-musl.so +0 -0
  37. sage/geometry/integral_points_generic_dense.pyx +7 -0
  38. sage/geometry/lattice_polytope.py +5894 -0
  39. sage/geometry/linear_expression.py +773 -0
  40. sage/geometry/newton_polygon.py +767 -0
  41. sage/geometry/point_collection.cpython-314-x86_64-linux-musl.so +0 -0
  42. sage/geometry/point_collection.pyx +1008 -0
  43. sage/geometry/polyhedral_complex.py +2616 -0
  44. sage/geometry/polyhedron/all.py +8 -0
  45. sage/geometry/polyhedron/backend_cdd.py +460 -0
  46. sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
  47. sage/geometry/polyhedron/backend_field.py +347 -0
  48. sage/geometry/polyhedron/backend_normaliz.py +2503 -0
  49. sage/geometry/polyhedron/backend_number_field.py +168 -0
  50. sage/geometry/polyhedron/backend_polymake.py +765 -0
  51. sage/geometry/polyhedron/backend_ppl.py +582 -0
  52. sage/geometry/polyhedron/base.py +1206 -0
  53. sage/geometry/polyhedron/base0.py +1444 -0
  54. sage/geometry/polyhedron/base1.py +886 -0
  55. sage/geometry/polyhedron/base2.py +812 -0
  56. sage/geometry/polyhedron/base3.py +1845 -0
  57. sage/geometry/polyhedron/base4.py +1262 -0
  58. sage/geometry/polyhedron/base5.py +2700 -0
  59. sage/geometry/polyhedron/base6.py +1741 -0
  60. sage/geometry/polyhedron/base7.py +997 -0
  61. sage/geometry/polyhedron/base_QQ.py +1258 -0
  62. sage/geometry/polyhedron/base_RDF.py +98 -0
  63. sage/geometry/polyhedron/base_ZZ.py +934 -0
  64. sage/geometry/polyhedron/base_mutable.py +215 -0
  65. sage/geometry/polyhedron/base_number_field.py +122 -0
  66. sage/geometry/polyhedron/cdd_file_format.py +155 -0
  67. sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
  68. sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-x86_64-linux-musl.so +0 -0
  69. sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
  70. sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
  71. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-x86_64-linux-musl.so +0 -0
  72. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
  73. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
  74. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-x86_64-linux-musl.so +0 -0
  75. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
  76. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
  77. sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
  78. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-x86_64-linux-musl.so +0 -0
  79. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
  80. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
  81. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-x86_64-linux-musl.so +0 -0
  82. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
  83. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
  84. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-x86_64-linux-musl.so +0 -0
  85. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
  86. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
  87. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-x86_64-linux-musl.so +0 -0
  88. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
  89. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
  90. sage/geometry/polyhedron/constructor.py +773 -0
  91. sage/geometry/polyhedron/double_description.py +753 -0
  92. sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
  93. sage/geometry/polyhedron/face.py +1060 -0
  94. sage/geometry/polyhedron/generating_function.py +1810 -0
  95. sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
  96. sage/geometry/polyhedron/library.py +3502 -0
  97. sage/geometry/polyhedron/misc.py +121 -0
  98. sage/geometry/polyhedron/modules/all.py +1 -0
  99. sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
  100. sage/geometry/polyhedron/palp_database.py +447 -0
  101. sage/geometry/polyhedron/parent.py +1279 -0
  102. sage/geometry/polyhedron/plot.py +1986 -0
  103. sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
  104. sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
  105. sage/geometry/polyhedron/representation.py +1723 -0
  106. sage/geometry/pseudolines.py +515 -0
  107. sage/geometry/relative_interior.py +445 -0
  108. sage/geometry/toric_plotter.py +1103 -0
  109. sage/geometry/triangulation/all.py +2 -0
  110. sage/geometry/triangulation/base.cpython-314-x86_64-linux-musl.so +0 -0
  111. sage/geometry/triangulation/base.pyx +963 -0
  112. sage/geometry/triangulation/data.h +147 -0
  113. sage/geometry/triangulation/data.pxd +4 -0
  114. sage/geometry/triangulation/element.py +914 -0
  115. sage/geometry/triangulation/functions.h +10 -0
  116. sage/geometry/triangulation/functions.pxd +4 -0
  117. sage/geometry/triangulation/point_configuration.py +2256 -0
  118. sage/geometry/triangulation/triangulations.h +49 -0
  119. sage/geometry/triangulation/triangulations.pxd +7 -0
  120. sage/geometry/voronoi_diagram.py +319 -0
  121. sage/interfaces/all__sagemath_polyhedra.py +1 -0
  122. sage/interfaces/polymake.py +2028 -0
  123. sage/numerical/all.py +13 -0
  124. sage/numerical/all__sagemath_polyhedra.py +11 -0
  125. sage/numerical/backends/all.py +1 -0
  126. sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
  127. sage/numerical/backends/cvxopt_backend.cpython-314-x86_64-linux-musl.so +0 -0
  128. sage/numerical/backends/cvxopt_backend.pyx +1006 -0
  129. sage/numerical/backends/cvxopt_backend_test.py +19 -0
  130. sage/numerical/backends/cvxopt_sdp_backend.cpython-314-x86_64-linux-musl.so +0 -0
  131. sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
  132. sage/numerical/backends/cvxpy_backend.cpython-314-x86_64-linux-musl.so +0 -0
  133. sage/numerical/backends/cvxpy_backend.pxd +41 -0
  134. sage/numerical/backends/cvxpy_backend.pyx +934 -0
  135. sage/numerical/backends/cvxpy_backend_test.py +13 -0
  136. sage/numerical/backends/generic_backend_test.py +24 -0
  137. sage/numerical/backends/interactivelp_backend.cpython-314-x86_64-linux-musl.so +0 -0
  138. sage/numerical/backends/interactivelp_backend.pxd +36 -0
  139. sage/numerical/backends/interactivelp_backend.pyx +1231 -0
  140. sage/numerical/backends/interactivelp_backend_test.py +12 -0
  141. sage/numerical/backends/logging_backend.py +391 -0
  142. sage/numerical/backends/matrix_sdp_backend.cpython-314-x86_64-linux-musl.so +0 -0
  143. sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
  144. sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
  145. sage/numerical/backends/ppl_backend.cpython-314-x86_64-linux-musl.so +0 -0
  146. sage/numerical/backends/ppl_backend.pyx +1126 -0
  147. sage/numerical/backends/ppl_backend_test.py +13 -0
  148. sage/numerical/backends/scip_backend.cpython-314-x86_64-linux-musl.so +0 -0
  149. sage/numerical/backends/scip_backend.pxd +22 -0
  150. sage/numerical/backends/scip_backend.pyx +1289 -0
  151. sage/numerical/backends/scip_backend_test.py +13 -0
  152. sage/numerical/interactive_simplex_method.py +5338 -0
  153. sage/numerical/knapsack.py +665 -0
  154. sage/numerical/linear_functions.cpython-314-x86_64-linux-musl.so +0 -0
  155. sage/numerical/linear_functions.pxd +31 -0
  156. sage/numerical/linear_functions.pyx +1648 -0
  157. sage/numerical/linear_tensor.py +470 -0
  158. sage/numerical/linear_tensor_constraints.py +448 -0
  159. sage/numerical/linear_tensor_element.cpython-314-x86_64-linux-musl.so +0 -0
  160. sage/numerical/linear_tensor_element.pxd +6 -0
  161. sage/numerical/linear_tensor_element.pyx +459 -0
  162. sage/numerical/mip.cpython-314-x86_64-linux-musl.so +0 -0
  163. sage/numerical/mip.pxd +40 -0
  164. sage/numerical/mip.pyx +3667 -0
  165. sage/numerical/sdp.cpython-314-x86_64-linux-musl.so +0 -0
  166. sage/numerical/sdp.pxd +39 -0
  167. sage/numerical/sdp.pyx +1433 -0
  168. sage/rings/all__sagemath_polyhedra.py +3 -0
  169. sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
  170. sage/rings/polynomial/omega.py +982 -0
  171. sage/schemes/all__sagemath_polyhedra.py +2 -0
  172. sage/schemes/toric/all.py +10 -0
  173. sage/schemes/toric/chow_group.py +1248 -0
  174. sage/schemes/toric/divisor.py +2082 -0
  175. sage/schemes/toric/divisor_class.cpython-314-x86_64-linux-musl.so +0 -0
  176. sage/schemes/toric/divisor_class.pyx +322 -0
  177. sage/schemes/toric/fano_variety.py +1606 -0
  178. sage/schemes/toric/homset.py +650 -0
  179. sage/schemes/toric/ideal.py +451 -0
  180. sage/schemes/toric/library.py +1322 -0
  181. sage/schemes/toric/morphism.py +1958 -0
  182. sage/schemes/toric/points.py +1032 -0
  183. sage/schemes/toric/sheaf/all.py +1 -0
  184. sage/schemes/toric/sheaf/constructor.py +302 -0
  185. sage/schemes/toric/sheaf/klyachko.py +921 -0
  186. sage/schemes/toric/toric_subscheme.py +905 -0
  187. sage/schemes/toric/variety.py +3460 -0
  188. sage/schemes/toric/weierstrass.py +1078 -0
  189. sage/schemes/toric/weierstrass_covering.py +457 -0
  190. sage/schemes/toric/weierstrass_higher.py +288 -0
  191. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
  192. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
  193. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
  194. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
  195. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
  196. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
  197. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
  198. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
  199. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
  200. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
  201. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
  202. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
  203. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
  204. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
  205. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
  206. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
  207. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
  208. 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