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,1038 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ r"""
3
+ Combinatorial face of a polyhedron
4
+
5
+ This module provides the combinatorial type of a polyhedral face.
6
+
7
+ .. SEEALSO::
8
+
9
+ :mod:`sage.geometry.polyhedron.combinatorial_polyhedron.base`,
10
+ :mod:`sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator`.
11
+
12
+ EXAMPLES:
13
+
14
+ Obtain a face from a face iterator::
15
+
16
+ sage: P = polytopes.cube()
17
+ sage: C = CombinatorialPolyhedron(P)
18
+ sage: it = C.face_generator()
19
+ sage: face = next(it); face
20
+ A 2-dimensional face of a 3-dimensional combinatorial polyhedron
21
+
22
+ Obtain a face from a face lattice index::
23
+
24
+ sage: P = polytopes.simplex(2)
25
+ sage: C = CombinatorialPolyhedron(P)
26
+ sage: sorted(C.face_lattice()._elements) # needs sage.combinat
27
+ [0, 1, 2, 3, 4, 5, 6, 7]
28
+ sage: face = C.face_by_face_lattice_index(0); face
29
+ A -1-dimensional face of a 2-dimensional combinatorial polyhedron
30
+
31
+ Obtain further information regarding a face::
32
+
33
+ sage: P = polytopes.octahedron()
34
+ sage: C = CombinatorialPolyhedron(P)
35
+ sage: it = C.face_generator(2)
36
+ sage: face = next(it); face
37
+ A 2-dimensional face of a 3-dimensional combinatorial polyhedron
38
+ sage: face.ambient_Vrepresentation()
39
+ (A vertex at (0, 0, 1), A vertex at (0, 1, 0), A vertex at (1, 0, 0))
40
+ sage: face.n_ambient_Vrepresentation()
41
+ 3
42
+ sage: face.ambient_H_indices()
43
+ (5,)
44
+ sage: face.dimension()
45
+ 2
46
+ sage: face.ambient_dimension()
47
+ 3
48
+
49
+ .. SEEALSO::
50
+
51
+ :class:`sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron`.
52
+
53
+ AUTHOR:
54
+
55
+ - Jonathan Kliem (2019-05)
56
+ """
57
+
58
+ # ****************************************************************************
59
+ # Copyright (C) 2019 Jonathan Kliem <jonathan.kliem@gmail.com>
60
+ #
61
+ # This program is free software: you can redistribute it and/or modify
62
+ # it under the terms of the GNU General Public License as published by
63
+ # the Free Software Foundation, either version 2 of the License, or
64
+ # (at your option) any later version.
65
+ # https://www.gnu.org/licenses/
66
+ # ****************************************************************************
67
+
68
+ from cysignals.memory cimport check_allocarray, sig_free
69
+
70
+ import numbers
71
+ from sage.rings.integer cimport smallInteger
72
+ from sage.geometry.polyhedron.combinatorial_polyhedron.conversions cimport bit_rep_to_Vrep_list
73
+ from sage.geometry.polyhedron.combinatorial_polyhedron.base cimport CombinatorialPolyhedron
74
+ from sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator cimport FaceIterator_base, FaceStatus
75
+ from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice cimport PolyhedronFaceLattice
76
+ from sage.geometry.polyhedron.combinatorial_polyhedron.face_data_structure cimport face_len_atoms, face_init, face_free, face_copy, face_issubset
77
+ from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport bit_rep_to_coatom_rep
78
+ from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces cimport face_as_combinatorial_polyhedron
79
+
80
+
81
+ cdef extern from "Python.h":
82
+ int unlikely(int) nogil # Defined by Cython
83
+
84
+
85
+ cdef class CombinatorialFace(SageObject):
86
+ r"""
87
+ A class of the combinatorial type of a polyhedral face.
88
+
89
+ EXAMPLES:
90
+
91
+ Obtain a combinatorial face from a face iterator::
92
+
93
+ sage: P = polytopes.cyclic_polytope(5,8)
94
+ sage: C = CombinatorialPolyhedron(P)
95
+ sage: it = C.face_generator()
96
+ sage: next(it)
97
+ A 0-dimensional face of a 5-dimensional combinatorial polyhedron
98
+
99
+ Obtain a combinatorial face from an index of the face lattice::
100
+
101
+ sage: F = C.face_lattice() # needs sage.combinat
102
+ sage: F._elements[3] # needs sage.combinat
103
+ 34
104
+ sage: C.face_by_face_lattice_index(29)
105
+ A 1-dimensional face of a 5-dimensional combinatorial polyhedron
106
+
107
+ Obtain the dimension of a combinatorial face::
108
+
109
+ sage: face = next(it)
110
+ sage: face.dimension()
111
+ 0
112
+
113
+ The dimension of the polyhedron::
114
+
115
+ sage: face.ambient_dimension()
116
+ 5
117
+
118
+ The Vrepresentation::
119
+
120
+ sage: face.ambient_Vrepresentation()
121
+ (A vertex at (6, 36, 216, 1296, 7776),)
122
+ sage: face.ambient_V_indices()
123
+ (6,)
124
+ sage: face.n_ambient_Vrepresentation()
125
+ 1
126
+
127
+ The Hrepresentation::
128
+
129
+ sage: face.ambient_Hrepresentation()
130
+ (An inequality (60, -112, 65, -14, 1) x + 0 >= 0,
131
+ An inequality (180, -216, 91, -16, 1) x + 0 >= 0,
132
+ An inequality (360, -342, 119, -18, 1) x + 0 >= 0,
133
+ An inequality (840, -638, 179, -22, 1) x + 0 >= 0,
134
+ An inequality (-2754, 1175, -245, 25, -1) x + 2520 >= 0,
135
+ An inequality (504, -450, 145, -20, 1) x + 0 >= 0,
136
+ An inequality (-1692, 853, -203, 23, -1) x + 1260 >= 0,
137
+ An inequality (252, -288, 113, -18, 1) x + 0 >= 0,
138
+ An inequality (-844, 567, -163, 21, -1) x + 420 >= 0,
139
+ An inequality (84, -152, 83, -16, 1) x + 0 >= 0,
140
+ An inequality (-210, 317, -125, 19, -1) x + 0 >= 0)
141
+ sage: face.ambient_H_indices()
142
+ (3, 4, 5, 6, 7, 8, 9, 10, 11, 18, 19)
143
+ sage: face.n_ambient_Hrepresentation()
144
+ 11
145
+ """
146
+ def __cinit__(self, data, dimension=None, index=None):
147
+ r"""
148
+ Initialize :class:`CombinatorialFace`.
149
+
150
+ See :class:`CombinatorialFace`.
151
+
152
+ TESTS::
153
+
154
+ sage: C = CombinatorialPolyhedron([[0,1,2],[0,1,3],
155
+ ....: [0,2,3],[1,2,3]])
156
+ sage: it = C.face_generator()
157
+ sage: next(it) # indirect doctest
158
+ A 2-dimensional face of a 3-dimensional combinatorial polyhedron
159
+
160
+ sage: C.face_by_face_lattice_index(0)
161
+ A -1-dimensional face of a 3-dimensional combinatorial polyhedron
162
+
163
+ sage: TestSuite(sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace).run()
164
+ """
165
+ # Note that all values are set to zero at the time ``__cinit__`` is called:
166
+ # https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#initialisation-methods
167
+ # In particular, ``__dealloc__`` will not do harm in this case.
168
+
169
+ cdef FaceIterator_base it
170
+ cdef PolyhedronFaceLattice all_faces
171
+
172
+ if isinstance(data, FaceIterator_base):
173
+ assert dimension is None and index is None, "dimension and index must be ``None``, when providing a face iterator"
174
+
175
+ # Copy data from FaceIterator.
176
+ it = data
177
+ self._dual = it.dual
178
+ self.atoms = it.atoms
179
+ self.coatoms = it.coatoms
180
+
181
+ if it.structure.face_status == FaceStatus.NOT_INITIALIZED:
182
+ raise LookupError("face iterator not set to a face")
183
+
184
+ face_init(self.face, self.coatoms.n_atoms(), self.coatoms.n_coatoms())
185
+ face_copy(self.face, it.structure.face)
186
+
187
+ self._dimension = it.structure.current_dimension
188
+ self._ambient_dimension = it.structure.dimension
189
+ self._ambient_Vrep = it._Vrep
190
+ self._ambient_facets = it._facet_names
191
+ self._n_ambient_facets = it._n_facets
192
+ self._equations = it._equations
193
+ self._n_equations = it._n_equations
194
+ self._hash_index = it.structure._index
195
+ self._ambient_bounded = it._bounded
196
+
197
+ self._initialized_from_face_lattice = False
198
+
199
+ elif isinstance(data, PolyhedronFaceLattice):
200
+ all_faces = data
201
+ assert isinstance(dimension, numbers.Integral), "dimension must be an integer"
202
+ assert isinstance(index, numbers.Integral), "index must be an integer"
203
+ assert -1 <= dimension <= all_faces.dimension, "dimension must be a face dimension of the polyhedron"
204
+ assert 0 <= index < all_faces.f_vector[dimension + 1], "index is out of range"
205
+
206
+ # Copy data from PolyhedronFaceLattice.
207
+ self._dual = all_faces.dual
208
+ self.atoms = all_faces.atoms
209
+ self.coatoms = all_faces.coatoms
210
+
211
+ face_init(self.face, self.coatoms.n_atoms(), self.coatoms.n_coatoms())
212
+ face_copy(self.face, all_faces.faces[dimension+1].faces[index])
213
+
214
+ self._dimension = dimension
215
+ self._ambient_dimension = all_faces.dimension
216
+ self._ambient_Vrep = all_faces._Vrep
217
+ self._ambient_facets = all_faces._facet_names
218
+ self._equations = all_faces._equations
219
+ self._n_equations = len(self._equations) if self._equations else 0
220
+ if self._dual:
221
+ self._n_ambient_facets = self.atoms.n_faces()
222
+ else:
223
+ self._n_ambient_facets = self.coatoms.n_faces()
224
+ self._ambient_bounded = all_faces._bounded
225
+
226
+ self._initialized_from_face_lattice = True
227
+
228
+ self._hash_index = index
229
+ for i in range(-1, dimension):
230
+ self._hash_index += all_faces.f_vector[i+1]
231
+
232
+ # Add the complete ``f-vector`` to the hash index,
233
+ # such that hash values obtained by an iterator or by the face lattice
234
+ # do not collide.
235
+ for i in range(-1, self._ambient_dimension+1):
236
+ self._hash_index += all_faces.f_vector[i+1]
237
+ else:
238
+ raise ValueError("data must be face iterator or a list of all faces")
239
+
240
+ if self._dual:
241
+ # Reverse the hash index in dual mode to respect inclusion of faces.
242
+ self._hash_index = -self._hash_index - 1
243
+
244
+ def __dealloc__(self):
245
+ r"""
246
+ TESTS::
247
+
248
+ sage: from sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face import CombinatorialFace
249
+ sage: CombinatorialFace(2) # indirect doctest
250
+ Traceback (most recent call last):
251
+ ...
252
+ ValueError: data must be face iterator or a list of all faces
253
+ """
254
+ face_free(self.face)
255
+ sig_free(self.atom_rep)
256
+ sig_free(self.coatom_rep)
257
+
258
+ def _repr_(self):
259
+ r"""
260
+ Return a description of the combinatorial face.
261
+
262
+ EXAMPLES::
263
+
264
+ sage: # needs sage.combinat
265
+ sage: P = polytopes.permutahedron(6)
266
+ sage: C = CombinatorialPolyhedron(P)
267
+ sage: it = C.face_generator(dimension=3, algorithm='primal')
268
+ sage: face = next(it)
269
+ sage: face.__repr__()
270
+ 'A 3-dimensional face of a 5-dimensional combinatorial polyhedron'
271
+ sage: it = C.face_generator(dimension=3, algorithm='dual')
272
+ sage: face = next(it)
273
+ sage: face.__repr__()
274
+ 'A 3-dimensional face of a 5-dimensional combinatorial polyhedron'
275
+ """
276
+ return "A {}-dimensional face of a {}-dimensional combinatorial polyhedron"\
277
+ .format(self.dimension(), self.ambient_dimension())
278
+
279
+ def __reduce__(self):
280
+ r"""
281
+ Override __reduce__ to indicate that pickle/unpickle will not work.
282
+
283
+ EXAMPLES::
284
+
285
+ sage: P = polytopes.simplex()
286
+ sage: C = CombinatorialPolyhedron(P)
287
+ sage: it = C.face_generator()
288
+ sage: face = next(it)
289
+ sage: face1 = loads(face.dumps())
290
+ Traceback (most recent call last):
291
+ ...
292
+ NotImplementedError
293
+ """
294
+ raise NotImplementedError
295
+
296
+ def __hash__(self):
297
+ r"""
298
+ Return an index for the face.
299
+
300
+ This is constructed such that for faces `F,G` constructed in the same manner (same face iterator or face lattice)
301
+ it holds that `F` contained in `G` implies ``hash(F) < hash(G)``.
302
+
303
+ If the face was constructed from a :class:`sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator.FaceIterator`,
304
+ then this is the index of the occurrence in the iterator.
305
+ In dual mode this value is then deducted from the maximal value of ``size_t``.
306
+
307
+ If the face was constructed from
308
+ :meth:`sage:geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron.face_by_face_lattice_index`,
309
+ then this is the total number of faces plus the index in the level set plus the number of lower dimensional faces
310
+ (or higher dimensional faces in dual mode).
311
+ In dual mode this value is then deducted from the maximal value of ``size_t``.
312
+
313
+ EXAMPLES::
314
+
315
+ sage: P = polytopes.simplex(2)
316
+ sage: C = CombinatorialPolyhedron(P)
317
+ sage: it = C.face_generator()
318
+ sage: [hash(face) for face in it]
319
+ [1, 2, 3, 4, 5, 6]
320
+
321
+ TESTS::
322
+
323
+ sage: # needs sage.combinat
324
+ sage: P = polytopes.permutahedron(5)
325
+ sage: C = CombinatorialPolyhedron(P)
326
+ sage: F = C.face_lattice()
327
+ sage: G = F.relabel(C.face_by_face_lattice_index)
328
+
329
+ sage: P = polytopes.cyclic_polytope(4,10)
330
+ sage: C = CombinatorialPolyhedron(P)
331
+ sage: F = C.face_lattice() # needs sage.combinat
332
+ sage: G = F.relabel(C.face_by_face_lattice_index) # needs sage.combinat
333
+ """
334
+ return self._hash_index
335
+
336
+ def __lt__(self, other):
337
+ r"""
338
+ Compare faces of the same polyhedron.
339
+
340
+ This is a helper function.
341
+ In order to construct a Hasse diagram (a digraph) with combinatorial faces,
342
+ we must define some order relation that is compatible with the Hasse diagram.
343
+
344
+ Any order relation compatible with ordering by dimension is suitable.
345
+ We use :meth:`__hash__` to define the relation.
346
+
347
+ EXAMPLES::
348
+
349
+ sage: P = polytopes.cube()
350
+ sage: C = CombinatorialPolyhedron(P)
351
+ sage: F1 = C.face_by_face_lattice_index(0)
352
+ sage: F2 = C.face_by_face_lattice_index(1)
353
+ sage: F1 < F2
354
+ True
355
+ sage: for i,j in Combinations(range(28), 2):
356
+ ....: F1 = C.face_by_face_lattice_index(i)
357
+ ....: F2 = C.face_by_face_lattice_index(j)
358
+ ....: if F1.dim() != F2.dim():
359
+ ....: assert (F1.dim() < F2.dim()) == (F1 < F2)
360
+
361
+ sage: P = polytopes.cross_polytope(3)
362
+ sage: C = CombinatorialPolyhedron(P)
363
+ sage: F1 = C.face_by_face_lattice_index(0)
364
+ sage: F2 = C.face_by_face_lattice_index(1)
365
+ sage: F1 < F2
366
+ True
367
+ sage: for i,j in Combinations(range(28), 2):
368
+ ....: F1 = C.face_by_face_lattice_index(i)
369
+ ....: F2 = C.face_by_face_lattice_index(j)
370
+ ....: if F1.dim() != F2.dim():
371
+ ....: assert (F1.dim() < F2.dim()) == (F1 < F2)
372
+ """
373
+ cdef CombinatorialFace other_face
374
+ if isinstance(other, CombinatorialFace):
375
+ other_face = other
376
+ if (self._initialized_from_face_lattice == other_face._initialized_from_face_lattice and
377
+ self.atoms is other_face.atoms):
378
+ # They are faces of the same polyhedron obtained in the same way.
379
+ return hash(self) < hash(other)
380
+
381
+ def is_subface(self, CombinatorialFace other):
382
+ r"""
383
+ Return whether ``self`` is contained in ``other``.
384
+
385
+ EXAMPLES::
386
+
387
+ sage: P = polytopes.cube()
388
+ sage: C = P.combinatorial_polyhedron()
389
+ sage: it = C.face_generator()
390
+ sage: face = next(it)
391
+ sage: face.ambient_V_indices()
392
+ (0, 3, 4, 5)
393
+ sage: face2 = next(it)
394
+ sage: face2.ambient_V_indices()
395
+ (0, 1, 5, 6)
396
+ sage: face.is_subface(face2)
397
+ False
398
+ sage: face2.is_subface(face)
399
+ False
400
+ sage: it.only_subfaces()
401
+ sage: face3 = next(it)
402
+ sage: face3.ambient_V_indices()
403
+ (0, 5)
404
+ sage: face3.is_subface(face2)
405
+ True
406
+ sage: face3.is_subface(face)
407
+ True
408
+
409
+ Works for faces of the same combinatorial polyhedron;
410
+ also from different iterators::
411
+
412
+ sage: it = C.face_generator(algorithm='dual')
413
+ sage: v7 = next(it); v7.ambient_V_indices()
414
+ (7,)
415
+ sage: v6 = next(it); v6.ambient_V_indices()
416
+ (6,)
417
+ sage: v5 = next(it); v5.ambient_V_indices()
418
+ (5,)
419
+ sage: face.ambient_V_indices()
420
+ (0, 3, 4, 5)
421
+ sage: face.is_subface(v7)
422
+ False
423
+ sage: v7.is_subface(face)
424
+ False
425
+ sage: v6.is_subface(face)
426
+ False
427
+ sage: v5.is_subface(face)
428
+ True
429
+ sage: face2.ambient_V_indices()
430
+ (0, 1, 5, 6)
431
+ sage: face2.is_subface(v7)
432
+ False
433
+ sage: v7.is_subface(face2)
434
+ False
435
+ sage: v6.is_subface(face2)
436
+ True
437
+ sage: v5.is_subface(face2)
438
+ True
439
+
440
+ Only implemented for faces of the same combinatorial polyhedron::
441
+
442
+ sage: P1 = polytopes.cube()
443
+ sage: C1 = P1.combinatorial_polyhedron()
444
+ sage: it = C1.face_generator()
445
+ sage: other_face = next(it)
446
+ sage: other_face.ambient_V_indices()
447
+ (0, 3, 4, 5)
448
+ sage: face.ambient_V_indices()
449
+ (0, 3, 4, 5)
450
+ sage: C is C1
451
+ False
452
+ sage: face.is_subface(other_face)
453
+ Traceback (most recent call last):
454
+ ...
455
+ NotImplementedError: is_subface only implemented for faces of the same polyhedron
456
+ """
457
+ cdef size_t length_self, length_other, counter_self, counter_other
458
+ cdef size_t* self_v_indices
459
+ cdef size_t* other_v_indices
460
+
461
+ if self._dual == other._dual:
462
+ if self.atoms is other.atoms:
463
+ if not self._dual:
464
+ return face_issubset(self.face, other.face)
465
+ else:
466
+ return face_issubset(other.face, self.face)
467
+ else:
468
+ raise NotImplementedError("is_subface only implemented for faces of the same polyhedron")
469
+ else:
470
+ if self.atoms is other.coatoms:
471
+ if self.dimension() > other.dimension():
472
+ return False
473
+ if self._dual:
474
+ length_self = self.set_coatom_rep()
475
+ self_v_indices = self.coatom_rep
476
+ length_other = other.set_atom_rep()
477
+ other_v_indices = other.atom_rep
478
+ else:
479
+ length_self = self.set_atom_rep()
480
+ self_v_indices = self.atom_rep
481
+ length_other = other.set_coatom_rep()
482
+ other_v_indices = other.coatom_rep
483
+ if length_self > length_other:
484
+ return False
485
+
486
+ # Check if every element in self_v_indices is contained in other_v_indices.
487
+ counter_self = 0
488
+ counter_other = 0
489
+ while counter_self < length_self and counter_other < length_other:
490
+ if self_v_indices[counter_self] > other_v_indices[counter_other]:
491
+ counter_other += 1
492
+ elif self_v_indices[counter_self] == other_v_indices[counter_other]:
493
+ counter_self += 1
494
+ counter_other += 1
495
+ else:
496
+ return False
497
+ return counter_self == length_self
498
+ else:
499
+ raise NotImplementedError("is_subface only implemented for faces of the same polyhedron")
500
+
501
+ cpdef dimension(self):
502
+ r"""
503
+ Return the dimension of the face.
504
+
505
+ EXAMPLES::
506
+
507
+ sage: # needs sage.combinat
508
+ sage: P = polytopes.associahedron(['A', 3])
509
+ sage: C = CombinatorialPolyhedron(P)
510
+ sage: it = C.face_generator()
511
+ sage: face = next(it)
512
+ sage: face.dimension()
513
+ 2
514
+
515
+ ``dim`` is an alias::
516
+
517
+ sage: face.dim() # needs sage.combinat
518
+ 2
519
+ """
520
+ if self._dual:
521
+ return smallInteger(self._ambient_dimension - self._dimension - 1)
522
+ else:
523
+ return smallInteger(self._dimension)
524
+
525
+ dim = dimension
526
+
527
+ def ambient_dimension(self):
528
+ r"""
529
+ Return the dimension of the polyhedron.
530
+
531
+ EXAMPLES::
532
+
533
+ sage: P = polytopes.cube()
534
+ sage: C = CombinatorialPolyhedron(P)
535
+ sage: it = C.face_generator()
536
+ sage: face = next(it)
537
+ sage: face.ambient_dimension()
538
+ 3
539
+ """
540
+ return smallInteger(self._ambient_dimension)
541
+
542
+ def ambient_Vrepresentation(self):
543
+ r"""
544
+ Return the Vrepresentation objects of the ambient polyhedron
545
+ defining the face.
546
+
547
+ It consists of the vertices/rays/lines
548
+ that face contains.
549
+
550
+ EXAMPLES::
551
+
552
+ sage: # needs sage.combinat
553
+ sage: P = polytopes.permutahedron(5)
554
+ sage: C = CombinatorialPolyhedron(P)
555
+ sage: it = C.face_generator(dimension=2)
556
+ sage: face = next(it)
557
+ sage: face.ambient_Vrepresentation()
558
+ (A vertex at (1, 3, 2, 5, 4),
559
+ A vertex at (2, 3, 1, 5, 4),
560
+ A vertex at (3, 1, 2, 5, 4),
561
+ A vertex at (3, 2, 1, 5, 4),
562
+ A vertex at (2, 1, 3, 5, 4),
563
+ A vertex at (1, 2, 3, 5, 4))
564
+ sage: face = next(it)
565
+ sage: face.ambient_Vrepresentation()
566
+ (A vertex at (2, 1, 4, 5, 3),
567
+ A vertex at (3, 2, 4, 5, 1),
568
+ A vertex at (3, 1, 4, 5, 2),
569
+ A vertex at (1, 3, 4, 5, 2),
570
+ A vertex at (1, 2, 4, 5, 3),
571
+ A vertex at (2, 3, 4, 5, 1))
572
+
573
+ sage: C = CombinatorialPolyhedron([[0,1,2],[0,1,3],[0,2,3],[1,2,3]])
574
+ sage: it = C.face_generator()
575
+ sage: for face in it: (face.dimension(), face.ambient_Vrepresentation())
576
+ (2, (1, 2, 3))
577
+ (2, (0, 2, 3))
578
+ (2, (0, 1, 3))
579
+ (2, (0, 1, 2))
580
+ (1, (2, 3))
581
+ (1, (1, 3))
582
+ (1, (1, 2))
583
+ (0, (3,))
584
+ (0, (2,))
585
+ (0, (1,))
586
+ (1, (0, 3))
587
+ (1, (0, 2))
588
+ (0, (0,))
589
+ (1, (0, 1))
590
+
591
+ .. SEEALSO::
592
+
593
+ :meth:`ambient_V_indices`.
594
+ """
595
+ if not self._ambient_Vrep:
596
+ # There are no names, so we return indices instead.
597
+ return self.ambient_V_indices()
598
+ cdef size_t length
599
+ if self._dual:
600
+ # if dual, the Vrepresentation corresponds to the coatom-representation
601
+ length = self.set_coatom_rep()
602
+ return tuple(self._ambient_Vrep[self.coatom_rep[i]]
603
+ for i in range(length))
604
+ else:
605
+ # if not dual, the Vrepresentation corresponds to the atom-representation
606
+ length = self.set_atom_rep()
607
+ return tuple(self._ambient_Vrep[self.atom_rep[i]]
608
+ for i in range(length))
609
+
610
+ def ambient_V_indices(self):
611
+ r"""
612
+ Return the indices of the Vrepresentation
613
+ objects of the ambient polyhedron defining the face.
614
+
615
+ EXAMPLES::
616
+
617
+ sage: # needs sage.combinat
618
+ sage: P = polytopes.permutahedron(5)
619
+ sage: C = CombinatorialPolyhedron(P)
620
+ sage: it = C.face_generator(dimension=2)
621
+ sage: face = next(it)
622
+ sage: next(it).ambient_V_indices()
623
+ (32, 91, 92, 93, 94, 95)
624
+ sage: next(it).ambient_V_indices()
625
+ (32, 89, 90, 94)
626
+
627
+ sage: C = CombinatorialPolyhedron([[0,1,2],[0,1,3],[0,2,3],[1,2,3]])
628
+ sage: it = C.face_generator()
629
+ sage: for face in it: (face.dimension(), face.ambient_V_indices())
630
+ (2, (1, 2, 3))
631
+ (2, (0, 2, 3))
632
+ (2, (0, 1, 3))
633
+ (2, (0, 1, 2))
634
+ (1, (2, 3))
635
+ (1, (1, 3))
636
+ (1, (1, 2))
637
+ (0, (3,))
638
+ (0, (2,))
639
+ (0, (1,))
640
+ (1, (0, 3))
641
+ (1, (0, 2))
642
+ (0, (0,))
643
+ (1, (0, 1))
644
+
645
+ .. SEEALSO::
646
+
647
+ :meth:`ambient_Vrepresentation`.
648
+ """
649
+ cdef size_t length
650
+ if self._dual:
651
+ # if dual, the Vrepresentation corresponds to the coatom-representation
652
+ length = self.set_coatom_rep()
653
+ return tuple(smallInteger(self.coatom_rep[i])
654
+ for i in range(length))
655
+ else:
656
+ # if not dual, the Vrepresentation corresponds to the atom-representation
657
+ length = self.set_atom_rep()
658
+ return tuple(smallInteger(self.atom_rep[i])
659
+ for i in range(length))
660
+
661
+ def n_ambient_Vrepresentation(self):
662
+ r"""
663
+ Return the length of the :meth:`CombinatorialFace.ambient_V_indices`.
664
+
665
+ Might be faster than using ``len``.
666
+
667
+ EXAMPLES::
668
+
669
+ sage: P = polytopes.cube()
670
+ sage: C = CombinatorialPolyhedron(P)
671
+ sage: it = C.face_generator()
672
+ sage: all(face.n_ambient_Vrepresentation() == len(face.ambient_Vrepresentation()) for face in it)
673
+ True
674
+
675
+ TESTS::
676
+
677
+ sage: P = polytopes.cube()
678
+ sage: C = CombinatorialPolyhedron(P)
679
+ sage: it = C.face_generator()
680
+ sage: face = next(it)
681
+ """
682
+ if self._dual:
683
+ return smallInteger(self.set_coatom_rep())
684
+ else:
685
+ return smallInteger(self.n_atom_rep())
686
+
687
+ def ambient_Hrepresentation(self):
688
+ r"""
689
+ Return the Hrepresentation objects of the ambient polyhedron
690
+ defining the face.
691
+
692
+ It consists of the facets/inequalities that contain the face
693
+ and the equations defining the ambient polyhedron.
694
+
695
+ EXAMPLES::
696
+
697
+ sage: # needs sage.combinat
698
+ sage: P = polytopes.permutahedron(5)
699
+ sage: C = CombinatorialPolyhedron(P)
700
+ sage: it = C.face_generator(2)
701
+ sage: next(it).ambient_Hrepresentation()
702
+ (An inequality (1, 1, 1, 0, 0) x - 6 >= 0,
703
+ An inequality (0, 0, 0, -1, 0) x + 5 >= 0,
704
+ An equation (1, 1, 1, 1, 1) x - 15 == 0)
705
+ sage: next(it).ambient_Hrepresentation()
706
+ (An inequality (0, 0, -1, -1, 0) x + 9 >= 0,
707
+ An inequality (0, 0, 0, -1, 0) x + 5 >= 0,
708
+ An equation (1, 1, 1, 1, 1) x - 15 == 0)
709
+
710
+ sage: P = polytopes.cyclic_polytope(4,6)
711
+ sage: C = CombinatorialPolyhedron(P)
712
+ sage: it = C.face_generator()
713
+ sage: next(it).ambient_Hrepresentation()
714
+ (An inequality (-20, 29, -10, 1) x + 0 >= 0,
715
+ An inequality (60, -47, 12, -1) x + 0 >= 0,
716
+ An inequality (30, -31, 10, -1) x + 0 >= 0,
717
+ An inequality (10, -17, 8, -1) x + 0 >= 0,
718
+ An inequality (-154, 71, -14, 1) x + 120 >= 0,
719
+ An inequality (-78, 49, -12, 1) x + 40 >= 0)
720
+ sage: next(it).ambient_Hrepresentation()
721
+ (An inequality (-50, 35, -10, 1) x + 24 >= 0,
722
+ An inequality (-12, 19, -8, 1) x + 0 >= 0,
723
+ An inequality (-20, 29, -10, 1) x + 0 >= 0,
724
+ An inequality (60, -47, 12, -1) x + 0 >= 0,
725
+ An inequality (-154, 71, -14, 1) x + 120 >= 0,
726
+ An inequality (-78, 49, -12, 1) x + 40 >= 0)
727
+
728
+ .. SEEALSO::
729
+
730
+ :meth:`ambient_H_indices`.
731
+ """
732
+ if not self._ambient_facets:
733
+ # There are no names, so we return indices instead.
734
+ return self.ambient_H_indices()
735
+ cdef size_t length
736
+ if not self._dual:
737
+ # if not dual, the facet-representation corresponds to the coatom-representation
738
+ length = self.set_coatom_rep() # fill self.coatom_repr_face
739
+ return tuple(self._ambient_facets[self.coatom_rep[i]]
740
+ for i in range(length)) + self._equations
741
+ else:
742
+ # if dual, the facet-representation corresponds to the atom-representation
743
+ length = self.set_atom_rep() # fill self.atom_repr_face
744
+ return tuple(self._ambient_facets[self.atom_rep[i]]
745
+ for i in range(length)) + self._equations
746
+
747
+ def ambient_H_indices(self, add_equations=True):
748
+ r"""
749
+ Return the indices of the Hrepresentation objects
750
+ of the ambient polyhedron defining the face.
751
+
752
+ INPUT:
753
+
754
+ - ``add_equations`` -- boolean (default: ``True``); whether or not to include the equations
755
+
756
+ EXAMPLES::
757
+
758
+ sage: # needs sage.combinat
759
+ sage: P = polytopes.permutahedron(5)
760
+ sage: C = CombinatorialPolyhedron(P)
761
+ sage: it = C.face_generator(2)
762
+ sage: face = next(it)
763
+ sage: face.ambient_H_indices(add_equations=False)
764
+ (28, 29)
765
+ sage: face2 = next(it)
766
+ sage: face2.ambient_H_indices(add_equations=False)
767
+ (25, 29)
768
+
769
+ Add the indices of the equation::
770
+
771
+ sage: face.ambient_H_indices(add_equations=True) # needs sage.combinat
772
+ (28, 29, 30)
773
+ sage: face2.ambient_H_indices(add_equations=True) # needs sage.combinat
774
+ (25, 29, 30)
775
+
776
+ Another example::
777
+
778
+ sage: P = polytopes.cyclic_polytope(4,6)
779
+ sage: C = CombinatorialPolyhedron(P)
780
+ sage: it = C.face_generator()
781
+ sage: _ = next(it); _ = next(it)
782
+ sage: next(it).ambient_H_indices()
783
+ (0, 1, 2, 4, 5, 7)
784
+ sage: next(it).ambient_H_indices()
785
+ (0, 1, 5, 6, 7, 8)
786
+ sage: next(it).ambient_H_indices()
787
+ (0, 1, 2, 3, 6, 8)
788
+ sage: [next(it).dimension() for _ in range(2)]
789
+ [0, 1]
790
+ sage: face = next(it)
791
+ sage: face.ambient_H_indices()
792
+ (4, 5, 7)
793
+
794
+ .. SEEALSO::
795
+
796
+ :meth:`ambient_Hrepresentation`.
797
+ """
798
+ cdef size_t length, i
799
+ cdef tuple equations
800
+
801
+ if add_equations and self._equations:
802
+ equations = tuple(smallInteger(i)
803
+ for i in range(self._n_ambient_facets,
804
+ self._n_ambient_facets + self._n_equations))
805
+ else:
806
+ equations = ()
807
+
808
+ if not self._dual:
809
+ # if not dual, the facet-representation corresponds to the coatom-representation
810
+ length = self.set_coatom_rep() # fill self.coatom_repr_face
811
+ return tuple(smallInteger(self.coatom_rep[i])
812
+ for i in range(length)) + equations
813
+ else:
814
+ # if dual, the facet-representation corresponds to the atom-representation
815
+ length = self.set_atom_rep() # fill self.atom_repr_face
816
+ return tuple(smallInteger(self.atom_rep[i])
817
+ for i in range(length)) + equations
818
+
819
+ def n_ambient_Hrepresentation(self, add_equations=True):
820
+ r"""
821
+ Return the length of the :meth:`CombinatorialFace.ambient_H_indices`.
822
+
823
+ Might be faster than then using ``len``.
824
+
825
+ INPUT:
826
+
827
+ - ``add_equations`` -- boolean (default: ``True``); whether or not to count the equations
828
+
829
+ EXAMPLES::
830
+
831
+ sage: P = polytopes.cube()
832
+ sage: C = CombinatorialPolyhedron(P)
833
+ sage: it = C.face_generator()
834
+ sage: all(face.n_ambient_Hrepresentation() == len(face.ambient_Hrepresentation()) for face in it)
835
+ True
836
+
837
+ Specifying whether to count the equations or not::
838
+
839
+ sage: # needs sage.combinat
840
+ sage: P = polytopes.permutahedron(5)
841
+ sage: C = CombinatorialPolyhedron(P)
842
+ sage: it = C.face_generator(2)
843
+ sage: f = next(it)
844
+ sage: f.n_ambient_Hrepresentation(add_equations=True)
845
+ 3
846
+ sage: f.n_ambient_Hrepresentation(add_equations=False)
847
+ 2
848
+
849
+ TESTS::
850
+
851
+ sage: P = polytopes.cube()
852
+ sage: C = CombinatorialPolyhedron(P)
853
+ sage: it = C.face_generator()
854
+ sage: face = next(it)
855
+ """
856
+ cdef size_t n_equations = self._n_equations if add_equations else 0
857
+ if not self._dual:
858
+ return smallInteger(self.set_coatom_rep() + n_equations)
859
+ else:
860
+ return smallInteger(self.n_atom_rep() + n_equations)
861
+
862
+ def as_combinatorial_polyhedron(self, quotient=False):
863
+ r"""
864
+ Return ``self`` as combinatorial polyhedron.
865
+
866
+ If ``quotient`` is ``True``, return the quotient of the
867
+ polyhedron by ``self``.
868
+ Let ``G`` be the face corresponding to ``self`` in the dual/polar polytope.
869
+ The ``quotient`` is the dual/polar of ``G``.
870
+
871
+ Let `[\hat{0}, \hat{1}]` be the face lattice of the ambient polyhedron
872
+ and `F` be ``self`` as element of the face lattice.
873
+ The face lattice of ``self`` as polyhedron corresponds to
874
+ `[\hat{0}, F]` and the face lattice of the quotient by ``self``
875
+ corresponds to `[F, \hat{1}]`.
876
+
877
+ EXAMPLES::
878
+
879
+ sage: P = polytopes.cyclic_polytope(7,11)
880
+ sage: C = CombinatorialPolyhedron(P)
881
+ sage: it = C.face_generator(4)
882
+ sage: f = next(it); f
883
+ A 4-dimensional face of a 7-dimensional combinatorial polyhedron
884
+ sage: F = f.as_combinatorial_polyhedron(); F
885
+ A 4-dimensional combinatorial polyhedron with 5 facets
886
+ sage: F.f_vector()
887
+ (1, 5, 10, 10, 5, 1)
888
+ sage: F_alt = polytopes.cyclic_polytope(4,5).combinatorial_polyhedron()
889
+ sage: F_alt.vertex_facet_graph().is_isomorphic(F.vertex_facet_graph()) # needs sage.graphs
890
+ True
891
+
892
+ Obtaining the quotient::
893
+
894
+ sage: Q = f.as_combinatorial_polyhedron(quotient=True); Q
895
+ A 2-dimensional combinatorial polyhedron with 6 facets
896
+ sage: Q
897
+ A 2-dimensional combinatorial polyhedron with 6 facets
898
+ sage: Q.f_vector()
899
+ (1, 6, 6, 1)
900
+
901
+ The Vrepresentation of the face as polyhedron is given by the
902
+ ambient Vrepresentation of the face in that order::
903
+
904
+ sage: P = polytopes.cube()
905
+ sage: C = CombinatorialPolyhedron(P)
906
+ sage: it = C.face_generator(2)
907
+ sage: f = next(it)
908
+ sage: F = f.as_combinatorial_polyhedron()
909
+ sage: C.Vrepresentation()
910
+ (A vertex at (1, -1, -1),
911
+ A vertex at (1, 1, -1),
912
+ A vertex at (1, 1, 1),
913
+ A vertex at (1, -1, 1),
914
+ A vertex at (-1, -1, 1),
915
+ A vertex at (-1, -1, -1),
916
+ A vertex at (-1, 1, -1),
917
+ A vertex at (-1, 1, 1))
918
+ sage: f.ambient_Vrepresentation()
919
+ (A vertex at (1, -1, -1),
920
+ A vertex at (1, -1, 1),
921
+ A vertex at (-1, -1, 1),
922
+ A vertex at (-1, -1, -1))
923
+ sage: F.Vrepresentation()
924
+ (0, 1, 2, 3)
925
+
926
+ To obtain the facets of the face as polyhedron,
927
+ we compute the meet of each facet with the face.
928
+ The first representative of each element strictly
929
+ contained in the face is kept::
930
+
931
+ sage: C.facets(names=False)
932
+ ((0, 1, 2, 3),
933
+ (1, 2, 6, 7),
934
+ (2, 3, 4, 7),
935
+ (4, 5, 6, 7),
936
+ (0, 1, 5, 6),
937
+ (0, 3, 4, 5))
938
+ sage: F.facets(names=False)
939
+ ((0, 1), (1, 2), (2, 3), (0, 3))
940
+
941
+ The Hrepresentation of the quotient by the face is given by the
942
+ ambient Hrepresentation of the face in that order::
943
+
944
+ sage: it = C.face_generator(1)
945
+ sage: f = next(it)
946
+ sage: Q = f.as_combinatorial_polyhedron(quotient=True)
947
+ sage: C.Hrepresentation()
948
+ (An inequality (-1, 0, 0) x + 1 >= 0,
949
+ An inequality (0, -1, 0) x + 1 >= 0,
950
+ An inequality (0, 0, -1) x + 1 >= 0,
951
+ An inequality (1, 0, 0) x + 1 >= 0,
952
+ An inequality (0, 0, 1) x + 1 >= 0,
953
+ An inequality (0, 1, 0) x + 1 >= 0)
954
+ sage: f.ambient_Hrepresentation()
955
+ (An inequality (0, 0, 1) x + 1 >= 0, An inequality (0, 1, 0) x + 1 >= 0)
956
+ sage: Q.Hrepresentation()
957
+ (0, 1)
958
+
959
+ To obtain the vertices of the face as polyhedron,
960
+ we compute the join of each vertex with the face.
961
+ The first representative of each element strictly
962
+ containing the face is kept::
963
+
964
+ sage: [g.ambient_H_indices() for g in C.face_generator(0)]
965
+ [(3, 4, 5),
966
+ (0, 4, 5),
967
+ (2, 3, 5),
968
+ (0, 2, 5),
969
+ (1, 3, 4),
970
+ (0, 1, 4),
971
+ (1, 2, 3),
972
+ (0, 1, 2)]
973
+ sage: [g.ambient_H_indices() for g in Q.face_generator(0)]
974
+ [(1,), (0,)]
975
+
976
+ The method is not implemented for unbounded polyhedra::
977
+
978
+ sage: P = Polyhedron(rays=[[0,1]])*polytopes.cube()
979
+ sage: C = CombinatorialPolyhedron(P)
980
+ sage: it = C.face_generator(2)
981
+ sage: f = next(it)
982
+ sage: f.as_combinatorial_polyhedron()
983
+ Traceback (most recent call last):
984
+ ...
985
+ NotImplementedError: only implemented for bounded polyhedra
986
+
987
+ REFERENCES:
988
+
989
+ For more information, see Exercise 2.9 of [Zie2007]_.
990
+
991
+ .. NOTE::
992
+
993
+ This method is tested in
994
+ :meth:`~sage.geometry.polyhedron.base.Polyhedron_base._test_combinatorial_face_as_combinatorial_polyhedron`.
995
+ """
996
+ if not self._ambient_bounded:
997
+ raise NotImplementedError("only implemented for bounded polyhedra")
998
+
999
+ cdef ListOfFaces facets = self.atoms if self._dual else self.coatoms
1000
+ cdef ListOfFaces Vrep = self.atoms if not self._dual else self.coatoms
1001
+
1002
+ if not quotient:
1003
+ return CombinatorialPolyhedron(face_as_combinatorial_polyhedron(facets, Vrep, self.face, self._dual))
1004
+ else:
1005
+ # We run ``face_as_combinatorial_polyhedron`` for the dual setting.
1006
+
1007
+ # We then interchange the output of it, to obtain the quotient.
1008
+ new_Vrep, new_facets = face_as_combinatorial_polyhedron(Vrep, facets, self.face, not self._dual)
1009
+ return CombinatorialPolyhedron((new_facets, new_Vrep))
1010
+
1011
+ cdef size_t n_atom_rep(self) except -1:
1012
+ r"""
1013
+ Compute the number of atoms in the current face by counting the
1014
+ number of set bits.
1015
+ """
1016
+ if self.atom_rep is not NULL:
1017
+ return self._n_atom_rep
1018
+ return face_len_atoms(self.face)
1019
+
1020
+ cdef size_t set_coatom_rep(self) except -1:
1021
+ r"""
1022
+ Set ``coatom_rep`` to be the coatom-representation of the current face.
1023
+ Return its length.
1024
+ """
1025
+ if self.coatom_rep is NULL:
1026
+ self.coatom_rep = <size_t *> check_allocarray(self.coatoms.n_faces(), sizeof(size_t))
1027
+ self._n_coatom_rep = bit_rep_to_coatom_rep(self.face, self.coatoms.data, self.coatom_rep)
1028
+ return self._n_coatom_rep
1029
+
1030
+ cdef size_t set_atom_rep(self) except -1:
1031
+ r"""
1032
+ Set ``atom_rep`` to be the atom-representation of the current face.
1033
+ Return its length.
1034
+ """
1035
+ if self.atom_rep is NULL:
1036
+ self.atom_rep = <size_t *> check_allocarray(self.coatoms.n_atoms(), sizeof(size_t))
1037
+ self._n_atom_rep = bit_rep_to_Vrep_list(self.face, self.atom_rep)
1038
+ return self._n_atom_rep