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,560 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ r"""
3
+ PolyhedronFaceLattice
4
+
5
+ This module provides a class that stores and sorts all faces of the polyhedron.
6
+
7
+ :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron` implicitly uses this class to generate
8
+ the face lattice of a polyhedron.
9
+
10
+ Terminology in this module:
11
+
12
+ - Vrep -- ``[vertices, rays, lines]`` of the polyhedron
13
+
14
+ - Hrep -- inequalities and equations of the polyhedron
15
+
16
+ - Facets -- facets of the polyhedron
17
+
18
+ - Coatoms -- the faces from which all others are constructed in the face
19
+ iterator. This will be facets or Vrep. In non-dual mode, faces are
20
+ constructed as intersections of the facets. In dual mode, the are constructed
21
+ theoretically as joins of vertices. The coatoms are represented as incidences
22
+ with the atoms they contain.
23
+
24
+ - Atoms -- facets or Vrep depending on application of algorithm. Atoms are
25
+ represented as incidences of coatoms they are contained in.
26
+
27
+ - Vrepresentation -- represents a face by a list of Vrep it contains
28
+
29
+ - Hrepresentation -- represents a face by a list of Hrep it is contained in
30
+
31
+ - bit representation -- represents incidences as ``uint64_t``-array, where each
32
+ bit represents one incidence. There might be trailing zeros, to fit alignment
33
+ requirements. In most instances, faces are represented by the bit
34
+ representation, where each bit corresponds to an atom.
35
+
36
+ EXAMPLES::
37
+
38
+ sage: from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice \
39
+ ....: import PolyhedronFaceLattice
40
+ sage: P = polytopes.octahedron()
41
+ sage: C = CombinatorialPolyhedron(P)
42
+ sage: all_faces = PolyhedronFaceLattice(C)
43
+
44
+ .. SEEALSO::
45
+
46
+ :mod:`~sage.geometry.polyhedron.combinatorial_polyhedron.base`,
47
+ :class:`PolyhedronFaceLattice`.
48
+
49
+ AUTHOR:
50
+
51
+ - Jonathan Kliem (2019-04)
52
+ """
53
+
54
+ # ****************************************************************************
55
+ # Copyright (C) 2019 Jonathan Kliem <jonathan.kliem@gmail.com>
56
+ #
57
+ # This program is free software: you can redistribute it and/or modify
58
+ # it under the terms of the GNU General Public License as published by
59
+ # the Free Software Foundation, either version 2 of the License, or
60
+ # (at your option) any later version.
61
+ # https://www.gnu.org/licenses/
62
+ # ****************************************************************************
63
+
64
+ from .conversions import (facets_tuple_to_bit_rep_of_facets,
65
+ facets_tuple_to_bit_rep_of_Vrep)
66
+
67
+ from sage.geometry.polyhedron.combinatorial_polyhedron.conversions cimport bit_rep_to_Vrep_list
68
+
69
+ from sage.geometry.polyhedron.combinatorial_polyhedron.base cimport CombinatorialPolyhedron
70
+ from sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator cimport FaceIterator
71
+ from sage.geometry.polyhedron.combinatorial_polyhedron.face_list_data_structure cimport *
72
+
73
+
74
+ cdef extern from "Python.h":
75
+ int unlikely(int) nogil # Defined by Cython
76
+
77
+ cdef class PolyhedronFaceLattice:
78
+ r"""
79
+ A class to generate incidences of :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron`.
80
+
81
+ On initialization all faces of the given :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron`
82
+ are added and sorted (except coatoms). The incidences can be used to
83
+ generate the ``face_lattice``.
84
+
85
+ Might generate the faces of the dual polyhedron for speed.
86
+
87
+ INPUT:
88
+
89
+ - :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.baseCombinatorialPolyhedron`
90
+
91
+ .. SEEALSO::
92
+
93
+ :meth:`~sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron._record_all_faces`,
94
+ :meth:`~sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron._record_all_faces_helper`,
95
+ :meth:`~sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron.face_lattice`,
96
+ :meth:`~sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron._compute_face_lattice_incidences`.
97
+
98
+ EXAMPLES::
99
+
100
+ sage: P = polytopes.Birkhoff_polytope(3)
101
+ sage: C = CombinatorialPolyhedron(P)
102
+ sage: C._record_all_faces() # indirect doctests
103
+ sage: C.face_lattice() # needs sage.combinat
104
+ Finite lattice containing 50 elements
105
+
106
+ ALGORITHM:
107
+
108
+ The faces are recorded with :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator.FaceIterator` in Bit-representation.
109
+ Once created, all level-sets but the coatoms are sorted with merge sort.
110
+ Non-trivial incidences of elements whose rank differs by 1 are determined
111
+ by intersecting with all coatoms. Then each intersection is looked up in
112
+ the sorted level sets.
113
+ """
114
+ def __cinit__(self, CombinatorialPolyhedron C):
115
+ r"""
116
+ Initialize :class:`PolyhedronFaceLattice`.
117
+
118
+ See :class:`PolyhedronFaceLattice`.
119
+
120
+ TESTS:
121
+
122
+ Not initializing the class, does not give segmentation fault::
123
+
124
+ sage: from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice import PolyhedronFaceLattice
125
+ sage: P = polytopes.cube()
126
+ sage: F = PolyhedronFaceLattice.__new__(PolyhedronFaceLattice, P.combinatorial_polyhedron())
127
+ sage: F.get_face(2, 3)
128
+ A 2-dimensional face of a 3-dimensional combinatorial polyhedron
129
+ """
130
+ # Note that all values are set to zero at the time ``__cinit__`` is called:
131
+ # https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#initialisation-methods
132
+ # In particular, ``__dealloc__`` will not do harm in this case.
133
+
134
+ cdef int i
135
+ cdef size_t j
136
+
137
+ self.dimension = C.dimension()
138
+ self.dual = False
139
+ if C.bitrep_facets().n_faces() > C.bitrep_Vrep().n_faces():
140
+ self.dual = True
141
+ if not C.is_bounded():
142
+ self.dual = False
143
+ cdef FaceIterator face_iter = C._face_iter(self.dual, -2)
144
+ self._Vrep = C.Vrep()
145
+ self._facet_names = C.facet_names()
146
+ self._equations = C.equations()
147
+ self._bounded = C.is_bounded()
148
+
149
+ # copy f_vector for later use
150
+ f_vector = C.f_vector()
151
+ self.f_vector = <size_t *> check_allocarray(self.dimension + 2, sizeof(size_t))
152
+ if self.dual:
153
+ for i in range(-1, self.dimension + 1):
154
+ self.f_vector[i+1] = f_vector[-i-2]
155
+ else:
156
+ for i in range(-1, self.dimension + 1):
157
+ self.f_vector[i+1] = f_vector[i+1]
158
+
159
+ # Initialize atoms, coatoms, ``atom_rep`` and ``coatom_rep``.
160
+ if self.dimension == 0:
161
+ # In case of the 0-dimensional polyhedron, we have to fix atoms and coatoms.
162
+ # So far this didn't matter, as we only iterated over proper faces.
163
+ self.atoms = facets_tuple_to_bit_rep_of_Vrep(((),), 1)
164
+ self.coatoms = facets_tuple_to_bit_rep_of_facets(((),), 1)
165
+ else:
166
+ self.atoms = face_iter.atoms
167
+ self.coatoms = face_iter.coatoms
168
+
169
+ self.atom_rep = <size_t *> check_allocarray(self.coatoms.n_atoms(), sizeof(size_t))
170
+ self.coatom_rep = <size_t *> check_allocarray(self.coatoms.n_faces(), sizeof(size_t))
171
+
172
+ # Setting up a pointer to raw data of ``faces``:
173
+ self.faces = <face_list_t*> check_calloc(self.dimension + 2, sizeof(face_list_t))
174
+
175
+ for i in range(self.dimension + 2):
176
+ face_list_init(self.faces[i], self.f_vector[i],
177
+ self.coatoms.n_atoms(), self.coatoms.n_coatoms())
178
+
179
+ # The universe.
180
+ for j in range(self.coatoms.n_atoms()):
181
+ face_add_atom(self.faces[self.dimension+1].faces[0], j)
182
+
183
+ # The coatoms.
184
+ if self.dimension > 0:
185
+ # Note that in the other cases, this was fully initialized above.
186
+ face_list_copy(self.faces[self.dimension], self.coatoms.data)
187
+
188
+ # Attributes for iterating over the incidences.
189
+ face_init(self.incidence_face, self.coatoms.n_atoms(), self.coatoms.n_coatoms())
190
+
191
+ # Adding all faces, using the iterator.
192
+ for i in range(1, self.dimension):
193
+ self.faces[i].n_faces = 0
194
+
195
+ cdef int d
196
+ if face_iter.structure.current_dimension != self.dimension:
197
+ # If there are proper faces.
198
+ d = face_iter.next_dimension()
199
+ while (d == self.dimension - 1):
200
+ # We already have the coatoms.
201
+ d = face_iter.next_dimension()
202
+ while (d < self.dimension):
203
+ add_face_deep(self.faces[d+1], face_iter.structure.face)
204
+ d = face_iter.next_dimension()
205
+
206
+ def __init__(self, CombinatorialPolyhedron C):
207
+ r"""
208
+ Initialize :class:`PolyhedronFaceLattice`.
209
+
210
+ See :class:`PolyhedronFaceLattice`.
211
+
212
+ EXAMPLES::
213
+
214
+ sage: P = polytopes.cube()
215
+ sage: C = CombinatorialPolyhedron(P)
216
+ sage: C._record_all_faces() # indirect doctests
217
+ sage: C.face_lattice() # needs sage.combinat
218
+ Finite lattice containing 28 elements
219
+
220
+ sage: TestSuite(sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice.PolyhedronFaceLattice).run()
221
+ """
222
+ # Sorting the faces, except for coatoms.
223
+ self._sort()
224
+
225
+ def __dealloc__(self):
226
+ """
227
+ TESTS::
228
+
229
+ sage: from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice import PolyhedronFaceLattice
230
+ sage: PolyhedronFaceLattice() # indirect doctest
231
+ Traceback (most recent call last):
232
+ ...
233
+ TypeError: __cinit__() takes exactly 1 positional argument (0 given)
234
+ """
235
+ cdef int i
236
+ sig_free(self.f_vector)
237
+ sig_free(self.atom_rep)
238
+ sig_free(self.coatom_rep)
239
+ if self.faces:
240
+ for i in range(self.dimension + 2):
241
+ face_list_free(self.faces[i])
242
+ sig_free(self.faces)
243
+ face_free(self.incidence_face)
244
+
245
+ cdef int _sort(self) except -1:
246
+ r"""
247
+ Sort each list of ``self.faces`` (except for coatoms).
248
+
249
+ This method is used on initialization only.
250
+ """
251
+ cdef int dim = self.dimension
252
+ cdef int i
253
+ for i in range(dim + 2):
254
+ if unlikely(self.f_vector[i] != self.faces[i].n_faces):
255
+ raise ValueError("``PolyhedronFaceLattice`` does not contain all faces")
256
+
257
+ for i in range(dim - 1):
258
+ # Sort each level set, except for the facets, the full- and empty polyhedron.
259
+ sort_faces_list(self.faces[i+1])
260
+
261
+ def _find_face_from_combinatorial_face(self, CombinatorialFace face):
262
+ r"""
263
+ A method to test :meth:`find_face`.
264
+
265
+ ``f`` must be a face in dual mode if and only if ``self`` is in dual mode.
266
+
267
+ TESTS::
268
+
269
+ sage: from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice \
270
+ ....: import PolyhedronFaceLattice
271
+ sage: P = polytopes.hypercube(4)
272
+ sage: C = CombinatorialPolyhedron(P)
273
+ sage: F = PolyhedronFaceLattice(C)
274
+ sage: it = C.face_generator()
275
+ sage: face = next(it)
276
+ sage: F._find_face_from_combinatorial_face(face)
277
+ Traceback (most recent call last):
278
+ ...
279
+ ValueError: cannot find a facet, as those are not sorted
280
+
281
+ """
282
+ if not (self.dual == face._dual):
283
+ raise ValueError("iterator and allfaces not in same mode")
284
+ cdef size_t face_index = self.find_face(face.dimension(), face.face)
285
+ if face_index == -1:
286
+ raise ValueError("face is not in the face lattice")
287
+ return face_index
288
+
289
+ cdef inline size_t find_face(self, int dimension, face_t face) except -2:
290
+ r"""
291
+ Return the index of ``face``, if it is of dimension ``dimension``.
292
+
293
+ Return -1 if the face is not contained.
294
+
295
+ EXAMPLES::
296
+
297
+ sage: from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice \
298
+ ....: import PolyhedronFaceLattice
299
+ sage: P = polytopes.permutahedron(4)
300
+ sage: C = CombinatorialPolyhedron(P)
301
+ sage: F = PolyhedronFaceLattice(C)
302
+ sage: it = C.face_generator(dimension=1)
303
+ sage: S = set(F._find_face_from_combinatorial_face(f) for f in it)
304
+ sage: S == set(range(36))
305
+ True
306
+ """
307
+ if unlikely(dimension == self.dimension -1):
308
+ raise ValueError("cannot find a facet, as those are not sorted")
309
+ # of course one can easily add a function to search for a facet as
310
+ # well, but there seems to be no need for that
311
+
312
+ if unlikely(dimension < -1 or dimension > self.dimension):
313
+ raise IndexError("dimension out of range")
314
+
315
+ return find_face(face, self.faces[dimension+1])
316
+
317
+ cpdef CombinatorialFace get_face(self, int dimension, size_t index):
318
+ r"""
319
+ Return the face of dimension ``dimension`` and index ``index``.
320
+
321
+ INPUT:
322
+
323
+ - ``dimension`` -- dimension of the face
324
+ - ``index`` -- index of the face
325
+ - ``names`` -- if ``True`` returns the names of the ``[vertices, rays, lines]``
326
+ as given on initialization of :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron`
327
+
328
+ EXAMPLES::
329
+
330
+ sage: from sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice \
331
+ ....: import PolyhedronFaceLattice
332
+ sage: P = polytopes.permutahedron(4)
333
+ sage: C = CombinatorialPolyhedron(P)
334
+ sage: F = PolyhedronFaceLattice(C)
335
+ sage: it = C.face_generator(dimension=1)
336
+ sage: face = next(it)
337
+ sage: index = F._find_face_from_combinatorial_face(face)
338
+ sage: F.get_face(face.dimension(), index).ambient_Vrepresentation()
339
+ (A vertex at (2, 1, 4, 3), A vertex at (1, 2, 4, 3))
340
+ sage: face.ambient_Vrepresentation()
341
+ (A vertex at (2, 1, 4, 3), A vertex at (1, 2, 4, 3))
342
+ sage: all(F.get_face(face.dimension(),
343
+ ....: F._find_face_from_combinatorial_face(face)).ambient_Vrepresentation() ==
344
+ ....: face.ambient_Vrepresentation() for face in it)
345
+ True
346
+
347
+ sage: P = polytopes.twenty_four_cell()
348
+ sage: C = CombinatorialPolyhedron(P)
349
+ sage: F = PolyhedronFaceLattice(C)
350
+ sage: it = C.face_generator()
351
+ sage: face = next(it)
352
+ sage: while (face.dimension() == 3): face = next(it)
353
+ sage: index = F._find_face_from_combinatorial_face(face)
354
+ sage: F.get_face(face.dimension(), index).ambient_Vrepresentation()
355
+ (A vertex at (-1/2, 1/2, -1/2, -1/2),
356
+ A vertex at (-1/2, 1/2, 1/2, -1/2),
357
+ A vertex at (0, 0, 0, -1))
358
+ sage: all(F.get_face(face.dimension(),
359
+ ....: F._find_face_from_combinatorial_face(face)).ambient_V_indices() ==
360
+ ....: face.ambient_V_indices() for face in it)
361
+ True
362
+ """
363
+ if self.dual:
364
+ # if dual, the Vrepresentation corresponds to the coatom-representation
365
+ dimension = self.dimension - 1 - dimension # if dual, the dimensions are reversed
366
+ return CombinatorialFace(self, dimension=dimension, index=index)
367
+
368
+ cdef size_t set_coatom_rep(self, int dimension, size_t index) except -1:
369
+ r"""
370
+ Set ``atom_rep`` to be the atom-representation of the face
371
+ of dimension ``dimension`` and index ``index``.
372
+ Return its length.
373
+
374
+ This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_coatom_rep`
375
+ """
376
+ if unlikely(dimension < -1 or dimension > self.dimension):
377
+ raise ValueError("no face of dimension %s" % dimension)
378
+ if unlikely(index >= self.f_vector[dimension + 1]):
379
+ raise IndexError("no %s-th face of dimension %s" % (index, dimension))
380
+ if unlikely(self.coatoms.n_faces() == 0):
381
+ return 0
382
+
383
+ cdef face_t face = self.faces[dimension+1].faces[index]
384
+ return bit_rep_to_coatom_rep(face, self.coatoms.data, self.coatom_rep)
385
+
386
+ cdef size_t set_atom_rep(self, int dimension, size_t index) except -1:
387
+ r"""
388
+ Set ``atom_rep`` to be the atom-representation of the face
389
+ of dimension ``dimension`` and index ``index``.
390
+ Return its length.
391
+
392
+ This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_atom_rep`
393
+ """
394
+ if unlikely(dimension < -1 or dimension > self.dimension):
395
+ raise ValueError("no face of dimension %s" % dimension)
396
+ if unlikely(index >= self.f_vector[dimension + 1]):
397
+ raise IndexError("no %s-th face of dimension %s" % (index, dimension))
398
+
399
+ cdef face_t face = self.faces[dimension+1].faces[index]
400
+ return bit_rep_to_Vrep_list(face, self.atom_rep)
401
+
402
+ cdef void incidence_init(self, int dimension_one, int dimension_two) noexcept:
403
+ r"""
404
+ Initialize the :class:`PolyhedronFaceLattice` to give incidences between
405
+ ``dimension_one`` and ``dimension_two``.
406
+
407
+ This will enable :meth:`next_incidence` to give all such incidences.
408
+
409
+ Currently only ``dimension_one == dimension_two + 1`` and incidences
410
+ with empty and full polyhedron are implemented, which suffices for the
411
+ face-lattice.
412
+ """
413
+ if dimension_one == self.dimension:
414
+ # The full polyhedron is incident to every face.
415
+ if dimension_two < -1:
416
+ raise ValueError("no faces of dimension %s" % dimension_two)
417
+ if dimension_two > self.dimension:
418
+ raise ValueError("no faces of dimension %s" % dimension_two)
419
+ self.incidence_dim_one = dimension_one
420
+ self.incidence_dim_two = dimension_two
421
+ self.incidence_counter_one = 0
422
+ self.incidence_counter_two = 0
423
+ self.is_incidence_initialized = 2
424
+ return
425
+
426
+ if dimension_two == -1:
427
+ # The empty polyhedron is incident to every face.
428
+ if dimension_one < -1:
429
+ raise ValueError("no faces of dimension %s" % dimension_two)
430
+ if dimension_one > self.dimension:
431
+ raise ValueError("no faces of dimension %s" % dimension_two)
432
+ self.incidence_dim_one = dimension_one
433
+ self.incidence_dim_two = dimension_two
434
+ self.incidence_counter_one = 0
435
+ self.incidence_counter_two = 0
436
+ self.is_incidence_initialized = 3
437
+ return
438
+
439
+ if dimension_one != dimension_two + 1:
440
+ raise ValueError("``dimension_one = dimension_two`` + 1 must hold")
441
+ # At the moment, this is not implemented.
442
+
443
+ if dimension_one > self.dimension:
444
+ raise ValueError("no faces of dimension %s" % dimension_one)
445
+ if dimension_two < -1:
446
+ raise ValueError("no faces of dimension %s" % dimension_two)
447
+
448
+ self.incidence_dim_one = dimension_one
449
+ self.incidence_dim_two = dimension_two
450
+ self.incidence_counter_one = 0
451
+ self.incidence_counter_two = 0
452
+ self.is_incidence_initialized = 1
453
+
454
+ cdef inline bint next_incidence(self, size_t *one, size_t *two) noexcept:
455
+ r"""
456
+ Set ``one[0]`` and ``two[0]`` to be the next incidence. Return ``True``
457
+ unless there are no more incidences, then return `0`.
458
+
459
+ After initialization with :meth:`next_incidence`, this method will give
460
+ all incidences of faces of ``dimension_one`` and ``dimension_two``.
461
+ ``one[0]`` will represent the index of a face in ``dimension_one`` and
462
+ ``two[0]`` will represent the index of a face in ``dimension_two``
463
+ according to their order in :class:`PolyhedronFaceLattice`.
464
+
465
+ Use :meth:`Vrep` and :meth:`Hrep` to interpret the output.
466
+
467
+ ALGORITHM:
468
+
469
+ This is the algorithm for non-trivial cases:
470
+ ``0 < self.dimension_two + 1 == self.dimension_one < self.dimension``
471
+
472
+ We intersect each face of dimension ``incidence_dim_one`` with each
473
+ coatom. The result will be looked up in the ``incidence_dim_two`` faces.
474
+ """
475
+ cdef bint result = False
476
+ while ((not result)
477
+ and (self.incidence_counter_one < self.f_vector[self.incidence_dim_one + 1])):
478
+ # Calls next_incidence_loop, until it gives a result or
479
+ # until there are no more incidences.
480
+ result = self.next_incidence_loop(one, two)
481
+
482
+ return result
483
+
484
+ cdef inline bint next_incidence_loop(self, size_t *one, size_t *two) noexcept:
485
+ r"""
486
+ Set ``one[0]`` and ``two[0]`` to be the next incidence. Return ``True``
487
+ on success and ``False`` otherwise.
488
+
489
+ If it returns ``False``, it needs to be called again, unless
490
+ ``self.incidence_counter_one >= self.f_vector[self.incidence_dim_one + 1])``.
491
+
492
+ See :meth:`next_incidence`.
493
+ """
494
+ cdef face_list_t coatoms
495
+ coatoms[0] = self.coatoms.data[0]
496
+ cdef face_t dimension_one_face # depending on the index ``incidence_counter_one``
497
+
498
+ cdef size_t location # the index the intersection has, if of correct dimension
499
+ if self.is_incidence_initialized == 1:
500
+ # The standard case, where
501
+ # ``0 < self.dimension_two + 1 == self.dimension_one < self.dimension``.
502
+
503
+ one[0] = self.incidence_counter_one
504
+ dimension_one_face = self.faces[self.incidence_dim_one + 1].faces[self.incidence_counter_one]
505
+
506
+ # Get the intersection of ``dimension_one_face`` with the
507
+ # ``self.incidence_counter_two``-th coatom.
508
+ face_intersection(self.incidence_face, dimension_one_face,
509
+ coatoms.faces[self.incidence_counter_two])
510
+
511
+ # Get the location of the intersection and
512
+ # check whether it is correct.
513
+ location = self.find_face(self.incidence_dim_two, self.incidence_face)
514
+ two[0] = location
515
+
516
+ # Set counters for next function call.
517
+ self.incidence_counter_two += 1
518
+ if self.incidence_counter_two == self.f_vector[self.dimension]:
519
+ self.incidence_counter_one += 1
520
+ self.incidence_counter_two = 0
521
+ return location != -1
522
+
523
+ if self.is_incidence_initialized == 2:
524
+ # the case where ``dimension_one`` is dimension of polyhedron.
525
+ return self.next_trivial_incidence(one, two)
526
+
527
+ if self.is_incidence_initialized == 3:
528
+ # the case where ``dimension_two`` is `-1`.
529
+ return self.next_trivial_incidence2(one, two)
530
+
531
+ if self.is_incidence_initialized == 0:
532
+ return 0
533
+
534
+ cdef inline bint next_trivial_incidence(self, size_t *one, size_t *two) noexcept:
535
+ r"""
536
+ Handling the case where ``dimension_one`` is dimension of polyhedron.
537
+
538
+ See :meth:`next_incidence`.
539
+ """
540
+ one[0] = 0
541
+ two[0] = self.incidence_counter_two
542
+ self.incidence_counter_two += 1
543
+
544
+ # Once done, raising ``self.incidence_counter_one``, such that
545
+ # :meth:`next_incidence` recognizes that we are done.
546
+ if self.incidence_counter_two >= self.f_vector[self.incidence_dim_two + 1]:
547
+ self.incidence_counter_one += 1
548
+
549
+ return (two[0] < self.f_vector[self.incidence_dim_two + 1])
550
+
551
+ cdef inline bint next_trivial_incidence2(self, size_t *one, size_t *two) noexcept:
552
+ r"""
553
+ Handling the case where ``dimension_two`` is `-1`.
554
+
555
+ See :meth:`next_incidence`.
556
+ """
557
+ two[0] = 0
558
+ one[0] = self.incidence_counter_one
559
+ self.incidence_counter_one += 1
560
+ return (one[0] < self.f_vector[self.incidence_dim_one + 1])