passagemath-polyhedra 10.6.31rc3__cp314-cp314-macosx_13_0_arm64.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 (205) hide show
  1. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA +368 -0
  2. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA.bak +371 -0
  3. passagemath_polyhedra-10.6.31rc3.dist-info/RECORD +205 -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.dylibs/libgmp.10.dylib +0 -0
  7. sage/all__sagemath_polyhedra.py +50 -0
  8. sage/game_theory/all.py +8 -0
  9. sage/game_theory/catalog.py +6 -0
  10. sage/game_theory/catalog_normal_form_games.py +923 -0
  11. sage/game_theory/cooperative_game.py +844 -0
  12. sage/game_theory/matching_game.py +1181 -0
  13. sage/game_theory/normal_form_game.py +2697 -0
  14. sage/game_theory/parser.py +275 -0
  15. sage/geometry/all__sagemath_polyhedra.py +22 -0
  16. sage/geometry/cone.py +6940 -0
  17. sage/geometry/cone_catalog.py +847 -0
  18. sage/geometry/cone_critical_angles.py +1027 -0
  19. sage/geometry/convex_set.py +1119 -0
  20. sage/geometry/fan.py +3743 -0
  21. sage/geometry/fan_isomorphism.py +389 -0
  22. sage/geometry/fan_morphism.py +1884 -0
  23. sage/geometry/hasse_diagram.py +202 -0
  24. sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
  25. sage/geometry/hyperplane_arrangement/all.py +1 -0
  26. sage/geometry/hyperplane_arrangement/arrangement.py +3895 -0
  27. sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
  28. sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
  29. sage/geometry/hyperplane_arrangement/library.py +825 -0
  30. sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
  31. sage/geometry/hyperplane_arrangement/plot.py +520 -0
  32. sage/geometry/integral_points.py +35 -0
  33. sage/geometry/integral_points_generic_dense.cpython-314-darwin.so +0 -0
  34. sage/geometry/integral_points_generic_dense.pyx +7 -0
  35. sage/geometry/lattice_polytope.py +5894 -0
  36. sage/geometry/linear_expression.py +773 -0
  37. sage/geometry/newton_polygon.py +767 -0
  38. sage/geometry/point_collection.cpython-314-darwin.so +0 -0
  39. sage/geometry/point_collection.pyx +1008 -0
  40. sage/geometry/polyhedral_complex.py +2616 -0
  41. sage/geometry/polyhedron/all.py +8 -0
  42. sage/geometry/polyhedron/backend_cdd.py +460 -0
  43. sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
  44. sage/geometry/polyhedron/backend_field.py +347 -0
  45. sage/geometry/polyhedron/backend_normaliz.py +2503 -0
  46. sage/geometry/polyhedron/backend_number_field.py +168 -0
  47. sage/geometry/polyhedron/backend_polymake.py +765 -0
  48. sage/geometry/polyhedron/backend_ppl.py +582 -0
  49. sage/geometry/polyhedron/base.py +1206 -0
  50. sage/geometry/polyhedron/base0.py +1444 -0
  51. sage/geometry/polyhedron/base1.py +886 -0
  52. sage/geometry/polyhedron/base2.py +812 -0
  53. sage/geometry/polyhedron/base3.py +1845 -0
  54. sage/geometry/polyhedron/base4.py +1262 -0
  55. sage/geometry/polyhedron/base5.py +2700 -0
  56. sage/geometry/polyhedron/base6.py +1741 -0
  57. sage/geometry/polyhedron/base7.py +997 -0
  58. sage/geometry/polyhedron/base_QQ.py +1258 -0
  59. sage/geometry/polyhedron/base_RDF.py +98 -0
  60. sage/geometry/polyhedron/base_ZZ.py +934 -0
  61. sage/geometry/polyhedron/base_mutable.py +215 -0
  62. sage/geometry/polyhedron/base_number_field.py +122 -0
  63. sage/geometry/polyhedron/cdd_file_format.py +155 -0
  64. sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
  65. sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-darwin.so +0 -0
  66. sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
  67. sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
  68. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-darwin.so +0 -0
  69. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
  70. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
  71. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-darwin.so +0 -0
  72. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
  73. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
  74. sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
  75. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-darwin.so +0 -0
  76. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
  77. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
  78. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-darwin.so +0 -0
  79. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
  80. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
  81. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-darwin.so +0 -0
  82. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
  83. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
  84. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-darwin.so +0 -0
  85. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
  86. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
  87. sage/geometry/polyhedron/constructor.py +773 -0
  88. sage/geometry/polyhedron/double_description.py +753 -0
  89. sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
  90. sage/geometry/polyhedron/face.py +1060 -0
  91. sage/geometry/polyhedron/generating_function.py +1810 -0
  92. sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
  93. sage/geometry/polyhedron/library.py +3502 -0
  94. sage/geometry/polyhedron/misc.py +121 -0
  95. sage/geometry/polyhedron/modules/all.py +1 -0
  96. sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
  97. sage/geometry/polyhedron/palp_database.py +447 -0
  98. sage/geometry/polyhedron/parent.py +1279 -0
  99. sage/geometry/polyhedron/plot.py +1986 -0
  100. sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
  101. sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
  102. sage/geometry/polyhedron/representation.py +1723 -0
  103. sage/geometry/pseudolines.py +515 -0
  104. sage/geometry/relative_interior.py +445 -0
  105. sage/geometry/toric_plotter.py +1103 -0
  106. sage/geometry/triangulation/all.py +2 -0
  107. sage/geometry/triangulation/base.cpython-314-darwin.so +0 -0
  108. sage/geometry/triangulation/base.pyx +963 -0
  109. sage/geometry/triangulation/data.h +147 -0
  110. sage/geometry/triangulation/data.pxd +4 -0
  111. sage/geometry/triangulation/element.py +914 -0
  112. sage/geometry/triangulation/functions.h +10 -0
  113. sage/geometry/triangulation/functions.pxd +4 -0
  114. sage/geometry/triangulation/point_configuration.py +2256 -0
  115. sage/geometry/triangulation/triangulations.h +49 -0
  116. sage/geometry/triangulation/triangulations.pxd +7 -0
  117. sage/geometry/voronoi_diagram.py +319 -0
  118. sage/interfaces/all__sagemath_polyhedra.py +1 -0
  119. sage/interfaces/polymake.py +2028 -0
  120. sage/numerical/all.py +13 -0
  121. sage/numerical/all__sagemath_polyhedra.py +11 -0
  122. sage/numerical/backends/all.py +1 -0
  123. sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
  124. sage/numerical/backends/cvxopt_backend.cpython-314-darwin.so +0 -0
  125. sage/numerical/backends/cvxopt_backend.pyx +1006 -0
  126. sage/numerical/backends/cvxopt_backend_test.py +19 -0
  127. sage/numerical/backends/cvxopt_sdp_backend.cpython-314-darwin.so +0 -0
  128. sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
  129. sage/numerical/backends/cvxpy_backend.cpython-314-darwin.so +0 -0
  130. sage/numerical/backends/cvxpy_backend.pxd +41 -0
  131. sage/numerical/backends/cvxpy_backend.pyx +934 -0
  132. sage/numerical/backends/cvxpy_backend_test.py +13 -0
  133. sage/numerical/backends/generic_backend_test.py +24 -0
  134. sage/numerical/backends/interactivelp_backend.cpython-314-darwin.so +0 -0
  135. sage/numerical/backends/interactivelp_backend.pxd +36 -0
  136. sage/numerical/backends/interactivelp_backend.pyx +1231 -0
  137. sage/numerical/backends/interactivelp_backend_test.py +12 -0
  138. sage/numerical/backends/logging_backend.py +391 -0
  139. sage/numerical/backends/matrix_sdp_backend.cpython-314-darwin.so +0 -0
  140. sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
  141. sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
  142. sage/numerical/backends/ppl_backend.cpython-314-darwin.so +0 -0
  143. sage/numerical/backends/ppl_backend.pyx +1126 -0
  144. sage/numerical/backends/ppl_backend_test.py +13 -0
  145. sage/numerical/backends/scip_backend.cpython-314-darwin.so +0 -0
  146. sage/numerical/backends/scip_backend.pxd +22 -0
  147. sage/numerical/backends/scip_backend.pyx +1289 -0
  148. sage/numerical/backends/scip_backend_test.py +13 -0
  149. sage/numerical/interactive_simplex_method.py +5338 -0
  150. sage/numerical/knapsack.py +665 -0
  151. sage/numerical/linear_functions.cpython-314-darwin.so +0 -0
  152. sage/numerical/linear_functions.pxd +31 -0
  153. sage/numerical/linear_functions.pyx +1648 -0
  154. sage/numerical/linear_tensor.py +470 -0
  155. sage/numerical/linear_tensor_constraints.py +448 -0
  156. sage/numerical/linear_tensor_element.cpython-314-darwin.so +0 -0
  157. sage/numerical/linear_tensor_element.pxd +6 -0
  158. sage/numerical/linear_tensor_element.pyx +459 -0
  159. sage/numerical/mip.cpython-314-darwin.so +0 -0
  160. sage/numerical/mip.pxd +40 -0
  161. sage/numerical/mip.pyx +3667 -0
  162. sage/numerical/sdp.cpython-314-darwin.so +0 -0
  163. sage/numerical/sdp.pxd +39 -0
  164. sage/numerical/sdp.pyx +1433 -0
  165. sage/rings/all__sagemath_polyhedra.py +3 -0
  166. sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
  167. sage/rings/polynomial/omega.py +982 -0
  168. sage/schemes/all__sagemath_polyhedra.py +2 -0
  169. sage/schemes/toric/all.py +10 -0
  170. sage/schemes/toric/chow_group.py +1248 -0
  171. sage/schemes/toric/divisor.py +2082 -0
  172. sage/schemes/toric/divisor_class.cpython-314-darwin.so +0 -0
  173. sage/schemes/toric/divisor_class.pyx +322 -0
  174. sage/schemes/toric/fano_variety.py +1606 -0
  175. sage/schemes/toric/homset.py +650 -0
  176. sage/schemes/toric/ideal.py +451 -0
  177. sage/schemes/toric/library.py +1322 -0
  178. sage/schemes/toric/morphism.py +1958 -0
  179. sage/schemes/toric/points.py +1032 -0
  180. sage/schemes/toric/sheaf/all.py +1 -0
  181. sage/schemes/toric/sheaf/constructor.py +302 -0
  182. sage/schemes/toric/sheaf/klyachko.py +921 -0
  183. sage/schemes/toric/toric_subscheme.py +905 -0
  184. sage/schemes/toric/variety.py +3460 -0
  185. sage/schemes/toric/weierstrass.py +1078 -0
  186. sage/schemes/toric/weierstrass_covering.py +457 -0
  187. sage/schemes/toric/weierstrass_higher.py +288 -0
  188. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
  189. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
  190. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
  191. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
  192. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
  193. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
  194. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
  195. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
  196. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
  197. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
  198. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
  199. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
  200. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
  201. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
  202. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
  203. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
  204. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
  205. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_3d +37977 -0
@@ -0,0 +1,470 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ """
3
+ Matrix/Vector-Valued Linear Functions: Parents
4
+
5
+ In Sage, matrices assume that the base is a ring. Hence, we cannot
6
+ construct matrices whose entries are linear functions in Sage. Really,
7
+ they should be thought of as the tensor product of the `R`-module of
8
+ linear functions and the `R`-vector/matrix space, with the latter viewed
9
+ as an `R`-module (`R` is usually ``QQ`` or ``RDF`` for our purposes).
10
+
11
+ You should not construct any tensor products by calling the parent
12
+ directly. This is also why none of the classes are imported in the
13
+ global namespace. The come into play whenever you have vector or
14
+ matrix MIP linear expressions/constraints. The intended way to
15
+ construct them is implicitly by acting with vectors or matrices on
16
+ linear functions. For example::
17
+
18
+ sage: mip.<x> = MixedIntegerLinearProgram('ppl') # base ring is QQ
19
+ sage: 3 + x[0] + 2*x[1] # a linear function
20
+ 3 + x_0 + 2*x_1
21
+ sage: x[0] * vector([3,4]) + 1 # vector linear function
22
+ (1, 1) + (3, 4)*x_0
23
+ sage: x[0] * matrix([[3,1],[4,0]]) + 1 # matrix linear function
24
+ [1 + 3*x_0 x_0]
25
+ [4*x_0 1 ]
26
+
27
+ Internally, all linear functions are stored as a dictionary whose
28
+
29
+ * keys are the index of the linear variable (and -1 for the constant
30
+ term)
31
+
32
+ * values are the coefficient of that variable. That is, a number for
33
+ linear functions, a vector for vector-valued functions, etc.
34
+
35
+ The entire dictionary can be accessed with the
36
+ :meth:`~sage.numerical.linear_tensor_element.LinearTensor.dict`
37
+ method. For convenience, you can also retrieve a single coefficient
38
+ with
39
+ :meth:`~sage.numerical.linear_tensor_element.LinearTensor.coefficient`. For
40
+ example::
41
+
42
+ sage: mip.<b> = MixedIntegerLinearProgram()
43
+ sage: f_scalar = (3 + b[7] + 2*b[9]); f_scalar
44
+ 3 + x_0 + 2*x_1
45
+ sage: f_scalar.dict()
46
+ {-1: 3.0, 0: 1.0, 1: 2.0}
47
+ sage: f_scalar.dict()[1]
48
+ 2.0
49
+ sage: f_scalar.coefficient(b[9])
50
+ 2.0
51
+ sage: f_scalar.coefficient(1)
52
+ 2.0
53
+
54
+ sage: f_vector = b[7] * vector([3,4]) + 1; f_vector
55
+ (1.0, 1.0) + (3.0, 4.0)*x_0
56
+ sage: f_vector.coefficient(-1)
57
+ (1.0, 1.0)
58
+ sage: f_vector.coefficient(b[7])
59
+ (3.0, 4.0)
60
+ sage: f_vector.coefficient(0)
61
+ (3.0, 4.0)
62
+ sage: f_vector.coefficient(1)
63
+ (0.0, 0.0)
64
+
65
+ sage: f_matrix = b[7] * matrix([[0,1], [2,0]]) + b[9] - 3; f_matrix
66
+ [-3 + x_1 x_0 ]
67
+ [2*x_0 -3 + x_1]
68
+ sage: f_matrix.coefficient(-1)
69
+ [-3.0 0.0]
70
+ [ 0.0 -3.0]
71
+ sage: f_matrix.coefficient(0)
72
+ [0.0 1.0]
73
+ [2.0 0.0]
74
+ sage: f_matrix.coefficient(1)
75
+ [1.0 0.0]
76
+ [0.0 1.0]
77
+
78
+ Just like :mod:`sage.numerical.linear_functions`, (in)equalities
79
+ become symbolic inequalities. See
80
+ :mod:`~sage.numerical.linear_tensor_constraints` for details.
81
+
82
+ .. NOTE::
83
+
84
+ For brevity, we just use ``LinearTensor`` in class names. It is
85
+ understood that this refers to the above tensor product
86
+ construction.
87
+ """
88
+
89
+ # ***************************************************************************
90
+ # Copyright (C) 2014 Volker Braun <vbraun.name@gmail.com>
91
+ #
92
+ # Distributed under the terms of the GNU General Public License (GPL)
93
+ # as published by the Free Software Foundation; either version 2 of
94
+ # the License, or (at your option) any later version.
95
+ # https://www.gnu.org/licenses/
96
+ # ***************************************************************************
97
+
98
+
99
+ from copy import copy
100
+
101
+ from sage.structure.parent import Parent
102
+ from sage.misc.cachefunc import cached_function
103
+ from sage.numerical.linear_functions import LinearFunction, LinearFunctionsParent_class
104
+ from sage.numerical.linear_tensor_element import LinearTensor
105
+
106
+
107
+ #*****************************************************************************
108
+ #
109
+ # Utility functions to test that something is a linear function / constraint
110
+ #
111
+ #*****************************************************************************
112
+
113
+ def is_LinearTensor(x):
114
+ """
115
+ Test whether ``x`` is a tensor product of linear functions with a
116
+ free module.
117
+
118
+ INPUT:
119
+
120
+ - ``x`` -- anything
121
+
122
+ OUTPUT: boolean
123
+
124
+ EXAMPLES::
125
+
126
+ sage: p = MixedIntegerLinearProgram()
127
+ sage: x = p.new_variable(nonnegative=False)
128
+ sage: from sage.numerical.linear_tensor import is_LinearTensor
129
+ sage: is_LinearTensor(x[0] - 2*x[2])
130
+ doctest:warning...
131
+ DeprecationWarning: The function is_LinearTensor is deprecated;
132
+ use 'isinstance(..., LinearTensor)' instead.
133
+ See https://github.com/sagemath/sage/issues/38184 for details.
134
+ False
135
+ sage: is_LinearTensor('a string')
136
+ False
137
+ """
138
+ from sage.misc.superseded import deprecation
139
+ deprecation(38184,
140
+ "The function is_LinearTensor is deprecated; "
141
+ "use 'isinstance(..., LinearTensor)' instead.")
142
+ return isinstance(x, LinearTensor)
143
+
144
+
145
+ #*****************************************************************************
146
+ #
147
+ # Factory functions for the parents to ensure uniqueness
148
+ #
149
+ #*****************************************************************************
150
+
151
+ @cached_function
152
+ def LinearTensorParent(free_module_parent, linear_functions_parent):
153
+ """
154
+ Return the parent for the tensor product over the common ``base_ring``.
155
+
156
+ The output is cached, so only a single parent is ever constructed
157
+ for a given base ring.
158
+
159
+ INPUT:
160
+
161
+ - ``free_module_parent`` -- a free module, like vector or matrix space
162
+
163
+ - ``linear_functions_parent`` -- linear functions; the linear functions
164
+ parent
165
+
166
+ OUTPUT:
167
+
168
+ The parent of the tensor product of a free module and linear
169
+ functions over a common base ring.
170
+
171
+ EXAMPLES::
172
+
173
+ sage: from sage.numerical.linear_functions import LinearFunctionsParent
174
+ sage: from sage.numerical.linear_tensor import LinearTensorParent
175
+ sage: LinearTensorParent(QQ^3, LinearFunctionsParent(QQ))
176
+ Tensor product of Vector space of dimension 3 over Rational Field and Linear functions over Rational Field
177
+
178
+ sage: LinearTensorParent(ZZ^3, LinearFunctionsParent(QQ))
179
+ Traceback (most recent call last):
180
+ ...
181
+ ValueError: base rings must match
182
+ """
183
+ if free_module_parent.base_ring() != linear_functions_parent.base_ring():
184
+ raise ValueError('base rings must match')
185
+ if not isinstance(linear_functions_parent, LinearFunctionsParent_class):
186
+ raise TypeError('linear_functions_parent must be a parent of linear functions')
187
+ return LinearTensorParent_class(free_module_parent, linear_functions_parent)
188
+
189
+
190
+ # ****************************************************************************
191
+ #
192
+ # Parent of linear functions tensored with a free module
193
+ #
194
+ # ****************************************************************************
195
+
196
+ class LinearTensorParent_class(Parent):
197
+ r"""
198
+ The parent for all linear functions over a fixed base ring.
199
+
200
+ .. warning::
201
+
202
+ You should use :func:`LinearTensorParent` to construct
203
+ instances of this class.
204
+
205
+ INPUT/OUTPUT: see :func:`LinearTensorParent`
206
+
207
+ EXAMPLES::
208
+
209
+ sage: from sage.numerical.linear_tensor import LinearTensorParent_class
210
+ sage: LinearTensorParent_class
211
+ <class 'sage.numerical.linear_tensor.LinearTensorParent_class'>
212
+ """
213
+ Element = LinearTensor
214
+
215
+ def __init__(self, free_module, linear_functions):
216
+ """
217
+ The Python constructor.
218
+
219
+ INPUT/OUTPUT: see :func:`LinearTensorParent`
220
+
221
+ TESTS::
222
+
223
+ sage: from sage.numerical.linear_functions import LinearFunctionsParent
224
+ sage: LinearFunctionsParent(RDF).tensor(RDF^2)
225
+ Tensor product of Vector space of dimension 2 over Real Double
226
+ Field and Linear functions over Real Double Field
227
+ """
228
+ self._free_module = free_module
229
+ self._linear_functions = linear_functions
230
+ base_ring = linear_functions.base_ring()
231
+ from sage.categories.modules_with_basis import ModulesWithBasis
232
+ Parent.__init__(self, base=base_ring, category=ModulesWithBasis(base_ring))
233
+
234
+ def free_module(self):
235
+ """
236
+ Return the linear functions.
237
+
238
+ See also :meth:`free_module`.
239
+
240
+ OUTPUT:
241
+
242
+ Parent of the linear functions, one of the factors in the
243
+ tensor product construction.
244
+
245
+ EXAMPLES::
246
+
247
+ sage: mip.<x> = MixedIntegerLinearProgram()
248
+ sage: lt = x[0] * vector(RDF, [1,2])
249
+ sage: lt.parent().free_module()
250
+ Vector space of dimension 2 over Real Double Field
251
+ sage: lt.parent().free_module() is vector(RDF, [1,2]).parent()
252
+ True
253
+ """
254
+ return self._free_module
255
+
256
+ def is_vector_space(self):
257
+ """
258
+ Return whether the free module is a vector space.
259
+
260
+ OUTPUT: boolean; whether the :meth:`free_module` factor in the tensor
261
+ product is a vector space
262
+
263
+ EXAMPLES::
264
+
265
+ sage: mip = MixedIntegerLinearProgram()
266
+ sage: LF = mip.linear_functions_parent()
267
+ sage: LF.tensor(RDF^2).is_vector_space()
268
+ True
269
+ sage: LF.tensor(RDF^(2,2)).is_vector_space()
270
+ False
271
+ """
272
+ from sage.modules.free_module import FreeModule_generic
273
+ return isinstance(self.free_module(), FreeModule_generic)
274
+
275
+ def is_matrix_space(self):
276
+ """
277
+ Return whether the free module is a matrix space.
278
+
279
+ OUTPUT: boolean; whether the :meth:`free_module` factor in the tensor
280
+ product is a matrix space
281
+
282
+ EXAMPLES::
283
+
284
+ sage: mip = MixedIntegerLinearProgram()
285
+ sage: LF = mip.linear_functions_parent()
286
+ sage: LF.tensor(RDF^2).is_matrix_space()
287
+ False
288
+ sage: LF.tensor(RDF^(2,2)).is_matrix_space()
289
+ True
290
+ """
291
+ from sage.matrix.matrix_space import MatrixSpace
292
+ return isinstance(self.free_module(), MatrixSpace)
293
+
294
+ def linear_functions(self):
295
+ """
296
+ Return the linear functions.
297
+
298
+ See also :meth:`free_module`.
299
+
300
+ OUTPUT:
301
+
302
+ Parent of the linear functions, one of the factors in the
303
+ tensor product construction.
304
+
305
+ EXAMPLES::
306
+
307
+ sage: mip.<x> = MixedIntegerLinearProgram()
308
+ sage: lt = x[0] * vector([1,2])
309
+ sage: lt.parent().linear_functions()
310
+ Linear functions over Real Double Field
311
+ sage: lt.parent().linear_functions() is mip.linear_functions_parent()
312
+ True
313
+ """
314
+ return self._linear_functions
315
+
316
+ def _repr_(self):
317
+ """
318
+ Return a string representation.
319
+
320
+ OUTPUT: string
321
+
322
+ EXAMPLES::
323
+
324
+ sage: MixedIntegerLinearProgram().linear_functions_parent()
325
+ Linear functions over Real Double Field
326
+ """
327
+ return 'Tensor product of {0} and {1}'.format(self.free_module(), self.linear_functions())
328
+
329
+ def _convert_constant(self, m):
330
+ """
331
+ Convert ``m`` to a constant free module element.
332
+
333
+ OUTPUT: a :meth:`free_module` element
334
+
335
+ EXAMPLES::
336
+
337
+ sage: mip = MixedIntegerLinearProgram()
338
+ sage: LF = mip.linear_functions_parent()
339
+ sage: LF.tensor(RDF^2)._convert_constant(42)
340
+ (42.0, 42.0)
341
+ sage: LF.tensor(RDF^(2,2))._convert_constant(42)
342
+ [42.0 0.0]
343
+ [ 0.0 42.0]
344
+ """
345
+ M = self.free_module()
346
+ m = M.base_ring()(m)
347
+ if self.is_matrix_space():
348
+ # Turn constants into diagonal matrices
349
+ m_matrix = copy(M.zero_matrix())
350
+ for i in range(min(M.ncols(), M.nrows())):
351
+ m_matrix[i, i] = m
352
+ m_matrix.set_immutable()
353
+ return m_matrix
354
+ elif self.is_vector_space():
355
+ # Turn constants into vectors with all entries equal
356
+ m_vector = M([m] * M.degree())
357
+ return m_vector
358
+ else:
359
+ return M(m)
360
+
361
+ def _element_constructor_(self, x):
362
+ """
363
+ Construct a :class:`LinearTensor` from ``x``.
364
+
365
+ INPUT:
366
+
367
+ - ``x`` -- anything that defines a
368
+ :class:`~sage.numerical.linear_tensor_element.LinearTensor`. See
369
+ examples.
370
+
371
+ EXAMPLES::
372
+
373
+ sage: p = MixedIntegerLinearProgram()
374
+ sage: LT = p.linear_functions_parent().tensor(RDF^2)
375
+ sage: LT._element_constructor_(123)
376
+ (123.0, 123.0)
377
+
378
+ Construct from dict with type conversion to RDF vector::
379
+
380
+ sage: LT({1:[1, 2]}) # indirect doctest
381
+ (1.0, 2.0)*x_1
382
+ sage: type(_)
383
+ <class 'sage.numerical.linear_tensor_element.LinearTensor'>
384
+
385
+ Construct from scalar::
386
+
387
+ sage: LT(123) # indirect doctest
388
+ (123.0, 123.0)
389
+
390
+ Similar, over ``QQ`` and with matrices instead of vectors::
391
+
392
+ sage: p_QQ = MixedIntegerLinearProgram(solver='ppl')
393
+ sage: LT_QQ = p_QQ.linear_functions_parent().tensor(QQ^(2, 2))
394
+ sage: LT_QQ({-1:[[1/2, 1/3], [2, 3]], 2:[[3/4, 1/4], [0, 0]]})
395
+ [1/2 + 3/4*x_2 1/3 + 1/4*x_2]
396
+ [2 3 ]
397
+ sage: LT_QQ(42.1)
398
+ [421/10 0 ]
399
+ [0 421/10]
400
+
401
+ Construct from a linear function::
402
+
403
+ sage: from sage.numerical.linear_functions import LinearFunctionsParent
404
+ sage: LF_ZZ = LinearFunctionsParent(ZZ)
405
+ sage: lf = LF_ZZ({-1:3, 1:2, 3:1})
406
+ sage: LT(lf)
407
+ (3.0, 3.0) + (2.0, 2.0)*x_1 + (1.0, 1.0)*x_3
408
+ """
409
+ M = self.free_module()
410
+ if isinstance(x, LinearTensor):
411
+ x = x.dict()
412
+ elif isinstance(x, LinearFunction):
413
+ x = dict([key, self._convert_constant(value)] for key, value in x.dict().items())
414
+ elif isinstance(x, dict):
415
+ x = dict([int(key), M(value)] for key, value in x.items())
416
+ else:
417
+ try:
418
+ x = {-1: M(x)}
419
+ except (TypeError, ValueError):
420
+ x_R = M.base_ring()(x)
421
+ x = {-1: self._convert_constant(x_R)}
422
+ return self.element_class(self, x)
423
+
424
+ def _coerce_map_from_(self, R):
425
+ """
426
+ Allow coercion of scalars into tensors.
427
+
428
+ INPUT:
429
+
430
+ - ``R`` -- a ring
431
+
432
+ OUTPUT: boolean; whether there is a coercion map
433
+
434
+ EXAMPLES::
435
+
436
+ sage: p = MixedIntegerLinearProgram()
437
+ sage: parent = p.linear_functions_parent()
438
+ sage: parent.coerce(int(2))
439
+ 2
440
+ sage: parent._coerce_map_from_(int)
441
+ True
442
+
443
+ sage: mip.<x> = MixedIntegerLinearProgram()
444
+ sage: LF = mip.linear_functions_parent()
445
+ sage: LT = LF.tensor(RDF^3)
446
+ sage: LT.has_coerce_map_from(LF)
447
+ True
448
+ """
449
+ if self.free_module().has_coerce_map_from(R):
450
+ return True
451
+ if self.linear_functions().has_coerce_map_from(R):
452
+ return True
453
+ return False
454
+
455
+ def _an_element_(self):
456
+ """
457
+ Return an element.
458
+
459
+ OUTPUT: a linear function tensored with a free module
460
+
461
+ EXAMPLES::
462
+
463
+ sage: p = MixedIntegerLinearProgram().linear_functions_parent().tensor(RDF^2)
464
+ sage: p._an_element_()
465
+ (1.0, 0.0) + (5.0, 0.0)*x_2 + (7.0, 0.0)*x_5
466
+ sage: p.an_element() # indirect doctest
467
+ (1.0, 0.0) + (5.0, 0.0)*x_2 + (7.0, 0.0)*x_5
468
+ """
469
+ m = self.free_module().an_element()
470
+ return self._element_constructor_({-1: m, 2: 5 * m, 5: 7 * m})