passagemath-polyhedra 10.6.31rc3__cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_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 (206) 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 +206 -0
  4. passagemath_polyhedra-10.6.31rc3.dist-info/WHEEL +6 -0
  5. passagemath_polyhedra-10.6.31rc3.dist-info/top_level.txt +2 -0
  6. passagemath_polyhedra.libs/libgmp-6e109695.so.10.5.0 +0 -0
  7. passagemath_polyhedra.libs/libgomp-e985bcbb.so.1.0.0 +0 -0
  8. sage/all__sagemath_polyhedra.py +50 -0
  9. sage/game_theory/all.py +8 -0
  10. sage/game_theory/catalog.py +6 -0
  11. sage/game_theory/catalog_normal_form_games.py +923 -0
  12. sage/game_theory/cooperative_game.py +844 -0
  13. sage/game_theory/matching_game.py +1181 -0
  14. sage/game_theory/normal_form_game.py +2697 -0
  15. sage/game_theory/parser.py +275 -0
  16. sage/geometry/all__sagemath_polyhedra.py +22 -0
  17. sage/geometry/cone.py +6940 -0
  18. sage/geometry/cone_catalog.py +847 -0
  19. sage/geometry/cone_critical_angles.py +1027 -0
  20. sage/geometry/convex_set.py +1119 -0
  21. sage/geometry/fan.py +3743 -0
  22. sage/geometry/fan_isomorphism.py +389 -0
  23. sage/geometry/fan_morphism.py +1884 -0
  24. sage/geometry/hasse_diagram.py +202 -0
  25. sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
  26. sage/geometry/hyperplane_arrangement/all.py +1 -0
  27. sage/geometry/hyperplane_arrangement/arrangement.py +3895 -0
  28. sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
  29. sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
  30. sage/geometry/hyperplane_arrangement/library.py +825 -0
  31. sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
  32. sage/geometry/hyperplane_arrangement/plot.py +520 -0
  33. sage/geometry/integral_points.py +35 -0
  34. sage/geometry/integral_points_generic_dense.cpython-314-x86_64-linux-gnu.so +0 -0
  35. sage/geometry/integral_points_generic_dense.pyx +7 -0
  36. sage/geometry/lattice_polytope.py +5894 -0
  37. sage/geometry/linear_expression.py +773 -0
  38. sage/geometry/newton_polygon.py +767 -0
  39. sage/geometry/point_collection.cpython-314-x86_64-linux-gnu.so +0 -0
  40. sage/geometry/point_collection.pyx +1008 -0
  41. sage/geometry/polyhedral_complex.py +2616 -0
  42. sage/geometry/polyhedron/all.py +8 -0
  43. sage/geometry/polyhedron/backend_cdd.py +460 -0
  44. sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
  45. sage/geometry/polyhedron/backend_field.py +347 -0
  46. sage/geometry/polyhedron/backend_normaliz.py +2503 -0
  47. sage/geometry/polyhedron/backend_number_field.py +168 -0
  48. sage/geometry/polyhedron/backend_polymake.py +765 -0
  49. sage/geometry/polyhedron/backend_ppl.py +582 -0
  50. sage/geometry/polyhedron/base.py +1206 -0
  51. sage/geometry/polyhedron/base0.py +1444 -0
  52. sage/geometry/polyhedron/base1.py +886 -0
  53. sage/geometry/polyhedron/base2.py +812 -0
  54. sage/geometry/polyhedron/base3.py +1845 -0
  55. sage/geometry/polyhedron/base4.py +1262 -0
  56. sage/geometry/polyhedron/base5.py +2700 -0
  57. sage/geometry/polyhedron/base6.py +1741 -0
  58. sage/geometry/polyhedron/base7.py +997 -0
  59. sage/geometry/polyhedron/base_QQ.py +1258 -0
  60. sage/geometry/polyhedron/base_RDF.py +98 -0
  61. sage/geometry/polyhedron/base_ZZ.py +934 -0
  62. sage/geometry/polyhedron/base_mutable.py +215 -0
  63. sage/geometry/polyhedron/base_number_field.py +122 -0
  64. sage/geometry/polyhedron/cdd_file_format.py +155 -0
  65. sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
  66. sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-x86_64-linux-gnu.so +0 -0
  67. sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
  68. sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
  69. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-x86_64-linux-gnu.so +0 -0
  70. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
  71. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
  72. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-x86_64-linux-gnu.so +0 -0
  73. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
  74. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
  75. sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
  76. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-x86_64-linux-gnu.so +0 -0
  77. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
  78. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
  79. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-x86_64-linux-gnu.so +0 -0
  80. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
  81. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
  82. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-x86_64-linux-gnu.so +0 -0
  83. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
  84. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
  85. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-x86_64-linux-gnu.so +0 -0
  86. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
  87. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
  88. sage/geometry/polyhedron/constructor.py +773 -0
  89. sage/geometry/polyhedron/double_description.py +753 -0
  90. sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
  91. sage/geometry/polyhedron/face.py +1060 -0
  92. sage/geometry/polyhedron/generating_function.py +1810 -0
  93. sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
  94. sage/geometry/polyhedron/library.py +3502 -0
  95. sage/geometry/polyhedron/misc.py +121 -0
  96. sage/geometry/polyhedron/modules/all.py +1 -0
  97. sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
  98. sage/geometry/polyhedron/palp_database.py +447 -0
  99. sage/geometry/polyhedron/parent.py +1279 -0
  100. sage/geometry/polyhedron/plot.py +1986 -0
  101. sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
  102. sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
  103. sage/geometry/polyhedron/representation.py +1723 -0
  104. sage/geometry/pseudolines.py +515 -0
  105. sage/geometry/relative_interior.py +445 -0
  106. sage/geometry/toric_plotter.py +1103 -0
  107. sage/geometry/triangulation/all.py +2 -0
  108. sage/geometry/triangulation/base.cpython-314-x86_64-linux-gnu.so +0 -0
  109. sage/geometry/triangulation/base.pyx +963 -0
  110. sage/geometry/triangulation/data.h +147 -0
  111. sage/geometry/triangulation/data.pxd +4 -0
  112. sage/geometry/triangulation/element.py +914 -0
  113. sage/geometry/triangulation/functions.h +10 -0
  114. sage/geometry/triangulation/functions.pxd +4 -0
  115. sage/geometry/triangulation/point_configuration.py +2256 -0
  116. sage/geometry/triangulation/triangulations.h +49 -0
  117. sage/geometry/triangulation/triangulations.pxd +7 -0
  118. sage/geometry/voronoi_diagram.py +319 -0
  119. sage/interfaces/all__sagemath_polyhedra.py +1 -0
  120. sage/interfaces/polymake.py +2028 -0
  121. sage/numerical/all.py +13 -0
  122. sage/numerical/all__sagemath_polyhedra.py +11 -0
  123. sage/numerical/backends/all.py +1 -0
  124. sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
  125. sage/numerical/backends/cvxopt_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  126. sage/numerical/backends/cvxopt_backend.pyx +1006 -0
  127. sage/numerical/backends/cvxopt_backend_test.py +19 -0
  128. sage/numerical/backends/cvxopt_sdp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  129. sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
  130. sage/numerical/backends/cvxpy_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  131. sage/numerical/backends/cvxpy_backend.pxd +41 -0
  132. sage/numerical/backends/cvxpy_backend.pyx +934 -0
  133. sage/numerical/backends/cvxpy_backend_test.py +13 -0
  134. sage/numerical/backends/generic_backend_test.py +24 -0
  135. sage/numerical/backends/interactivelp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  136. sage/numerical/backends/interactivelp_backend.pxd +36 -0
  137. sage/numerical/backends/interactivelp_backend.pyx +1231 -0
  138. sage/numerical/backends/interactivelp_backend_test.py +12 -0
  139. sage/numerical/backends/logging_backend.py +391 -0
  140. sage/numerical/backends/matrix_sdp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  141. sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
  142. sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
  143. sage/numerical/backends/ppl_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  144. sage/numerical/backends/ppl_backend.pyx +1126 -0
  145. sage/numerical/backends/ppl_backend_test.py +13 -0
  146. sage/numerical/backends/scip_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  147. sage/numerical/backends/scip_backend.pxd +22 -0
  148. sage/numerical/backends/scip_backend.pyx +1289 -0
  149. sage/numerical/backends/scip_backend_test.py +13 -0
  150. sage/numerical/interactive_simplex_method.py +5338 -0
  151. sage/numerical/knapsack.py +665 -0
  152. sage/numerical/linear_functions.cpython-314-x86_64-linux-gnu.so +0 -0
  153. sage/numerical/linear_functions.pxd +31 -0
  154. sage/numerical/linear_functions.pyx +1648 -0
  155. sage/numerical/linear_tensor.py +470 -0
  156. sage/numerical/linear_tensor_constraints.py +448 -0
  157. sage/numerical/linear_tensor_element.cpython-314-x86_64-linux-gnu.so +0 -0
  158. sage/numerical/linear_tensor_element.pxd +6 -0
  159. sage/numerical/linear_tensor_element.pyx +459 -0
  160. sage/numerical/mip.cpython-314-x86_64-linux-gnu.so +0 -0
  161. sage/numerical/mip.pxd +40 -0
  162. sage/numerical/mip.pyx +3667 -0
  163. sage/numerical/sdp.cpython-314-x86_64-linux-gnu.so +0 -0
  164. sage/numerical/sdp.pxd +39 -0
  165. sage/numerical/sdp.pyx +1433 -0
  166. sage/rings/all__sagemath_polyhedra.py +3 -0
  167. sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
  168. sage/rings/polynomial/omega.py +982 -0
  169. sage/schemes/all__sagemath_polyhedra.py +2 -0
  170. sage/schemes/toric/all.py +10 -0
  171. sage/schemes/toric/chow_group.py +1248 -0
  172. sage/schemes/toric/divisor.py +2082 -0
  173. sage/schemes/toric/divisor_class.cpython-314-x86_64-linux-gnu.so +0 -0
  174. sage/schemes/toric/divisor_class.pyx +322 -0
  175. sage/schemes/toric/fano_variety.py +1606 -0
  176. sage/schemes/toric/homset.py +650 -0
  177. sage/schemes/toric/ideal.py +451 -0
  178. sage/schemes/toric/library.py +1322 -0
  179. sage/schemes/toric/morphism.py +1958 -0
  180. sage/schemes/toric/points.py +1032 -0
  181. sage/schemes/toric/sheaf/all.py +1 -0
  182. sage/schemes/toric/sheaf/constructor.py +302 -0
  183. sage/schemes/toric/sheaf/klyachko.py +921 -0
  184. sage/schemes/toric/toric_subscheme.py +905 -0
  185. sage/schemes/toric/variety.py +3460 -0
  186. sage/schemes/toric/weierstrass.py +1078 -0
  187. sage/schemes/toric/weierstrass_covering.py +457 -0
  188. sage/schemes/toric/weierstrass_higher.py +288 -0
  189. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
  190. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
  191. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
  192. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
  193. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
  194. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
  195. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
  196. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
  197. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
  198. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
  199. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
  200. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
  201. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
  202. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
  203. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
  204. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
  205. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
  206. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_3d +37977 -0
@@ -0,0 +1,215 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ r"""
3
+ Base class for mutable polyhedra.
4
+
5
+ Just like vectors and matrices they can be set immutable.
6
+ The constructor does this by default.
7
+ """
8
+
9
+ from sage.misc.abstract_method import abstract_method
10
+
11
+ from .base import Polyhedron_base
12
+
13
+
14
+ class Polyhedron_mutable(Polyhedron_base):
15
+ """
16
+ Base class for polyhedra that allow mutability.
17
+
18
+ This should not be used directly.
19
+ """
20
+
21
+ def __hash__(self):
22
+ r"""
23
+ TESTS::
24
+
25
+ sage: p = Polyhedron([[1, 1]], mutable=True)
26
+ sage: set([p])
27
+ Traceback (most recent call last):
28
+ ...
29
+ TypeError: ...mutable polyhedra are unhashable...
30
+ sage: p.set_immutable()
31
+ sage: set([p])
32
+ {A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex}
33
+ """
34
+ if self._is_mutable:
35
+ raise TypeError("mutable polyhedra are unhashable")
36
+ return Polyhedron_base.__hash__(self)
37
+
38
+ def _clear_cache(self):
39
+ r"""
40
+ Clear the Vrepresentation and Hrepresentation data of ``self``.
41
+
42
+ TESTS::
43
+
44
+ sage: p = polytopes.permutahedron(4)
45
+ sage: P = p.parent()
46
+ sage: q = P._element_constructor_(p, mutable=True)
47
+ sage: TestSuite(q).run() # needs sage.libs.pari
48
+ sage: q._clear_cache()
49
+ sage: TestSuite(q).run() # needs sage.libs.pari
50
+
51
+ ::
52
+
53
+ sage: q.set_immutable()
54
+ sage: q._clear_cache()
55
+ Traceback (most recent call last):
56
+ ...
57
+ TypeError: cannot clear cache of immutable polyhedra
58
+ """
59
+ if not self._is_mutable:
60
+ raise TypeError("cannot clear cache of immutable polyhedra")
61
+
62
+ # Invalidate object pointing towards this polyhedron (faces etc.).
63
+ for ob in self._dependent_objects:
64
+ ob._polyhedron = None
65
+ backend_object = self.__dict__["_" + self._backend_object_name]
66
+ del self.__dict__
67
+ self.__dict__["_" + self._backend_object_name] = backend_object
68
+ self._is_mutable = True
69
+ self._dependent_objects = []
70
+
71
+ def _add_dependent_object(self, ob):
72
+ r"""
73
+ Add an object that has ``self`` has attribute ``_polyhedron``.
74
+
75
+ When ``self`` is modified, we delete this attribute to invalidate those objects.
76
+
77
+ EXAMPLES::
78
+
79
+ sage: p = Polyhedron([[1, 1]], mutable=True)
80
+ sage: class foo:
81
+ ....: def __init__(self, p):
82
+ ....: self._polyhedron = p
83
+ ....:
84
+ sage: a = foo(p)
85
+ sage: a.__dict__
86
+ {'_polyhedron': A 0-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex}
87
+ sage: p._add_dependent_object(a)
88
+ sage: p._clear_cache()
89
+ sage: a.__dict__
90
+ {'_polyhedron': None}
91
+
92
+ TESTS::
93
+
94
+ sage: from sage.geometry.newton_polygon import NewtonPolygon
95
+ sage: p = Polyhedron([[1, 1]], mutable=True)
96
+ sage: n = NewtonPolygon(p)
97
+ sage: n
98
+ Finite Newton polygon with 1 vertex: (1, 1)
99
+ sage: n = NewtonPolygon(p)
100
+ sage: p._clear_cache()
101
+ sage: n
102
+ <repr(<sage.geometry.newton_polygon.ParentNewtonPolygon_with_category.element_class at ...>) failed: AttributeError: 'NoneType' object has no attribute 'vertices'>
103
+
104
+ ::
105
+
106
+ sage: f = p.faces(0)[0]; f
107
+ A 0-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex
108
+ sage: p._clear_cache()
109
+ sage: f
110
+ <repr(<sage.geometry.polyhedron.face.PolyhedronFace at ...>) failed: AttributeError: 'NoneType' object has no attribute 'parent'>
111
+
112
+ ::
113
+
114
+ sage: v = p.vertices()[0]
115
+ sage: p = Polyhedron([[1, 1]], mutable=True)
116
+ sage: v = p.Vrepresentation(0); v
117
+ A vertex at (1, 1)
118
+ sage: h = p.Hrepresentation(0); h
119
+ An equation (0, 1) x - 1 == 0
120
+ sage: p._clear_cache()
121
+ sage: v.polyhedron() is None
122
+ True
123
+ sage: h.polyhedron() is None
124
+ True
125
+
126
+ ::
127
+
128
+ sage: p = Polyhedron([[1, 0], [0, 1]], mutable=True)
129
+ sage: r = p.relative_interior()
130
+ sage: p._clear_cache()
131
+ sage: r
132
+ Relative interior of None
133
+ """
134
+ if ob._polyhedron is not self:
135
+ raise ValueError
136
+ self._dependent_objects.append(ob)
137
+
138
+ def is_mutable(self):
139
+ r"""
140
+ Return ``True`` if the polyhedron is mutable, i.e. it can be modified in place.
141
+
142
+ EXAMPLES::
143
+
144
+ sage: p = Polyhedron([[1, 1]], mutable=True)
145
+ sage: p.is_mutable()
146
+ True
147
+ sage: p = Polyhedron([[1, 1]], mutable=False)
148
+ sage: p.is_mutable()
149
+ False
150
+ """
151
+ return self._is_mutable
152
+
153
+ def is_immutable(self):
154
+ r"""
155
+ Return ``True`` if the polyhedron is immutable, i.e. it cannot be modified in place.
156
+
157
+ EXAMPLES::
158
+
159
+ sage: p = Polyhedron([[1, 1]], mutable=True)
160
+ sage: p.is_immutable()
161
+ False
162
+ sage: p = Polyhedron([[1, 1]], mutable=False)
163
+ sage: p.is_immutable()
164
+ True
165
+ """
166
+ return not self._is_mutable
167
+
168
+ @abstract_method
169
+ def set_immutable(self):
170
+ r"""
171
+ Make this polyhedron immutable. This operation cannot be undone.
172
+
173
+ TESTS::
174
+
175
+ sage: from sage.geometry.polyhedron.base_mutable import Polyhedron_mutable
176
+ sage: p = polytopes.cube()
177
+ sage: Polyhedron_mutable.set_immutable(p)
178
+ Traceback (most recent call last):
179
+ ...
180
+ TypeError: 'AbstractMethod' object is not callable
181
+ """
182
+
183
+ @abstract_method
184
+ def Vrepresentation(self):
185
+ r"""
186
+ A derived class must overwrite such that it restores Vrepresentation
187
+ after clearing it.
188
+
189
+ TESTS::
190
+
191
+ sage: from sage.geometry.polyhedron.base_mutable import Polyhedron_mutable
192
+ sage: p = polytopes.cube()
193
+ sage: Polyhedron_mutable.Vrepresentation(p)
194
+ Traceback (most recent call last):
195
+ ...
196
+ TypeError: 'AbstractMethod' object is not callable
197
+ """
198
+ # A derived class must implemented it to recalculate, if necessary.
199
+
200
+ @abstract_method
201
+ def Hrepresentation(self):
202
+ r"""
203
+ A derived class must overwrite such that it restores Hrepresentation
204
+ after clearing it.
205
+
206
+ TESTS::
207
+
208
+ sage: from sage.geometry.polyhedron.base_mutable import Polyhedron_mutable
209
+ sage: p = polytopes.cube()
210
+ sage: Polyhedron_mutable.Hrepresentation(p)
211
+ Traceback (most recent call last):
212
+ ...
213
+ TypeError: 'AbstractMethod' object is not callable
214
+ """
215
+ # A derived class must implemented it to recalculate, if necessary.
@@ -0,0 +1,122 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ r"""
3
+ Support for internal use of number fields in backends for polyhedral computations
4
+ """
5
+
6
+ # ****************************************************************************
7
+ # Copyright (C) 2016-2022 Matthias Köppe <mkoeppe at math.ucdavis.edu>
8
+ # 2016-2018 Travis Scrimshaw
9
+ # 2017 Jeroen Demeyer
10
+ # 2018-2020 Jean-Philippe Labbé
11
+ # 2019 Vincent Delecroix
12
+ # 2019-2021 Jonathan Kliem
13
+ # 2019-2021 Sophia Elia
14
+ # 2020 Frédéric Chapoton
15
+ # 2022 Yuan Zhou
16
+ #
17
+ # This program is free software: you can redistribute it and/or modify
18
+ # it under the terms of the GNU General Public License as published by
19
+ # the Free Software Foundation, either version 2 of the License, or
20
+ # (at your option) any later version.
21
+ # https://www.gnu.org/licenses/
22
+ # ****************************************************************************
23
+
24
+ from sage.rings.integer_ring import ZZ
25
+ from sage.rings.rational_field import QQ
26
+
27
+ from .base import Polyhedron_base
28
+
29
+
30
+ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds):
31
+ r"""
32
+ Like ``number_field_elements_from_algebraics``, but for a list of lists of lists.
33
+
34
+ EXAMPLES::
35
+
36
+ sage: rt2 = AA(sqrt(2)); rt2 # needs sage.rings.number_field sage.symbolic
37
+ 1.414213562373095?
38
+ sage: rt3 = AA(sqrt(3)); rt3 # needs sage.rings.number_field sage.symbolic
39
+ 1.732050807568878?
40
+ sage: from sage.geometry.polyhedron.base_number_field import _number_field_elements_from_algebraics_list_of_lists_of_lists
41
+ sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results # needs sage.rings.number_field sage.symbolic
42
+ [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
43
+ """
44
+ from sage.rings.qqbar import number_field_elements_from_algebraics
45
+ numbers = []
46
+ for lists in listss:
47
+ for list in lists:
48
+ numbers.extend(list)
49
+ K, K_numbers, hom = number_field_elements_from_algebraics(numbers, **kwds)
50
+ g = iter(K_numbers)
51
+ return K, [ [ [ next(g) for _ in list ] for list in lists ] for lists in listss ], hom
52
+
53
+
54
+ class Polyhedron_base_number_field(Polyhedron_base):
55
+
56
+ def _compute_data_lists_and_internal_base_ring(self, data_lists, convert_QQ, convert_NF):
57
+ r"""
58
+ Compute data lists in Normaliz or ``number_field`` backend format and the internal base ring of the data.
59
+
60
+ EXAMPLES::
61
+
62
+ sage: # optional - pynormaliz, needs sage.rings.number_field
63
+ sage: p = Polyhedron(vertices=[(0,1/2), (2,0), (4,5/6)],
64
+ ....: base_ring=AA, backend='normaliz')
65
+ sage: def convert_QQ(ieqs, eqs):
66
+ ....: return [[1000*x for x in ieq] for ieq in ieqs], \
67
+ ....: [[1000*x for x in eq] for eq in eqs]
68
+ sage: def convert_NF(ieqs, eqs):
69
+ ....: return ieqs, eqs
70
+ sage: p._compute_data_lists_and_internal_base_ring(
71
+ ....: [[[1]], [[1/2]]], convert_QQ, convert_NF)
72
+ (([[1000]], [[500]]), Rational Field)
73
+ sage: p._compute_data_lists_and_internal_base_ring(
74
+ ....: [[[AA(1)]], [[1/2]]], convert_QQ, convert_NF)
75
+ (([[1000]], [[500]]), Rational Field)
76
+ sage: p._compute_data_lists_and_internal_base_ring(
77
+ ....: [[[AA(sqrt(2))]], [[1/2]]], convert_QQ, convert_NF)
78
+ ([[[a]], [[1/2]]],
79
+ Number Field in a with defining polynomial y^2 - 2 with a = 1.414213562373095?)
80
+
81
+ TESTS::
82
+
83
+ sage: K.<a> = QuadraticField(-5) # needs sage.rings.number_field
84
+ sage: p = Polyhedron(base_ring=K, # indirect doctest # optional - pynormaliz, needs sage.rings.number_field
85
+ ....: backend='normaliz',
86
+ ....: vertices=[(a,1/2), (2,0), (4,5/6)])
87
+ Traceback (most recent call last):
88
+ ...
89
+ ValueError: invalid base ring: Number Field in a ... is not real embedded
90
+
91
+ Checks that :issue:`30248` is fixed::
92
+
93
+ sage: q = Polyhedron(base_ring=AA, # indirect doctest # optional - pynormaliz, needs sage.rings.number_field
94
+ ....: backend='normaliz',
95
+ ....: rays=[(0, 0, 1), (0, 1, -1), (1, 0, -1)]); q
96
+ A 3-dimensional polyhedron in AA^3 defined as the convex hull of 1 vertex and 3 rays
97
+ sage: -q # optional - pynormaliz, needs sage.rings.number_field
98
+ A 3-dimensional polyhedron in AA^3 defined as the convex hull of 1 vertex and 3 rays
99
+ """
100
+ from sage.categories.number_fields import NumberFields
101
+ from sage.rings.real_double import RDF
102
+
103
+ if self.base_ring() in (QQ, ZZ):
104
+ internal_base_ring = QQ
105
+ internal_data_lists = convert_QQ(*data_lists)
106
+ else:
107
+ # Allows to re-iterate if K is QQ below when data_lists contain
108
+ # iterators:
109
+ data_lists = [tuple(_) for _ in data_lists]
110
+ internal_data_lists = convert_NF(*data_lists)
111
+ if self.base_ring() in NumberFields():
112
+ if not RDF.has_coerce_map_from(self.base_ring()):
113
+ raise ValueError("invalid base ring: {} is a number field that is not real embedded".format(self.base_ring()))
114
+ internal_base_ring = self.base_ring()
115
+ else:
116
+ K, internal_data_lists, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists(internal_data_lists, embedded=True)
117
+ internal_base_ring = K
118
+ if K is QQ:
119
+ # Compute it with Normaliz, not QNormaliz
120
+ internal_data_lists = convert_QQ(*[ [ [ QQ(x) for x in v ] for v in l]
121
+ for l in data_lists ])
122
+ return internal_data_lists, internal_base_ring
@@ -0,0 +1,155 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ """
3
+ Generate cdd ``.ext`` / ``.ine`` file format
4
+ """
5
+
6
+ ########################################################################
7
+ # Copyright (C) 2008 Marshall Hampton <hamptonio@gmail.com>
8
+ # Copyright (C) 2011 Volker Braun <vbraun.name@gmail.com>
9
+ #
10
+ # Distributed under the terms of the GNU General Public License (GPL)
11
+ #
12
+ # http://www.gnu.org/licenses/
13
+ ########################################################################
14
+
15
+ from .misc import _set_to_None_if_empty, _common_length_of, _to_space_separated_string
16
+
17
+ #########################################################################
18
+
19
+
20
+ def cdd_Vrepresentation(cdd_type, vertices, rays, lines, file_output=None):
21
+ r"""
22
+ Return a string containing the V-representation in cddlib's ext format.
23
+
24
+ INPUT:
25
+
26
+ - ``file_output`` -- string (optional); a filename to which the
27
+ representation should be written. If set to ``None`` (default),
28
+ representation is returned as a string.
29
+
30
+ .. NOTE::
31
+
32
+ If there is no vertex given, then the origin will be implicitly
33
+ added. You cannot write the empty V-representation (which cdd would
34
+ refuse to process).
35
+
36
+ EXAMPLES::
37
+
38
+ sage: from sage.geometry.polyhedron.cdd_file_format import cdd_Vrepresentation
39
+ sage: print(cdd_Vrepresentation('rational', [[0,0]], [[1,0]], [[0,1]]))
40
+ V-representation
41
+ linearity 1 1
42
+ begin
43
+ 3 3 rational
44
+ 0 0 1
45
+ 0 1 0
46
+ 1 0 0
47
+ end
48
+
49
+ TESTS::
50
+
51
+ sage: from sage.misc.temporary_file import tmp_filename
52
+ sage: filename = tmp_filename(ext='.ext')
53
+ sage: cdd_Vrepresentation('rational', [[0,0]], [[1,0]], [[0,1]], file_output=filename)
54
+ """
55
+ vertices = _set_to_None_if_empty(vertices)
56
+ rays = _set_to_None_if_empty(rays)
57
+ lines = _set_to_None_if_empty(lines)
58
+
59
+ num, ambient_dim = _common_length_of(vertices, rays, lines)
60
+
61
+ # cdd implicitly assumes that the origin is a vertex if none is given
62
+ if vertices is None:
63
+ vertices = [[0]*ambient_dim]
64
+ num += 1
65
+
66
+ if cdd_type == 'real':
67
+ from sage.rings.real_double import RDF
68
+ base_ring = RDF
69
+ else:
70
+ base_ring = None
71
+
72
+ s = 'V-representation\n'
73
+ if lines is not None:
74
+ n = len(lines)
75
+ s += "linearity " + repr(n) + ' '
76
+ s += _to_space_separated_string(range(1,n+1)) + '\n'
77
+ s += 'begin\n'
78
+ s += ' ' + repr(num) + ' ' + repr(ambient_dim+1) + ' ' + cdd_type + '\n'
79
+ if lines is not None:
80
+ for l in lines:
81
+ s += ' 0 ' + _to_space_separated_string(l, base_ring) + '\n'
82
+ if rays is not None:
83
+ for r in rays:
84
+ s += ' 0 ' + _to_space_separated_string(r, base_ring) + '\n'
85
+ if vertices is not None:
86
+ for v in vertices:
87
+ s += ' 1 ' + _to_space_separated_string(v, base_ring) + '\n'
88
+ s += 'end\n'
89
+
90
+ if file_output is not None:
91
+ in_file = open(file_output, 'w')
92
+ in_file.write(s)
93
+ in_file.close()
94
+ else:
95
+ return s
96
+
97
+ #########################################################################
98
+
99
+
100
+ def cdd_Hrepresentation(cdd_type, ieqs, eqns, file_output=None):
101
+ r"""
102
+ Return a string containing the H-representation in cddlib's ine format.
103
+
104
+ INPUT:
105
+
106
+ - ``file_output`` -- string (optional); a filename to which the
107
+ representation should be written. If set to ``None`` (default),
108
+ representation is returned as a string.
109
+
110
+ EXAMPLES::
111
+
112
+ sage: from sage.geometry.polyhedron.cdd_file_format import cdd_Hrepresentation
113
+ sage: cdd_Hrepresentation('rational', None, [[0,1]])
114
+ 'H-representation\nlinearity 1 1\nbegin\n 1 2 rational\n 0 1\nend\n'
115
+
116
+ TESTS::
117
+
118
+ sage: from sage.misc.temporary_file import tmp_filename
119
+ sage: filename = tmp_filename(ext='.ine')
120
+ sage: cdd_Hrepresentation('rational', None, [[0,1]], file_output=filename)
121
+ """
122
+ ieqs = _set_to_None_if_empty(ieqs)
123
+ eqns = _set_to_None_if_empty(eqns)
124
+
125
+ num, ambient_dim = _common_length_of(ieqs, eqns)
126
+ ambient_dim -= 1
127
+
128
+ if cdd_type == 'real':
129
+ from sage.rings.real_double import RDF
130
+ base_ring = RDF
131
+ else:
132
+ base_ring = None
133
+
134
+ s = 'H-representation\n'
135
+ if eqns is not None:
136
+ assert len(eqns) > 0
137
+ n = len(eqns)
138
+ s += "linearity " + repr(n) + ' '
139
+ s += _to_space_separated_string(range(1,n+1)) + '\n'
140
+ s += 'begin\n'
141
+ s += ' ' + repr(num) + ' ' + repr(ambient_dim+1) + ' ' + cdd_type + '\n'
142
+ if eqns is not None:
143
+ for e in eqns:
144
+ s += ' ' + _to_space_separated_string(e, base_ring) + '\n'
145
+ if ieqs is not None:
146
+ for i in ieqs:
147
+ s += ' ' + _to_space_separated_string(i, base_ring) + '\n'
148
+ s += 'end\n'
149
+
150
+ if file_output is not None:
151
+ in_file = open(file_output, 'w')
152
+ in_file.write(s)
153
+ in_file.close()
154
+ else:
155
+ return s
@@ -0,0 +1 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
@@ -0,0 +1,76 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ cimport cython
3
+ from sage.data_structures.list_of_pairs cimport ListOfPairs
4
+ from sage.structure.sage_object cimport SageObject
5
+ from sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator cimport FaceIterator, CombinatorialFace
6
+ from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces cimport ListOfFaces
7
+ from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport face_t
8
+ from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice cimport PolyhedronFaceLattice
9
+
10
+
11
+ @cython.final
12
+ cdef class CombinatorialPolyhedron(SageObject):
13
+ cdef public dict _cached_methods
14
+
15
+ # Do not assume any of those attributes to be initialized, use the corresponding methods instead.
16
+ cdef tuple _Vrep # the names of VRep, if they exist
17
+ cdef tuple _facet_names # the names of HRep without equations, if they exist
18
+ cdef tuple _equations # stores equations, given on input (might belong to Hrep)
19
+ cdef int _dimension # stores dimension, -2 on init
20
+ cdef unsigned int _n_Hrepresentation # Hrep might include equations
21
+ cdef unsigned int _n_Vrepresentation # Vrep might include rays/lines
22
+ cdef size_t _n_facets # length Hrep without equations
23
+ cdef bint _bounded # ``True`` iff Polyhedron is bounded
24
+ cdef ListOfFaces _bitrep_facets # facets in bit representation
25
+ cdef ListOfFaces _bitrep_Vrep # vertices in bit representation
26
+ cdef face_t _far_face # a 'face' containing all none-vertices of Vrep
27
+ cdef tuple _far_face_tuple
28
+ cdef tuple _f_vector
29
+
30
+ cdef ListOfPairs _edges # stores edges labeled by vertex indices
31
+ cdef ListOfPairs _ridges # stores ridges labeled by facet indices
32
+ cdef ListOfPairs _face_lattice_incidences # stores incidences in Hasse diagram labeled indices of the faces
33
+ cdef PolyhedronFaceLattice _all_faces # class to generate Hasse diagram incidences
34
+
35
+ cdef tuple Vrep(self)
36
+ cdef tuple facet_names(self)
37
+ cdef tuple equations(self)
38
+ cdef unsigned int n_Vrepresentation(self) noexcept
39
+ cdef unsigned int n_Hrepresentation(self) noexcept
40
+ cdef bint is_bounded(self) noexcept
41
+ cdef ListOfFaces bitrep_facets(self)
42
+ cdef ListOfFaces bitrep_Vrep(self)
43
+ cdef tuple far_face_tuple(self)
44
+ cdef int _algorithm_to_dual(self, algorithm) except -2
45
+
46
+ # Methods to initialize the combinatorial polyhedron.
47
+ cdef _init_from_polyhedron(self, data)
48
+ cdef _init_from_lattice_polytope(self, data)
49
+ cdef _init_from_cone(self, data)
50
+ cdef _init_facet_names(self, facets)
51
+ cdef _init_from_incidence_matrix(self, data)
52
+ cdef _init_from_list_of_facets(self, data)
53
+ cdef _init_from_ListOfFaces(self, ListOfFaces facets, ListOfFaces Vrep)
54
+ cdef _initialize_far_face(self)
55
+ cdef _init_as_trivial_polyhedron(self, int dimension)
56
+
57
+ # Methods to obtain a different combinatorial polyhedron.
58
+ cpdef CombinatorialPolyhedron dual(self)
59
+ cpdef CombinatorialPolyhedron pyramid(self, new_vertex=*, new_facet=*)
60
+
61
+ cdef FaceIterator _face_iter(self, bint dual, int dimension)
62
+ cdef int _compute_f_vector(self, size_t num_threads, size_t parallelization_depth, int dual) except -1
63
+ cdef int _persist_f_vector(self, size_t* input_f_vector, bint input_is_reversed) except -1
64
+
65
+ cdef inline int _compute_edges(self, dual) except -1:
66
+ return self._compute_edges_or_ridges(dual, True)
67
+
68
+ cdef inline int _compute_ridges(self, dual) except -1:
69
+ return self._compute_edges_or_ridges(dual, False)
70
+
71
+ cdef int _compute_edges_or_ridges(self, int dual, bint do_edges) except -1
72
+ cdef size_t _compute_edges_or_ridges_with_iterator(
73
+ self, FaceIterator face_iter, const bint do_atom_rep,
74
+ ListOfPairs edges, size_t* f_vector) except -1
75
+
76
+ cdef int _compute_face_lattice_incidences(self) except -1