passagemath-categories 10.6.32__cp314-cp314t-musllinux_1_2_aarch64.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.
Files changed (719) hide show
  1. passagemath_categories-10.6.32.dist-info/METADATA +156 -0
  2. passagemath_categories-10.6.32.dist-info/RECORD +719 -0
  3. passagemath_categories-10.6.32.dist-info/WHEEL +5 -0
  4. passagemath_categories-10.6.32.dist-info/top_level.txt +2 -0
  5. passagemath_categories.libs/libgcc_s-2d945d6c.so.1 +0 -0
  6. passagemath_categories.libs/libgmp-28992bcb.so.10.5.0 +0 -0
  7. passagemath_categories.libs/libstdc++-85f2cd6d.so.6.0.33 +0 -0
  8. sage/all__sagemath_categories.py +28 -0
  9. sage/arith/all.py +38 -0
  10. sage/arith/constants.pxd +27 -0
  11. sage/arith/functions.cpython-314t-aarch64-linux-musl.so +0 -0
  12. sage/arith/functions.pxd +4 -0
  13. sage/arith/functions.pyx +221 -0
  14. sage/arith/misc.py +6552 -0
  15. sage/arith/multi_modular.cpython-314t-aarch64-linux-musl.so +0 -0
  16. sage/arith/multi_modular.pxd +39 -0
  17. sage/arith/multi_modular.pyx +994 -0
  18. sage/arith/rational_reconstruction.cpython-314t-aarch64-linux-musl.so +0 -0
  19. sage/arith/rational_reconstruction.pxd +4 -0
  20. sage/arith/rational_reconstruction.pyx +115 -0
  21. sage/arith/srange.cpython-314t-aarch64-linux-musl.so +0 -0
  22. sage/arith/srange.pyx +571 -0
  23. sage/calculus/all__sagemath_categories.py +2 -0
  24. sage/calculus/functional.py +481 -0
  25. sage/calculus/functions.py +151 -0
  26. sage/categories/additive_groups.py +73 -0
  27. sage/categories/additive_magmas.py +1044 -0
  28. sage/categories/additive_monoids.py +114 -0
  29. sage/categories/additive_semigroups.py +184 -0
  30. sage/categories/affine_weyl_groups.py +238 -0
  31. sage/categories/algebra_ideals.py +95 -0
  32. sage/categories/algebra_modules.py +96 -0
  33. sage/categories/algebras.py +349 -0
  34. sage/categories/algebras_with_basis.py +377 -0
  35. sage/categories/all.py +160 -0
  36. sage/categories/aperiodic_semigroups.py +29 -0
  37. sage/categories/associative_algebras.py +47 -0
  38. sage/categories/bialgebras.py +101 -0
  39. sage/categories/bialgebras_with_basis.py +414 -0
  40. sage/categories/bimodules.py +206 -0
  41. sage/categories/chain_complexes.py +268 -0
  42. sage/categories/classical_crystals.py +480 -0
  43. sage/categories/coalgebras.py +405 -0
  44. sage/categories/coalgebras_with_basis.py +232 -0
  45. sage/categories/coercion_methods.cpython-314t-aarch64-linux-musl.so +0 -0
  46. sage/categories/coercion_methods.pyx +52 -0
  47. sage/categories/commutative_additive_groups.py +104 -0
  48. sage/categories/commutative_additive_monoids.py +45 -0
  49. sage/categories/commutative_additive_semigroups.py +48 -0
  50. sage/categories/commutative_algebra_ideals.py +87 -0
  51. sage/categories/commutative_algebras.py +94 -0
  52. sage/categories/commutative_ring_ideals.py +58 -0
  53. sage/categories/commutative_rings.py +736 -0
  54. sage/categories/complete_discrete_valuation.py +293 -0
  55. sage/categories/complex_reflection_groups.py +145 -0
  56. sage/categories/complex_reflection_or_generalized_coxeter_groups.py +1249 -0
  57. sage/categories/coxeter_group_algebras.py +186 -0
  58. sage/categories/coxeter_groups.py +3402 -0
  59. sage/categories/crystals.py +2628 -0
  60. sage/categories/cw_complexes.py +216 -0
  61. sage/categories/dedekind_domains.py +137 -0
  62. sage/categories/discrete_valuation.py +325 -0
  63. sage/categories/distributive_magmas_and_additive_magmas.py +100 -0
  64. sage/categories/division_rings.py +114 -0
  65. sage/categories/domains.py +95 -0
  66. sage/categories/drinfeld_modules.py +789 -0
  67. sage/categories/dual.py +42 -0
  68. sage/categories/enumerated_sets.py +1146 -0
  69. sage/categories/euclidean_domains.py +271 -0
  70. sage/categories/examples/algebras_with_basis.py +102 -0
  71. sage/categories/examples/all.py +1 -0
  72. sage/categories/examples/commutative_additive_monoids.py +130 -0
  73. sage/categories/examples/commutative_additive_semigroups.py +199 -0
  74. sage/categories/examples/coxeter_groups.py +8 -0
  75. sage/categories/examples/crystals.py +236 -0
  76. sage/categories/examples/cw_complexes.py +163 -0
  77. sage/categories/examples/facade_sets.py +187 -0
  78. sage/categories/examples/filtered_algebras_with_basis.py +204 -0
  79. sage/categories/examples/filtered_modules_with_basis.py +154 -0
  80. sage/categories/examples/finite_coxeter_groups.py +252 -0
  81. sage/categories/examples/finite_dimensional_algebras_with_basis.py +148 -0
  82. sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py +495 -0
  83. sage/categories/examples/finite_enumerated_sets.py +208 -0
  84. sage/categories/examples/finite_monoids.py +150 -0
  85. sage/categories/examples/finite_semigroups.py +190 -0
  86. sage/categories/examples/finite_weyl_groups.py +191 -0
  87. sage/categories/examples/graded_connected_hopf_algebras_with_basis.py +152 -0
  88. sage/categories/examples/graded_modules_with_basis.py +168 -0
  89. sage/categories/examples/graphs.py +122 -0
  90. sage/categories/examples/hopf_algebras_with_basis.py +145 -0
  91. sage/categories/examples/infinite_enumerated_sets.py +190 -0
  92. sage/categories/examples/lie_algebras.py +352 -0
  93. sage/categories/examples/lie_algebras_with_basis.py +196 -0
  94. sage/categories/examples/magmas.py +162 -0
  95. sage/categories/examples/manifolds.py +94 -0
  96. sage/categories/examples/monoids.py +144 -0
  97. sage/categories/examples/posets.py +178 -0
  98. sage/categories/examples/semigroups.py +580 -0
  99. sage/categories/examples/semigroups_cython.cpython-314t-aarch64-linux-musl.so +0 -0
  100. sage/categories/examples/semigroups_cython.pyx +221 -0
  101. sage/categories/examples/semirings.py +249 -0
  102. sage/categories/examples/sets_cat.py +706 -0
  103. sage/categories/examples/sets_with_grading.py +101 -0
  104. sage/categories/examples/with_realizations.py +542 -0
  105. sage/categories/fields.py +991 -0
  106. sage/categories/filtered_algebras.py +63 -0
  107. sage/categories/filtered_algebras_with_basis.py +548 -0
  108. sage/categories/filtered_hopf_algebras_with_basis.py +138 -0
  109. sage/categories/filtered_modules.py +210 -0
  110. sage/categories/filtered_modules_with_basis.py +1209 -0
  111. sage/categories/finite_complex_reflection_groups.py +1506 -0
  112. sage/categories/finite_coxeter_groups.py +1138 -0
  113. sage/categories/finite_crystals.py +103 -0
  114. sage/categories/finite_dimensional_algebras_with_basis.py +1860 -0
  115. sage/categories/finite_dimensional_bialgebras_with_basis.py +33 -0
  116. sage/categories/finite_dimensional_coalgebras_with_basis.py +33 -0
  117. sage/categories/finite_dimensional_graded_lie_algebras_with_basis.py +231 -0
  118. sage/categories/finite_dimensional_hopf_algebras_with_basis.py +38 -0
  119. sage/categories/finite_dimensional_lie_algebras_with_basis.py +2774 -0
  120. sage/categories/finite_dimensional_modules_with_basis.py +1407 -0
  121. sage/categories/finite_dimensional_nilpotent_lie_algebras_with_basis.py +167 -0
  122. sage/categories/finite_dimensional_semisimple_algebras_with_basis.py +270 -0
  123. sage/categories/finite_enumerated_sets.py +769 -0
  124. sage/categories/finite_fields.py +252 -0
  125. sage/categories/finite_groups.py +256 -0
  126. sage/categories/finite_lattice_posets.py +242 -0
  127. sage/categories/finite_monoids.py +316 -0
  128. sage/categories/finite_permutation_groups.py +339 -0
  129. sage/categories/finite_posets.py +1994 -0
  130. sage/categories/finite_semigroups.py +136 -0
  131. sage/categories/finite_sets.py +93 -0
  132. sage/categories/finite_weyl_groups.py +39 -0
  133. sage/categories/finitely_generated_lambda_bracket_algebras.py +112 -0
  134. sage/categories/finitely_generated_lie_conformal_algebras.py +114 -0
  135. sage/categories/finitely_generated_magmas.py +57 -0
  136. sage/categories/finitely_generated_semigroups.py +214 -0
  137. sage/categories/function_fields.py +76 -0
  138. sage/categories/g_sets.py +77 -0
  139. sage/categories/gcd_domains.py +65 -0
  140. sage/categories/generalized_coxeter_groups.py +94 -0
  141. sage/categories/graded_algebras.py +85 -0
  142. sage/categories/graded_algebras_with_basis.py +258 -0
  143. sage/categories/graded_bialgebras.py +32 -0
  144. sage/categories/graded_bialgebras_with_basis.py +32 -0
  145. sage/categories/graded_coalgebras.py +65 -0
  146. sage/categories/graded_coalgebras_with_basis.py +51 -0
  147. sage/categories/graded_hopf_algebras.py +41 -0
  148. sage/categories/graded_hopf_algebras_with_basis.py +169 -0
  149. sage/categories/graded_lie_algebras.py +91 -0
  150. sage/categories/graded_lie_algebras_with_basis.py +44 -0
  151. sage/categories/graded_lie_conformal_algebras.py +74 -0
  152. sage/categories/graded_modules.py +133 -0
  153. sage/categories/graded_modules_with_basis.py +329 -0
  154. sage/categories/graphs.py +138 -0
  155. sage/categories/group_algebras.py +430 -0
  156. sage/categories/groupoid.py +94 -0
  157. sage/categories/groups.py +667 -0
  158. sage/categories/h_trivial_semigroups.py +64 -0
  159. sage/categories/hecke_modules.py +185 -0
  160. sage/categories/highest_weight_crystals.py +980 -0
  161. sage/categories/hopf_algebras.py +219 -0
  162. sage/categories/hopf_algebras_with_basis.py +309 -0
  163. sage/categories/infinite_enumerated_sets.py +115 -0
  164. sage/categories/integral_domains.py +203 -0
  165. sage/categories/j_trivial_semigroups.py +29 -0
  166. sage/categories/kac_moody_algebras.py +82 -0
  167. sage/categories/kahler_algebras.py +203 -0
  168. sage/categories/l_trivial_semigroups.py +63 -0
  169. sage/categories/lambda_bracket_algebras.py +280 -0
  170. sage/categories/lambda_bracket_algebras_with_basis.py +107 -0
  171. sage/categories/lattice_posets.py +89 -0
  172. sage/categories/left_modules.py +49 -0
  173. sage/categories/lie_algebras.py +1070 -0
  174. sage/categories/lie_algebras_with_basis.py +261 -0
  175. sage/categories/lie_conformal_algebras.py +350 -0
  176. sage/categories/lie_conformal_algebras_with_basis.py +147 -0
  177. sage/categories/lie_groups.py +73 -0
  178. sage/categories/loop_crystals.py +1290 -0
  179. sage/categories/magmas.py +1189 -0
  180. sage/categories/magmas_and_additive_magmas.py +149 -0
  181. sage/categories/magmatic_algebras.py +365 -0
  182. sage/categories/manifolds.py +352 -0
  183. sage/categories/matrix_algebras.py +40 -0
  184. sage/categories/metric_spaces.py +387 -0
  185. sage/categories/modular_abelian_varieties.py +78 -0
  186. sage/categories/modules.py +989 -0
  187. sage/categories/modules_with_basis.py +2794 -0
  188. sage/categories/monoid_algebras.py +38 -0
  189. sage/categories/monoids.py +739 -0
  190. sage/categories/noetherian_rings.py +87 -0
  191. sage/categories/number_fields.py +242 -0
  192. sage/categories/ore_modules.py +189 -0
  193. sage/categories/partially_ordered_monoids.py +49 -0
  194. sage/categories/permutation_groups.py +63 -0
  195. sage/categories/pointed_sets.py +42 -0
  196. sage/categories/polyhedra.py +74 -0
  197. sage/categories/poor_man_map.py +270 -0
  198. sage/categories/posets.py +722 -0
  199. sage/categories/principal_ideal_domains.py +270 -0
  200. sage/categories/quantum_group_representations.py +543 -0
  201. sage/categories/quotient_fields.py +728 -0
  202. sage/categories/r_trivial_semigroups.py +45 -0
  203. sage/categories/regular_crystals.py +898 -0
  204. sage/categories/regular_supercrystals.py +170 -0
  205. sage/categories/right_modules.py +49 -0
  206. sage/categories/ring_ideals.py +74 -0
  207. sage/categories/rings.py +1904 -0
  208. sage/categories/rngs.py +175 -0
  209. sage/categories/schemes.py +393 -0
  210. sage/categories/semigroups.py +1060 -0
  211. sage/categories/semirings.py +71 -0
  212. sage/categories/semisimple_algebras.py +114 -0
  213. sage/categories/sets_with_grading.py +235 -0
  214. sage/categories/shephard_groups.py +43 -0
  215. sage/categories/signed_tensor.py +120 -0
  216. sage/categories/simplicial_complexes.py +134 -0
  217. sage/categories/simplicial_sets.py +1206 -0
  218. sage/categories/super_algebras.py +149 -0
  219. sage/categories/super_algebras_with_basis.py +144 -0
  220. sage/categories/super_hopf_algebras_with_basis.py +126 -0
  221. sage/categories/super_lie_conformal_algebras.py +193 -0
  222. sage/categories/super_modules.py +229 -0
  223. sage/categories/super_modules_with_basis.py +193 -0
  224. sage/categories/supercommutative_algebras.py +99 -0
  225. sage/categories/supercrystals.py +406 -0
  226. sage/categories/tensor.py +110 -0
  227. sage/categories/topological_spaces.py +170 -0
  228. sage/categories/triangular_kac_moody_algebras.py +439 -0
  229. sage/categories/tutorial.py +58 -0
  230. sage/categories/unique_factorization_domains.py +318 -0
  231. sage/categories/unital_algebras.py +426 -0
  232. sage/categories/vector_bundles.py +159 -0
  233. sage/categories/vector_spaces.py +357 -0
  234. sage/categories/weyl_groups.py +853 -0
  235. sage/combinat/all__sagemath_categories.py +34 -0
  236. sage/combinat/backtrack.py +180 -0
  237. sage/combinat/combinat.py +2269 -0
  238. sage/combinat/combinat_cython.cpython-314t-aarch64-linux-musl.so +0 -0
  239. sage/combinat/combinat_cython.pxd +6 -0
  240. sage/combinat/combinat_cython.pyx +390 -0
  241. sage/combinat/combination.py +796 -0
  242. sage/combinat/combinatorial_map.py +416 -0
  243. sage/combinat/composition.py +2192 -0
  244. sage/combinat/dlx.py +510 -0
  245. sage/combinat/integer_lists/__init__.py +7 -0
  246. sage/combinat/integer_lists/base.cpython-314t-aarch64-linux-musl.so +0 -0
  247. sage/combinat/integer_lists/base.pxd +16 -0
  248. sage/combinat/integer_lists/base.pyx +713 -0
  249. sage/combinat/integer_lists/invlex.cpython-314t-aarch64-linux-musl.so +0 -0
  250. sage/combinat/integer_lists/invlex.pxd +4 -0
  251. sage/combinat/integer_lists/invlex.pyx +1650 -0
  252. sage/combinat/integer_lists/lists.py +328 -0
  253. sage/combinat/integer_lists/nn.py +48 -0
  254. sage/combinat/integer_vector.py +1818 -0
  255. sage/combinat/integer_vector_weighted.py +413 -0
  256. sage/combinat/matrices/all__sagemath_categories.py +5 -0
  257. sage/combinat/matrices/dancing_links.cpython-314t-aarch64-linux-musl.so +0 -0
  258. sage/combinat/matrices/dancing_links.pyx +1159 -0
  259. sage/combinat/matrices/dancing_links_c.h +380 -0
  260. sage/combinat/matrices/dlxcpp.py +136 -0
  261. sage/combinat/partition.py +10070 -0
  262. sage/combinat/partitions.cpython-314t-aarch64-linux-musl.so +0 -0
  263. sage/combinat/partitions.pyx +743 -0
  264. sage/combinat/permutation.py +10168 -0
  265. sage/combinat/permutation_cython.cpython-314t-aarch64-linux-musl.so +0 -0
  266. sage/combinat/permutation_cython.pxd +11 -0
  267. sage/combinat/permutation_cython.pyx +407 -0
  268. sage/combinat/q_analogues.py +1090 -0
  269. sage/combinat/ranker.py +268 -0
  270. sage/combinat/subset.py +1561 -0
  271. sage/combinat/subsets_hereditary.py +202 -0
  272. sage/combinat/subsets_pairwise.py +184 -0
  273. sage/combinat/tools.py +63 -0
  274. sage/combinat/tuple.py +348 -0
  275. sage/data_structures/all.py +2 -0
  276. sage/data_structures/all__sagemath_categories.py +2 -0
  277. sage/data_structures/binary_matrix.pxd +138 -0
  278. sage/data_structures/binary_search.cpython-314t-aarch64-linux-musl.so +0 -0
  279. sage/data_structures/binary_search.pxd +3 -0
  280. sage/data_structures/binary_search.pyx +66 -0
  281. sage/data_structures/bitset.cpython-314t-aarch64-linux-musl.so +0 -0
  282. sage/data_structures/bitset.pxd +40 -0
  283. sage/data_structures/bitset.pyx +2385 -0
  284. sage/data_structures/bitset_base.cpython-314t-aarch64-linux-musl.so +0 -0
  285. sage/data_structures/bitset_base.pxd +926 -0
  286. sage/data_structures/bitset_base.pyx +117 -0
  287. sage/data_structures/bitset_intrinsics.h +487 -0
  288. sage/data_structures/blas_dict.cpython-314t-aarch64-linux-musl.so +0 -0
  289. sage/data_structures/blas_dict.pxd +12 -0
  290. sage/data_structures/blas_dict.pyx +469 -0
  291. sage/data_structures/list_of_pairs.cpython-314t-aarch64-linux-musl.so +0 -0
  292. sage/data_structures/list_of_pairs.pxd +16 -0
  293. sage/data_structures/list_of_pairs.pyx +122 -0
  294. sage/data_structures/mutable_poset.py +3312 -0
  295. sage/data_structures/pairing_heap.cpython-314t-aarch64-linux-musl.so +0 -0
  296. sage/data_structures/pairing_heap.h +346 -0
  297. sage/data_structures/pairing_heap.pxd +88 -0
  298. sage/data_structures/pairing_heap.pyx +1464 -0
  299. sage/data_structures/sparse_bitset.pxd +62 -0
  300. sage/data_structures/stream.py +5070 -0
  301. sage/databases/all__sagemath_categories.py +7 -0
  302. sage/databases/sql_db.py +2236 -0
  303. sage/ext/all__sagemath_categories.py +3 -0
  304. sage/ext/fast_callable.cpython-314t-aarch64-linux-musl.so +0 -0
  305. sage/ext/fast_callable.pxd +4 -0
  306. sage/ext/fast_callable.pyx +2746 -0
  307. sage/ext/fast_eval.cpython-314t-aarch64-linux-musl.so +0 -0
  308. sage/ext/fast_eval.pxd +1 -0
  309. sage/ext/fast_eval.pyx +102 -0
  310. sage/ext/interpreters/__init__.py +1 -0
  311. sage/ext/interpreters/all__sagemath_categories.py +2 -0
  312. sage/ext/interpreters/wrapper_el.cpython-314t-aarch64-linux-musl.so +0 -0
  313. sage/ext/interpreters/wrapper_el.pxd +18 -0
  314. sage/ext/interpreters/wrapper_el.pyx +148 -0
  315. sage/ext/interpreters/wrapper_py.cpython-314t-aarch64-linux-musl.so +0 -0
  316. sage/ext/interpreters/wrapper_py.pxd +17 -0
  317. sage/ext/interpreters/wrapper_py.pyx +133 -0
  318. sage/functions/airy.py +937 -0
  319. sage/functions/all.py +97 -0
  320. sage/functions/bessel.py +2102 -0
  321. sage/functions/error.py +784 -0
  322. sage/functions/exp_integral.py +1529 -0
  323. sage/functions/gamma.py +1087 -0
  324. sage/functions/generalized.py +672 -0
  325. sage/functions/hyperbolic.py +747 -0
  326. sage/functions/hypergeometric.py +1156 -0
  327. sage/functions/jacobi.py +1705 -0
  328. sage/functions/log.py +1402 -0
  329. sage/functions/min_max.py +338 -0
  330. sage/functions/orthogonal_polys.py +3106 -0
  331. sage/functions/other.py +2303 -0
  332. sage/functions/piecewise.py +1505 -0
  333. sage/functions/prime_pi.cpython-314t-aarch64-linux-musl.so +0 -0
  334. sage/functions/prime_pi.pyx +262 -0
  335. sage/functions/special.py +1212 -0
  336. sage/functions/spike_function.py +278 -0
  337. sage/functions/transcendental.py +690 -0
  338. sage/functions/trig.py +1062 -0
  339. sage/functions/wigner.py +726 -0
  340. sage/geometry/abc.cpython-314t-aarch64-linux-musl.so +0 -0
  341. sage/geometry/abc.pyx +82 -0
  342. sage/geometry/all__sagemath_categories.py +1 -0
  343. sage/groups/all__sagemath_categories.py +11 -0
  344. sage/groups/generic.py +1733 -0
  345. sage/groups/groups_catalog.py +113 -0
  346. sage/groups/perm_gps/all__sagemath_categories.py +1 -0
  347. sage/groups/perm_gps/partn_ref/all.py +1 -0
  348. sage/groups/perm_gps/partn_ref/all__sagemath_categories.py +1 -0
  349. sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.cpython-314t-aarch64-linux-musl.so +0 -0
  350. sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd +52 -0
  351. sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +906 -0
  352. sage/groups/perm_gps/partn_ref/canonical_augmentation.cpython-314t-aarch64-linux-musl.so +0 -0
  353. sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd +85 -0
  354. sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx +534 -0
  355. sage/groups/perm_gps/partn_ref/data_structures.cpython-314t-aarch64-linux-musl.so +0 -0
  356. sage/groups/perm_gps/partn_ref/data_structures.pxd +576 -0
  357. sage/groups/perm_gps/partn_ref/data_structures.pyx +1792 -0
  358. sage/groups/perm_gps/partn_ref/double_coset.cpython-314t-aarch64-linux-musl.so +0 -0
  359. sage/groups/perm_gps/partn_ref/double_coset.pxd +45 -0
  360. sage/groups/perm_gps/partn_ref/double_coset.pyx +739 -0
  361. sage/groups/perm_gps/partn_ref/refinement_lists.cpython-314t-aarch64-linux-musl.so +0 -0
  362. sage/groups/perm_gps/partn_ref/refinement_lists.pxd +18 -0
  363. sage/groups/perm_gps/partn_ref/refinement_lists.pyx +82 -0
  364. sage/groups/perm_gps/partn_ref/refinement_python.cpython-314t-aarch64-linux-musl.so +0 -0
  365. sage/groups/perm_gps/partn_ref/refinement_python.pxd +16 -0
  366. sage/groups/perm_gps/partn_ref/refinement_python.pyx +564 -0
  367. sage/groups/perm_gps/partn_ref/refinement_sets.cpython-314t-aarch64-linux-musl.so +0 -0
  368. sage/groups/perm_gps/partn_ref/refinement_sets.pxd +60 -0
  369. sage/groups/perm_gps/partn_ref/refinement_sets.pyx +858 -0
  370. sage/interfaces/abc.py +140 -0
  371. sage/interfaces/all.py +58 -0
  372. sage/interfaces/all__sagemath_categories.py +1 -0
  373. sage/interfaces/expect.py +1643 -0
  374. sage/interfaces/interface.py +1682 -0
  375. sage/interfaces/process.cpython-314t-aarch64-linux-musl.so +0 -0
  376. sage/interfaces/process.pxd +5 -0
  377. sage/interfaces/process.pyx +288 -0
  378. sage/interfaces/quit.py +167 -0
  379. sage/interfaces/sage0.py +604 -0
  380. sage/interfaces/sagespawn.cpython-314t-aarch64-linux-musl.so +0 -0
  381. sage/interfaces/sagespawn.pyx +308 -0
  382. sage/interfaces/tab_completion.py +101 -0
  383. sage/misc/all__sagemath_categories.py +78 -0
  384. sage/misc/allocator.cpython-314t-aarch64-linux-musl.so +0 -0
  385. sage/misc/allocator.pxd +6 -0
  386. sage/misc/allocator.pyx +47 -0
  387. sage/misc/binary_tree.cpython-314t-aarch64-linux-musl.so +0 -0
  388. sage/misc/binary_tree.pxd +29 -0
  389. sage/misc/binary_tree.pyx +537 -0
  390. sage/misc/callable_dict.cpython-314t-aarch64-linux-musl.so +0 -0
  391. sage/misc/callable_dict.pyx +89 -0
  392. sage/misc/citation.cpython-314t-aarch64-linux-musl.so +0 -0
  393. sage/misc/citation.pyx +159 -0
  394. sage/misc/converting_dict.py +293 -0
  395. sage/misc/defaults.py +129 -0
  396. sage/misc/derivative.cpython-314t-aarch64-linux-musl.so +0 -0
  397. sage/misc/derivative.pyx +223 -0
  398. sage/misc/functional.py +2005 -0
  399. sage/misc/html.py +589 -0
  400. sage/misc/latex.py +2673 -0
  401. sage/misc/latex_macros.py +236 -0
  402. sage/misc/latex_standalone.py +1833 -0
  403. sage/misc/map_threaded.py +38 -0
  404. sage/misc/mathml.py +76 -0
  405. sage/misc/method_decorator.py +88 -0
  406. sage/misc/mrange.py +755 -0
  407. sage/misc/multireplace.py +41 -0
  408. sage/misc/object_multiplexer.py +92 -0
  409. sage/misc/parser.cpython-314t-aarch64-linux-musl.so +0 -0
  410. sage/misc/parser.pyx +1107 -0
  411. sage/misc/random_testing.py +264 -0
  412. sage/misc/rest_index_of_methods.py +377 -0
  413. sage/misc/search.cpython-314t-aarch64-linux-musl.so +0 -0
  414. sage/misc/search.pxd +2 -0
  415. sage/misc/search.pyx +68 -0
  416. sage/misc/stopgap.cpython-314t-aarch64-linux-musl.so +0 -0
  417. sage/misc/stopgap.pyx +95 -0
  418. sage/misc/table.py +853 -0
  419. sage/monoids/all__sagemath_categories.py +1 -0
  420. sage/monoids/indexed_free_monoid.py +1071 -0
  421. sage/monoids/monoid.py +82 -0
  422. sage/numerical/all__sagemath_categories.py +1 -0
  423. sage/numerical/backends/all__sagemath_categories.py +1 -0
  424. sage/numerical/backends/generic_backend.cpython-314t-aarch64-linux-musl.so +0 -0
  425. sage/numerical/backends/generic_backend.pxd +61 -0
  426. sage/numerical/backends/generic_backend.pyx +1893 -0
  427. sage/numerical/backends/generic_sdp_backend.cpython-314t-aarch64-linux-musl.so +0 -0
  428. sage/numerical/backends/generic_sdp_backend.pxd +38 -0
  429. sage/numerical/backends/generic_sdp_backend.pyx +755 -0
  430. sage/parallel/all.py +6 -0
  431. sage/parallel/decorate.py +575 -0
  432. sage/parallel/map_reduce.py +1997 -0
  433. sage/parallel/multiprocessing_sage.py +76 -0
  434. sage/parallel/ncpus.py +35 -0
  435. sage/parallel/parallelism.py +364 -0
  436. sage/parallel/reference.py +47 -0
  437. sage/parallel/use_fork.py +333 -0
  438. sage/rings/abc.cpython-314t-aarch64-linux-musl.so +0 -0
  439. sage/rings/abc.pxd +31 -0
  440. sage/rings/abc.pyx +526 -0
  441. sage/rings/algebraic_closure_finite_field.py +1154 -0
  442. sage/rings/all__sagemath_categories.py +91 -0
  443. sage/rings/big_oh.py +227 -0
  444. sage/rings/continued_fraction.py +2754 -0
  445. sage/rings/continued_fraction_gosper.py +220 -0
  446. sage/rings/factorint.cpython-314t-aarch64-linux-musl.so +0 -0
  447. sage/rings/factorint.pyx +295 -0
  448. sage/rings/fast_arith.cpython-314t-aarch64-linux-musl.so +0 -0
  449. sage/rings/fast_arith.pxd +21 -0
  450. sage/rings/fast_arith.pyx +535 -0
  451. sage/rings/finite_rings/all__sagemath_categories.py +9 -0
  452. sage/rings/finite_rings/conway_polynomials.py +542 -0
  453. sage/rings/finite_rings/element_base.cpython-314t-aarch64-linux-musl.so +0 -0
  454. sage/rings/finite_rings/element_base.pxd +12 -0
  455. sage/rings/finite_rings/element_base.pyx +1176 -0
  456. sage/rings/finite_rings/finite_field_base.cpython-314t-aarch64-linux-musl.so +0 -0
  457. sage/rings/finite_rings/finite_field_base.pxd +7 -0
  458. sage/rings/finite_rings/finite_field_base.pyx +2171 -0
  459. sage/rings/finite_rings/finite_field_constructor.py +827 -0
  460. sage/rings/finite_rings/finite_field_prime_modn.py +372 -0
  461. sage/rings/finite_rings/galois_group.py +154 -0
  462. sage/rings/finite_rings/hom_finite_field.cpython-314t-aarch64-linux-musl.so +0 -0
  463. sage/rings/finite_rings/hom_finite_field.pxd +23 -0
  464. sage/rings/finite_rings/hom_finite_field.pyx +856 -0
  465. sage/rings/finite_rings/hom_prime_finite_field.cpython-314t-aarch64-linux-musl.so +0 -0
  466. sage/rings/finite_rings/hom_prime_finite_field.pxd +15 -0
  467. sage/rings/finite_rings/hom_prime_finite_field.pyx +164 -0
  468. sage/rings/finite_rings/homset.py +357 -0
  469. sage/rings/finite_rings/integer_mod.cpython-314t-aarch64-linux-musl.so +0 -0
  470. sage/rings/finite_rings/integer_mod.pxd +56 -0
  471. sage/rings/finite_rings/integer_mod.pyx +4586 -0
  472. sage/rings/finite_rings/integer_mod_limits.h +11 -0
  473. sage/rings/finite_rings/integer_mod_ring.py +2044 -0
  474. sage/rings/finite_rings/residue_field.cpython-314t-aarch64-linux-musl.so +0 -0
  475. sage/rings/finite_rings/residue_field.pxd +30 -0
  476. sage/rings/finite_rings/residue_field.pyx +1811 -0
  477. sage/rings/finite_rings/stdint.pxd +19 -0
  478. sage/rings/fraction_field.py +1452 -0
  479. sage/rings/fraction_field_element.cpython-314t-aarch64-linux-musl.so +0 -0
  480. sage/rings/fraction_field_element.pyx +1357 -0
  481. sage/rings/function_field/all.py +7 -0
  482. sage/rings/function_field/all__sagemath_categories.py +2 -0
  483. sage/rings/function_field/constructor.py +218 -0
  484. sage/rings/function_field/element.cpython-314t-aarch64-linux-musl.so +0 -0
  485. sage/rings/function_field/element.pxd +11 -0
  486. sage/rings/function_field/element.pyx +1008 -0
  487. sage/rings/function_field/element_rational.cpython-314t-aarch64-linux-musl.so +0 -0
  488. sage/rings/function_field/element_rational.pyx +513 -0
  489. sage/rings/function_field/extensions.py +230 -0
  490. sage/rings/function_field/function_field.py +1468 -0
  491. sage/rings/function_field/function_field_rational.py +1005 -0
  492. sage/rings/function_field/ideal.py +1155 -0
  493. sage/rings/function_field/ideal_rational.py +629 -0
  494. sage/rings/function_field/jacobian_base.py +826 -0
  495. sage/rings/function_field/jacobian_hess.py +1053 -0
  496. sage/rings/function_field/jacobian_khuri_makdisi.py +1027 -0
  497. sage/rings/function_field/maps.py +1039 -0
  498. sage/rings/function_field/order.py +281 -0
  499. sage/rings/function_field/order_basis.py +586 -0
  500. sage/rings/function_field/order_rational.py +576 -0
  501. sage/rings/function_field/place.py +426 -0
  502. sage/rings/function_field/place_rational.py +181 -0
  503. sage/rings/generic.py +320 -0
  504. sage/rings/homset.py +332 -0
  505. sage/rings/ideal.py +1885 -0
  506. sage/rings/ideal_monoid.py +215 -0
  507. sage/rings/infinity.py +1890 -0
  508. sage/rings/integer.cpython-314t-aarch64-linux-musl.so +0 -0
  509. sage/rings/integer.pxd +45 -0
  510. sage/rings/integer.pyx +7874 -0
  511. sage/rings/integer_ring.cpython-314t-aarch64-linux-musl.so +0 -0
  512. sage/rings/integer_ring.pxd +8 -0
  513. sage/rings/integer_ring.pyx +1693 -0
  514. sage/rings/laurent_series_ring.py +931 -0
  515. sage/rings/laurent_series_ring_element.cpython-314t-aarch64-linux-musl.so +0 -0
  516. sage/rings/laurent_series_ring_element.pxd +11 -0
  517. sage/rings/laurent_series_ring_element.pyx +1927 -0
  518. sage/rings/lazy_series.py +7815 -0
  519. sage/rings/lazy_series_ring.py +4356 -0
  520. sage/rings/localization.py +1043 -0
  521. sage/rings/morphism.cpython-314t-aarch64-linux-musl.so +0 -0
  522. sage/rings/morphism.pxd +39 -0
  523. sage/rings/morphism.pyx +3299 -0
  524. sage/rings/multi_power_series_ring.py +1145 -0
  525. sage/rings/multi_power_series_ring_element.py +2184 -0
  526. sage/rings/noncommutative_ideals.cpython-314t-aarch64-linux-musl.so +0 -0
  527. sage/rings/noncommutative_ideals.pyx +423 -0
  528. sage/rings/number_field/all__sagemath_categories.py +1 -0
  529. sage/rings/number_field/number_field_base.cpython-314t-aarch64-linux-musl.so +0 -0
  530. sage/rings/number_field/number_field_base.pxd +8 -0
  531. sage/rings/number_field/number_field_base.pyx +507 -0
  532. sage/rings/number_field/number_field_element_base.cpython-314t-aarch64-linux-musl.so +0 -0
  533. sage/rings/number_field/number_field_element_base.pxd +6 -0
  534. sage/rings/number_field/number_field_element_base.pyx +36 -0
  535. sage/rings/number_field/number_field_ideal.py +3550 -0
  536. sage/rings/padics/all__sagemath_categories.py +4 -0
  537. sage/rings/padics/local_generic.py +1670 -0
  538. sage/rings/padics/local_generic_element.cpython-314t-aarch64-linux-musl.so +0 -0
  539. sage/rings/padics/local_generic_element.pxd +5 -0
  540. sage/rings/padics/local_generic_element.pyx +1017 -0
  541. sage/rings/padics/misc.py +256 -0
  542. sage/rings/padics/padic_generic.py +1911 -0
  543. sage/rings/padics/pow_computer.cpython-314t-aarch64-linux-musl.so +0 -0
  544. sage/rings/padics/pow_computer.pxd +38 -0
  545. sage/rings/padics/pow_computer.pyx +671 -0
  546. sage/rings/padics/precision_error.py +24 -0
  547. sage/rings/polynomial/all__sagemath_categories.py +25 -0
  548. sage/rings/polynomial/commutative_polynomial.cpython-314t-aarch64-linux-musl.so +0 -0
  549. sage/rings/polynomial/commutative_polynomial.pxd +6 -0
  550. sage/rings/polynomial/commutative_polynomial.pyx +24 -0
  551. sage/rings/polynomial/cyclotomic.cpython-314t-aarch64-linux-musl.so +0 -0
  552. sage/rings/polynomial/cyclotomic.pyx +404 -0
  553. sage/rings/polynomial/flatten.py +711 -0
  554. sage/rings/polynomial/ideal.py +102 -0
  555. sage/rings/polynomial/infinite_polynomial_element.py +1768 -0
  556. sage/rings/polynomial/infinite_polynomial_ring.py +1653 -0
  557. sage/rings/polynomial/laurent_polynomial.cpython-314t-aarch64-linux-musl.so +0 -0
  558. sage/rings/polynomial/laurent_polynomial.pxd +18 -0
  559. sage/rings/polynomial/laurent_polynomial.pyx +2190 -0
  560. sage/rings/polynomial/laurent_polynomial_ideal.py +590 -0
  561. sage/rings/polynomial/laurent_polynomial_ring.py +832 -0
  562. sage/rings/polynomial/laurent_polynomial_ring_base.py +708 -0
  563. sage/rings/polynomial/multi_polynomial.cpython-314t-aarch64-linux-musl.so +0 -0
  564. sage/rings/polynomial/multi_polynomial.pxd +12 -0
  565. sage/rings/polynomial/multi_polynomial.pyx +3082 -0
  566. sage/rings/polynomial/multi_polynomial_element.py +2570 -0
  567. sage/rings/polynomial/multi_polynomial_ideal.py +5771 -0
  568. sage/rings/polynomial/multi_polynomial_ring.py +947 -0
  569. sage/rings/polynomial/multi_polynomial_ring_base.cpython-314t-aarch64-linux-musl.so +0 -0
  570. sage/rings/polynomial/multi_polynomial_ring_base.pxd +15 -0
  571. sage/rings/polynomial/multi_polynomial_ring_base.pyx +1855 -0
  572. sage/rings/polynomial/multi_polynomial_sequence.py +2204 -0
  573. sage/rings/polynomial/polydict.cpython-314t-aarch64-linux-musl.so +0 -0
  574. sage/rings/polynomial/polydict.pxd +45 -0
  575. sage/rings/polynomial/polydict.pyx +2701 -0
  576. sage/rings/polynomial/polynomial_compiled.cpython-314t-aarch64-linux-musl.so +0 -0
  577. sage/rings/polynomial/polynomial_compiled.pxd +59 -0
  578. sage/rings/polynomial/polynomial_compiled.pyx +509 -0
  579. sage/rings/polynomial/polynomial_element.cpython-314t-aarch64-linux-musl.so +0 -0
  580. sage/rings/polynomial/polynomial_element.pxd +64 -0
  581. sage/rings/polynomial/polynomial_element.pyx +13255 -0
  582. sage/rings/polynomial/polynomial_element_generic.py +1637 -0
  583. sage/rings/polynomial/polynomial_fateman.py +97 -0
  584. sage/rings/polynomial/polynomial_quotient_ring.py +2465 -0
  585. sage/rings/polynomial/polynomial_quotient_ring_element.py +779 -0
  586. sage/rings/polynomial/polynomial_ring.py +3784 -0
  587. sage/rings/polynomial/polynomial_ring_constructor.py +1051 -0
  588. sage/rings/polynomial/polynomial_ring_homomorphism.cpython-314t-aarch64-linux-musl.so +0 -0
  589. sage/rings/polynomial/polynomial_ring_homomorphism.pxd +5 -0
  590. sage/rings/polynomial/polynomial_ring_homomorphism.pyx +121 -0
  591. sage/rings/polynomial/polynomial_singular_interface.py +549 -0
  592. sage/rings/polynomial/symmetric_ideal.py +989 -0
  593. sage/rings/polynomial/symmetric_reduction.cpython-314t-aarch64-linux-musl.so +0 -0
  594. sage/rings/polynomial/symmetric_reduction.pxd +8 -0
  595. sage/rings/polynomial/symmetric_reduction.pyx +669 -0
  596. sage/rings/polynomial/term_order.py +2279 -0
  597. sage/rings/polynomial/toy_buchberger.py +449 -0
  598. sage/rings/polynomial/toy_d_basis.py +387 -0
  599. sage/rings/polynomial/toy_variety.py +362 -0
  600. sage/rings/power_series_mpoly.cpython-314t-aarch64-linux-musl.so +0 -0
  601. sage/rings/power_series_mpoly.pxd +9 -0
  602. sage/rings/power_series_mpoly.pyx +161 -0
  603. sage/rings/power_series_poly.cpython-314t-aarch64-linux-musl.so +0 -0
  604. sage/rings/power_series_poly.pxd +10 -0
  605. sage/rings/power_series_poly.pyx +1317 -0
  606. sage/rings/power_series_ring.py +1441 -0
  607. sage/rings/power_series_ring_element.cpython-314t-aarch64-linux-musl.so +0 -0
  608. sage/rings/power_series_ring_element.pxd +12 -0
  609. sage/rings/power_series_ring_element.pyx +3028 -0
  610. sage/rings/puiseux_series_ring.py +487 -0
  611. sage/rings/puiseux_series_ring_element.cpython-314t-aarch64-linux-musl.so +0 -0
  612. sage/rings/puiseux_series_ring_element.pxd +7 -0
  613. sage/rings/puiseux_series_ring_element.pyx +1055 -0
  614. sage/rings/qqbar_decorators.py +167 -0
  615. sage/rings/quotient_ring.py +1598 -0
  616. sage/rings/quotient_ring_element.py +979 -0
  617. sage/rings/rational.cpython-314t-aarch64-linux-musl.so +0 -0
  618. sage/rings/rational.pxd +20 -0
  619. sage/rings/rational.pyx +4284 -0
  620. sage/rings/rational_field.py +1730 -0
  621. sage/rings/real_double.cpython-314t-aarch64-linux-musl.so +0 -0
  622. sage/rings/real_double.pxd +16 -0
  623. sage/rings/real_double.pyx +2218 -0
  624. sage/rings/real_lazy.cpython-314t-aarch64-linux-musl.so +0 -0
  625. sage/rings/real_lazy.pxd +30 -0
  626. sage/rings/real_lazy.pyx +1773 -0
  627. sage/rings/ring.cpython-314t-aarch64-linux-musl.so +0 -0
  628. sage/rings/ring.pxd +30 -0
  629. sage/rings/ring.pyx +850 -0
  630. sage/rings/semirings/all.py +3 -0
  631. sage/rings/semirings/non_negative_integer_semiring.py +107 -0
  632. sage/rings/semirings/tropical_mpolynomial.py +972 -0
  633. sage/rings/semirings/tropical_polynomial.py +997 -0
  634. sage/rings/semirings/tropical_semiring.cpython-314t-aarch64-linux-musl.so +0 -0
  635. sage/rings/semirings/tropical_semiring.pyx +676 -0
  636. sage/rings/semirings/tropical_variety.py +1701 -0
  637. sage/rings/sum_of_squares.cpython-314t-aarch64-linux-musl.so +0 -0
  638. sage/rings/sum_of_squares.pxd +3 -0
  639. sage/rings/sum_of_squares.pyx +336 -0
  640. sage/rings/tests.py +504 -0
  641. sage/schemes/affine/affine_homset.py +508 -0
  642. sage/schemes/affine/affine_morphism.py +1574 -0
  643. sage/schemes/affine/affine_point.py +460 -0
  644. sage/schemes/affine/affine_rational_point.py +308 -0
  645. sage/schemes/affine/affine_space.py +1264 -0
  646. sage/schemes/affine/affine_subscheme.py +592 -0
  647. sage/schemes/affine/all.py +25 -0
  648. sage/schemes/all__sagemath_categories.py +5 -0
  649. sage/schemes/generic/algebraic_scheme.py +2092 -0
  650. sage/schemes/generic/all.py +5 -0
  651. sage/schemes/generic/ambient_space.py +400 -0
  652. sage/schemes/generic/divisor.py +465 -0
  653. sage/schemes/generic/divisor_group.py +313 -0
  654. sage/schemes/generic/glue.py +84 -0
  655. sage/schemes/generic/homset.py +820 -0
  656. sage/schemes/generic/hypersurface.py +234 -0
  657. sage/schemes/generic/morphism.py +2107 -0
  658. sage/schemes/generic/point.py +237 -0
  659. sage/schemes/generic/scheme.py +1190 -0
  660. sage/schemes/generic/spec.py +199 -0
  661. sage/schemes/product_projective/all.py +6 -0
  662. sage/schemes/product_projective/homset.py +236 -0
  663. sage/schemes/product_projective/morphism.py +517 -0
  664. sage/schemes/product_projective/point.py +568 -0
  665. sage/schemes/product_projective/rational_point.py +550 -0
  666. sage/schemes/product_projective/space.py +1301 -0
  667. sage/schemes/product_projective/subscheme.py +466 -0
  668. sage/schemes/projective/all.py +24 -0
  669. sage/schemes/projective/proj_bdd_height.py +453 -0
  670. sage/schemes/projective/projective_homset.py +718 -0
  671. sage/schemes/projective/projective_morphism.py +2792 -0
  672. sage/schemes/projective/projective_point.py +1484 -0
  673. sage/schemes/projective/projective_rational_point.py +569 -0
  674. sage/schemes/projective/projective_space.py +2571 -0
  675. sage/schemes/projective/projective_subscheme.py +1574 -0
  676. sage/sets/all.py +17 -0
  677. sage/sets/cartesian_product.py +376 -0
  678. sage/sets/condition_set.py +525 -0
  679. sage/sets/disjoint_set.cpython-314t-aarch64-linux-musl.so +0 -0
  680. sage/sets/disjoint_set.pxd +36 -0
  681. sage/sets/disjoint_set.pyx +998 -0
  682. sage/sets/disjoint_union_enumerated_sets.py +625 -0
  683. sage/sets/family.cpython-314t-aarch64-linux-musl.so +0 -0
  684. sage/sets/family.pxd +12 -0
  685. sage/sets/family.pyx +1556 -0
  686. sage/sets/finite_enumerated_set.py +406 -0
  687. sage/sets/finite_set_map_cy.cpython-314t-aarch64-linux-musl.so +0 -0
  688. sage/sets/finite_set_map_cy.pxd +34 -0
  689. sage/sets/finite_set_map_cy.pyx +708 -0
  690. sage/sets/finite_set_maps.py +591 -0
  691. sage/sets/image_set.py +448 -0
  692. sage/sets/integer_range.py +829 -0
  693. sage/sets/non_negative_integers.py +241 -0
  694. sage/sets/positive_integers.py +93 -0
  695. sage/sets/primes.py +188 -0
  696. sage/sets/real_set.py +2760 -0
  697. sage/sets/recursively_enumerated_set.cpython-314t-aarch64-linux-musl.so +0 -0
  698. sage/sets/recursively_enumerated_set.pxd +31 -0
  699. sage/sets/recursively_enumerated_set.pyx +2082 -0
  700. sage/sets/set.py +2083 -0
  701. sage/sets/set_from_iterator.py +1021 -0
  702. sage/sets/totally_ordered_finite_set.py +329 -0
  703. sage/symbolic/all__sagemath_categories.py +1 -0
  704. sage/symbolic/function.cpython-314t-aarch64-linux-musl.so +0 -0
  705. sage/symbolic/function.pxd +29 -0
  706. sage/symbolic/function.pyx +1488 -0
  707. sage/symbolic/symbols.py +56 -0
  708. sage/tests/all__sagemath_categories.py +1 -0
  709. sage/tests/cython.cpython-314t-aarch64-linux-musl.so +0 -0
  710. sage/tests/cython.pyx +37 -0
  711. sage/tests/stl_vector.cpython-314t-aarch64-linux-musl.so +0 -0
  712. sage/tests/stl_vector.pyx +171 -0
  713. sage/typeset/all.py +6 -0
  714. sage/typeset/ascii_art.py +295 -0
  715. sage/typeset/character_art.py +789 -0
  716. sage/typeset/character_art_factory.py +572 -0
  717. sage/typeset/symbols.py +334 -0
  718. sage/typeset/unicode_art.py +183 -0
  719. sage/typeset/unicode_characters.py +101 -0
sage/rings/infinity.py ADDED
@@ -0,0 +1,1890 @@
1
+ # sage_setup: distribution = sagemath-categories
2
+ r"""
3
+ Signed and Unsigned Infinities
4
+
5
+ The unsigned infinity "ring" is the set of two elements
6
+
7
+ 1. infinity
8
+
9
+ 2. A number less than infinity
10
+
11
+ The rules for arithmetic are that the unsigned infinity ring does
12
+ not canonically coerce to any other ring, and all other rings
13
+ canonically coerce to the unsigned infinity ring, sending all
14
+ elements to the single element "a number less than infinity" of the
15
+ unsigned infinity ring. Arithmetic and comparisons then take place
16
+ in the unsigned infinity ring, where all arithmetic operations that
17
+ are well-defined are defined.
18
+
19
+ The infinity "ring" is the set of five elements
20
+
21
+ 1. plus infinity
22
+
23
+ 2. a positive finite element
24
+
25
+ 3. zero
26
+
27
+ 4. a negative finite element
28
+
29
+ 5. negative infinity
30
+
31
+ The infinity ring coerces to the unsigned infinity ring, sending
32
+ the infinite elements to infinity and the non-infinite elements to
33
+ "a number less than infinity." Any ordered ring coerces to the
34
+ infinity ring in the obvious way.
35
+
36
+ .. NOTE::
37
+
38
+ The shorthand ``oo`` is predefined in Sage to be the same as
39
+ ``+Infinity`` in the infinity ring. It is considered equal to, but not
40
+ the same as ``Infinity`` in the
41
+ :class:`UnsignedInfinityRing<UnsignedInfinityRing_class>`.
42
+
43
+ EXAMPLES:
44
+
45
+ We fetch the unsigned infinity ring and create some elements::
46
+
47
+ sage: P = UnsignedInfinityRing; P
48
+ The Unsigned Infinity Ring
49
+ sage: P(5)
50
+ A number less than infinity
51
+ sage: P.ngens()
52
+ 1
53
+ sage: unsigned_oo = P.0; unsigned_oo
54
+ Infinity
55
+
56
+ We compare finite numbers with infinity::
57
+
58
+ sage: 5 < unsigned_oo
59
+ True
60
+ sage: 5 > unsigned_oo
61
+ False
62
+ sage: unsigned_oo < 5
63
+ False
64
+ sage: unsigned_oo > 5
65
+ True
66
+
67
+ Demonstrating the shorthand ``oo`` versus ``Infinity``::
68
+
69
+ sage: oo
70
+ +Infinity
71
+ sage: oo is InfinityRing.0
72
+ True
73
+ sage: oo is UnsignedInfinityRing.0
74
+ False
75
+ sage: oo == UnsignedInfinityRing.0
76
+ True
77
+
78
+ We do arithmetic::
79
+
80
+ sage: unsigned_oo + 5
81
+ Infinity
82
+
83
+ We make ``1 / unsigned_oo`` return the integer 0 so that arithmetic of
84
+ the following type works::
85
+
86
+ sage: (1/unsigned_oo) + 2
87
+ 2
88
+ sage: 32/5 - (2.439/unsigned_oo)
89
+ 32/5
90
+
91
+ Note that many operations are not defined, since the result is not
92
+ well-defined::
93
+
94
+ sage: unsigned_oo/0
95
+ Traceback (most recent call last):
96
+ ...
97
+ ValueError: quotient of number < oo by number < oo not defined
98
+
99
+ What happened above is that 0 is canonically coerced to "A number less
100
+ than infinity" in the unsigned infinity ring. Next, Sage tries to divide
101
+ by multiplying with its inverse. Finally, this inverse is not
102
+ well-defined.
103
+
104
+ ::
105
+
106
+ sage: 0/unsigned_oo
107
+ 0
108
+ sage: unsigned_oo * 0
109
+ Traceback (most recent call last):
110
+ ...
111
+ ValueError: unsigned oo times smaller number not defined
112
+ sage: unsigned_oo/unsigned_oo
113
+ Traceback (most recent call last):
114
+ ...
115
+ ValueError: unsigned oo times smaller number not defined
116
+
117
+ In the infinity ring, we can negate infinity, multiply positive
118
+ numbers by infinity, etc.
119
+
120
+ ::
121
+
122
+ sage: P = InfinityRing; P
123
+ The Infinity Ring
124
+ sage: P(5)
125
+ A positive finite number
126
+
127
+ The symbol ``oo`` is predefined as a shorthand for ``+Infinity``::
128
+
129
+ sage: oo
130
+ +Infinity
131
+
132
+ We compare finite and infinite elements::
133
+
134
+ sage: 5 < oo
135
+ True
136
+ sage: P(-5) < P(5)
137
+ True
138
+ sage: P(2) < P(3)
139
+ False
140
+ sage: -oo < oo
141
+ True
142
+
143
+ We can do more arithmetic than in the unsigned infinity ring::
144
+
145
+ sage: 2 * oo
146
+ +Infinity
147
+ sage: -2 * oo
148
+ -Infinity
149
+ sage: 1 - oo
150
+ -Infinity
151
+ sage: 1 / oo
152
+ 0
153
+ sage: -1 / oo
154
+ 0
155
+
156
+ We make ``1 / oo`` and ``1 / -oo`` return the integer 0 instead of the
157
+ infinity ring Zero so that arithmetic of the following type works::
158
+
159
+ sage: (1/oo) + 2
160
+ 2
161
+ sage: 32/5 - (2.439/-oo)
162
+ 32/5
163
+
164
+ If we try to subtract infinities or multiply infinity by zero we
165
+ still get an error::
166
+
167
+ sage: oo - oo
168
+ Traceback (most recent call last):
169
+ ...
170
+ SignError: cannot add infinity to minus infinity
171
+ sage: 0 * oo
172
+ Traceback (most recent call last):
173
+ ...
174
+ SignError: cannot multiply infinity by zero
175
+ sage: P(2) + P(-3)
176
+ Traceback (most recent call last):
177
+ ...
178
+ SignError: cannot add positive finite value to negative finite value
179
+
180
+ Signed infinity can also be represented by RR / RDF elements. But
181
+ unsigned infinity cannot::
182
+
183
+ sage: oo in RR, oo in RDF
184
+ (True, True)
185
+ sage: unsigned_infinity in RR, unsigned_infinity in RDF
186
+ (False, False)
187
+
188
+ TESTS::
189
+
190
+ sage: P = InfinityRing
191
+ sage: P == loads(dumps(P))
192
+ True
193
+
194
+ ::
195
+
196
+ sage: P(2) == loads(dumps(P(2)))
197
+ True
198
+
199
+ The following is assumed in a lot of code (i.e., "is" is used for
200
+ testing whether something is infinity), so make sure it is satisfied::
201
+
202
+ sage: loads(dumps(infinity)) is infinity
203
+ True
204
+
205
+ We check that :issue:`17990` is fixed::
206
+
207
+ sage: m = Matrix([Infinity]) # needs sage.modules
208
+ sage: m.rows() # needs sage.modules
209
+ [(+Infinity)]
210
+ """
211
+ # ****************************************************************************
212
+ # This program is free software: you can redistribute it and/or modify
213
+ # it under the terms of the GNU General Public License as published by
214
+ # the Free Software Foundation, either version 2 of the License, or
215
+ # (at your option) any later version.
216
+ # https://www.gnu.org/licenses/
217
+ # ****************************************************************************
218
+
219
+ from sys import maxsize
220
+
221
+ import sage.rings.abc
222
+
223
+ from sage.structure.parent import Parent
224
+ from sage.categories.rings import Rings
225
+ from sage.categories.semirings import Semirings
226
+ from sage.misc.fast_methods import Singleton
227
+ from sage.misc.lazy_import import lazy_import
228
+ from sage.rings.ring import CommutativeRing
229
+ from sage.structure.element import RingElement, InfinityElement
230
+ from sage.structure.richcmp import rich_to_bool, richcmp
231
+
232
+ lazy_import('sage.rings.integer', 'Integer')
233
+
234
+
235
+ _obj = {}
236
+
237
+
238
+ class _uniq:
239
+ def __new__(cls, *args):
240
+ """
241
+ This ensures uniqueness of these objects.
242
+
243
+ EXAMPLES::
244
+
245
+ sage: sage.rings.infinity.UnsignedInfinityRing_class() is sage.rings.infinity.UnsignedInfinityRing_class()
246
+ True
247
+ """
248
+ if cls in _obj:
249
+ return _obj[cls]
250
+ _obj[cls] = O = cls.__bases__[-1].__new__(cls, *args)
251
+ return O
252
+
253
+
254
+ class AnInfinity:
255
+ """
256
+ TESTS::
257
+
258
+ sage: oo == oo
259
+ True
260
+ sage: oo < oo
261
+ False
262
+ sage: -oo < oo
263
+ True
264
+ sage: -oo < 3 < oo
265
+ True
266
+
267
+ sage: unsigned_infinity == 3
268
+ False
269
+ sage: unsigned_infinity == unsigned_infinity
270
+ True
271
+ sage: unsigned_infinity == oo
272
+ True
273
+ """
274
+
275
+ def _repr_(self) -> str:
276
+ """
277
+ Return a string representation of ``self``.
278
+
279
+ TESTS::
280
+
281
+ sage: [x._repr_() for x in [unsigned_infinity, oo, -oo]]
282
+ ['Infinity', '+Infinity', '-Infinity']
283
+ """
284
+ return self._sign_char + "Infinity"
285
+
286
+ def _giac_init_(self) -> str:
287
+ """
288
+ TESTS::
289
+
290
+ sage: [x._giac_init_() for x in [unsigned_infinity, oo, -oo]]
291
+ ['infinity', '+infinity', '-infinity']
292
+ """
293
+ return self._sign_char + "infinity"
294
+
295
+ def _maxima_init_(self) -> str:
296
+ """
297
+ TESTS::
298
+
299
+ sage: maxima(-oo) # needs sage.symbolic
300
+ minf
301
+ sage: [x._maxima_init_() for x in [unsigned_infinity, oo, -oo]]
302
+ ['inf', 'inf', 'minf']
303
+ """
304
+ if self._sign < 0:
305
+ return 'minf'
306
+ else:
307
+ return 'inf'
308
+
309
+ def _fricas_init_(self) -> str:
310
+ """
311
+ TESTS::
312
+
313
+ sage: fricas(-oo) # optional - fricas
314
+ - infinity
315
+ sage: [x._fricas_init_() for x in [unsigned_infinity, oo, -oo]]
316
+ ['%infinity', '%plusInfinity', '%minusInfinity']
317
+ sage: [fricas(x) for x in [unsigned_infinity, oo, -oo]] # optional - fricas
318
+ [infinity, + infinity, - infinity]
319
+ """
320
+ if self._sign_char == '':
321
+ return r"%infinity"
322
+ elif self._sign > 0:
323
+ return r"%plusInfinity"
324
+ else:
325
+ return r"%minusInfinity"
326
+
327
+ def __pari__(self):
328
+ """
329
+ Convert ``self`` to a Pari object.
330
+
331
+ EXAMPLES::
332
+
333
+ sage: pari(-oo) # needs sage.libs.pari
334
+ -oo
335
+ sage: pari(oo) # needs sage.libs.pari
336
+ +oo
337
+ """
338
+ from sage.libs.pari import pari
339
+
340
+ if self._sign >= 0:
341
+ return pari('oo')
342
+ else:
343
+ return pari('-oo')
344
+
345
+ def _latex_(self) -> str:
346
+ r"""
347
+ Return a latex representation of ``self``.
348
+
349
+ EXAMPLES::
350
+
351
+ sage: latex(oo) # indirect doctest
352
+ +\infty
353
+ sage: [x._latex_() for x in [unsigned_infinity, oo, -oo]]
354
+ ['\\infty', '+\\infty', '-\\infty']
355
+ """
356
+ return self._sign_char + "\\infty"
357
+
358
+ def __abs__(self):
359
+ """
360
+ EXAMPLES::
361
+
362
+ sage: [abs(x) for x in [UnsignedInfinityRing.gen(), oo, -oo]]
363
+ [Infinity, +Infinity, +Infinity]
364
+ """
365
+ return -self if self._sign < 0 else self
366
+
367
+ def _add_(self, other):
368
+ """
369
+ Add ``self`` to ``other``.
370
+
371
+ EXAMPLES::
372
+
373
+ sage: -oo + -oo # indirect doctest
374
+ -Infinity
375
+ sage: -oo + 3
376
+ -Infinity
377
+ sage: oo + -100
378
+ +Infinity
379
+ sage: oo + -oo
380
+ Traceback (most recent call last):
381
+ ...
382
+ SignError: cannot add infinity to minus infinity
383
+
384
+ sage: unsigned_infinity = UnsignedInfinityRing.gen()
385
+ sage: unsigned_infinity + unsigned_infinity
386
+ Traceback (most recent call last):
387
+ ...
388
+ SignError: cannot add unsigned infinities
389
+ sage: unsigned_infinity + oo*i # needs sage.symbolic
390
+ Traceback (most recent call last):
391
+ ...
392
+ SignError: cannot add unsigned infinities
393
+ sage: unsigned_infinity + 88/3
394
+ Infinity
395
+ """
396
+ if isinstance(other, AnInfinity):
397
+ if self._sign == 0:
398
+ # just like oo - oo is undefined
399
+ raise SignError("cannot add unsigned infinities")
400
+ if self._sign != other._sign:
401
+ raise SignError("cannot add infinity to minus infinity")
402
+ return self
403
+
404
+ def _sub_(self, other):
405
+ """
406
+ EXAMPLES::
407
+
408
+ sage: -oo - oo # indirect doctest
409
+ -Infinity
410
+ sage: oo - -oo
411
+ +Infinity
412
+ sage: oo - 4
413
+ +Infinity
414
+ sage: -oo - 1
415
+ -Infinity
416
+ sage: oo - oo
417
+ Traceback (most recent call last):
418
+ ...
419
+ SignError: cannot add infinity to minus infinity
420
+ sage: unsigned_infinity - 4
421
+ Infinity
422
+ sage: unsigned_infinity - unsigned_infinity
423
+ Traceback (most recent call last):
424
+ ...
425
+ SignError: cannot subtract unsigned infinities
426
+ sage: unsigned_infinity - oo*i # needs sage.symbolic
427
+ Traceback (most recent call last):
428
+ ...
429
+ SignError: cannot subtract unsigned infinities
430
+ """
431
+ if isinstance(other, AnInfinity):
432
+ if self._sign == 0:
433
+ raise SignError("cannot subtract unsigned infinities")
434
+ elif self._sign == other._sign:
435
+ raise SignError("cannot add infinity to minus infinity")
436
+ return self
437
+
438
+ def _mul_(self, other):
439
+ """
440
+ EXAMPLES::
441
+
442
+ sage: oo * 19 # indirect doctest
443
+ +Infinity
444
+ sage: oo * oo
445
+ +Infinity
446
+ sage: -oo * oo
447
+ -Infinity
448
+ sage: -oo * 4
449
+ -Infinity
450
+ sage: -oo * -2/3
451
+ +Infinity
452
+ sage: -oo * 0
453
+ Traceback (most recent call last):
454
+ ...
455
+ SignError: cannot multiply infinity by zero
456
+ """
457
+ if other < 0:
458
+ return -self
459
+ if other > 0:
460
+ return self
461
+ raise SignError("cannot multiply infinity by zero")
462
+
463
+ def _div_(self, other):
464
+ """
465
+ EXAMPLES::
466
+
467
+ sage: 1.5 / oo # indirect doctest
468
+ 0
469
+ sage: oo / -4
470
+ -Infinity
471
+ sage: oo / oo
472
+ Traceback (most recent call last):
473
+ ...
474
+ SignError: cannot multiply infinity by zero
475
+
476
+ Check that :issue:`14857` is fixed::
477
+
478
+ sage: infinity / unsigned_infinity
479
+ Traceback (most recent call last):
480
+ ...
481
+ ValueError: unsigned oo times smaller number not defined
482
+ sage: SR(infinity) / unsigned_infinity # needs sage.symbolic
483
+ Traceback (most recent call last):
484
+ ...
485
+ RuntimeError: indeterminate expression: 0 * infinity encountered.
486
+ """
487
+ return self * ~other
488
+
489
+ def __float__(self):
490
+ r"""
491
+ Generate a floating-point infinity.
492
+
493
+ The printing of floating-point infinity varies across platforms.
494
+
495
+ EXAMPLES::
496
+
497
+ sage: RDF(infinity)
498
+ +infinity
499
+ sage: float(infinity) # random
500
+ +infinity
501
+ sage: CDF(infinity) # needs sage.rings.complex_double
502
+ +infinity
503
+ sage: infinity.__float__() # random
504
+ +infinity
505
+
506
+ sage: RDF(-infinity)
507
+ -infinity
508
+ sage: float(-infinity) # random
509
+ -inf
510
+ sage: CDF(-infinity) # needs sage.rings.complex_double
511
+ -infinity
512
+ sage: (-infinity).__float__() # random
513
+ -inf
514
+ sage: float(unsigned_infinity)
515
+ Traceback (most recent call last):
516
+ ...
517
+ ValueError: unsigned infinity cannot be represented in a float
518
+ """
519
+ if self._sign == 0:
520
+ raise ValueError('unsigned infinity cannot be represented in a float')
521
+ return float(self._sign_char + 'inf')
522
+
523
+ def lcm(self, x):
524
+ """
525
+ Return the least common multiple of ``oo`` and ``x``, which
526
+ is by definition oo unless ``x`` is 0.
527
+
528
+ EXAMPLES::
529
+
530
+ sage: oo.lcm(0)
531
+ 0
532
+ sage: oo.lcm(oo)
533
+ +Infinity
534
+ sage: oo.lcm(-oo)
535
+ +Infinity
536
+ sage: oo.lcm(10)
537
+ +Infinity
538
+ sage: (-oo).lcm(10)
539
+ +Infinity
540
+ """
541
+ if x == 0:
542
+ return x
543
+ else:
544
+ return abs(self)
545
+
546
+ def _sage_input_(self, sib, coerced):
547
+ """
548
+ Produce an expression which will reproduce this value when evaluated.
549
+
550
+ TESTS::
551
+
552
+ sage: sage_input(-oo)
553
+ -oo
554
+ sage: sage_input(oo)
555
+ oo
556
+ sage: sage_input(unsigned_infinity)
557
+ unsigned_infinity
558
+ """
559
+ if self._sign == 0:
560
+ return sib.name('unsigned_infinity')
561
+ elif self._sign > 0:
562
+ return sib.name('oo')
563
+ else:
564
+ return -sib.name('oo')
565
+
566
+
567
+ class UnsignedInfinityRing_class(Singleton, Parent):
568
+
569
+ def __init__(self):
570
+ """
571
+ Initialize ``self``.
572
+
573
+ TESTS::
574
+
575
+ sage: sage.rings.infinity.UnsignedInfinityRing_class() is sage.rings.infinity.UnsignedInfinityRing_class() is UnsignedInfinityRing
576
+ True
577
+
578
+ Sage can understand SymPy's complex infinity (:issue:`17493`)::
579
+
580
+ sage: import sympy # needs sympy
581
+ sage: SR(sympy.zoo) # needs sympy
582
+ Infinity
583
+
584
+ Some equality checks::
585
+
586
+ sage: infinity == UnsignedInfinityRing.gen()
587
+ True
588
+ sage: UnsignedInfinityRing(3) == UnsignedInfinityRing(-19.5)
589
+ True
590
+ """
591
+ cat = Semirings().Commutative()
592
+ Parent.__init__(self, self, names=('oo',), normalize=False,
593
+ category=cat)
594
+
595
+ def ngens(self) -> int:
596
+ """
597
+ The unsigned infinity ring has one "generator."
598
+
599
+ EXAMPLES::
600
+
601
+ sage: UnsignedInfinityRing.ngens()
602
+ 1
603
+ sage: len(UnsignedInfinityRing.gens())
604
+ 1
605
+ """
606
+ return 1
607
+
608
+ def gen(self, n=0):
609
+ """
610
+ The "generator" of ``self`` is the infinity object.
611
+
612
+ EXAMPLES::
613
+
614
+ sage: UnsignedInfinityRing.gen()
615
+ Infinity
616
+ sage: UnsignedInfinityRing.gen(1)
617
+ Traceback (most recent call last):
618
+ ...
619
+ IndexError: UnsignedInfinityRing only has one generator
620
+ """
621
+ if n == 0:
622
+ try:
623
+ return self._gen
624
+ except AttributeError:
625
+ self._gen = UnsignedInfinity()
626
+ return self._gen
627
+ else:
628
+ raise IndexError("UnsignedInfinityRing only has one generator")
629
+
630
+ def gens(self) -> tuple:
631
+ """
632
+ The "generator" of ``self`` is the infinity object.
633
+
634
+ EXAMPLES::
635
+
636
+ sage: UnsignedInfinityRing.gens()
637
+ (Infinity,)
638
+ """
639
+ return (self.gen(),)
640
+
641
+ def less_than_infinity(self):
642
+ """
643
+ This is the element that represents a finite value.
644
+
645
+ EXAMPLES::
646
+
647
+ sage: UnsignedInfinityRing.less_than_infinity()
648
+ A number less than infinity
649
+ sage: UnsignedInfinityRing(5) is UnsignedInfinityRing.less_than_infinity()
650
+ True
651
+ """
652
+ try:
653
+ return self._less_than_infinity
654
+ except AttributeError:
655
+ self._less_than_infinity = LessThanInfinity(self)
656
+ return self._less_than_infinity
657
+
658
+ def _repr_(self) -> str:
659
+ """
660
+ Return a string representation of ``self``.
661
+
662
+ TESTS::
663
+
664
+ sage: UnsignedInfinityRing._repr_()
665
+ 'The Unsigned Infinity Ring'
666
+ """
667
+ return "The Unsigned Infinity Ring"
668
+
669
+ def _element_constructor_(self, x):
670
+ """
671
+ The element constructor.
672
+
673
+ TESTS::
674
+
675
+ sage: UnsignedInfinityRing(2) # indirect doctest
676
+ A number less than infinity
677
+ sage: UnsignedInfinityRing(I) # needs sage.rings.number_field
678
+ A number less than infinity
679
+ sage: UnsignedInfinityRing(unsigned_infinity)
680
+ Infinity
681
+ sage: UnsignedInfinityRing(oo)
682
+ Infinity
683
+ sage: UnsignedInfinityRing(-oo)
684
+ Infinity
685
+ sage: K.<a> = QuadraticField(3) # needs sage.rings.number_field
686
+ sage: UnsignedInfinityRing(a) # needs sage.rings.number_field
687
+ A number less than infinity
688
+ sage: UnsignedInfinityRing(a - 2) # needs sage.rings.number_field
689
+ A number less than infinity
690
+ sage: UnsignedInfinityRing(RDF(oo)), UnsignedInfinityRing(RDF(-oo))
691
+ (Infinity, Infinity)
692
+ sage: UnsignedInfinityRing(RR(oo)), UnsignedInfinityRing(RR(-oo))
693
+ (Infinity, Infinity)
694
+ sage: UnsignedInfinityRing(CDF(oo)), UnsignedInfinityRing(CDF(-oo)) # needs sage.rings.complex_double
695
+ (Infinity, Infinity)
696
+ sage: UnsignedInfinityRing(CC(oo)), UnsignedInfinityRing(CC(-oo)) # needs sage.rings.real_mpfr
697
+ (Infinity, Infinity)
698
+ sage: UnsignedInfinityRing(RIF(oo)), UnsignedInfinityRing(RIF(-oo)) # needs sage.rings.real_interval_field
699
+ (Infinity, Infinity)
700
+ sage: UnsignedInfinityRing(float('+inf')), UnsignedInfinityRing(float('-inf'))
701
+ (Infinity, Infinity)
702
+ sage: UnsignedInfinityRing(SR(oo)), UnsignedInfinityRing(SR(-oo)) # needs sage.symbolic
703
+ (Infinity, Infinity)
704
+
705
+ The following rings have a ``is_infinity`` method::
706
+
707
+ sage: RR(oo).is_infinity()
708
+ True
709
+ sage: SR(oo).is_infinity() # needs sage.symbolic
710
+ True
711
+ """
712
+ # Lazy elements can wrap infinity or not, unwrap first
713
+ try:
714
+ from sage.rings.real_lazy import LazyWrapper
715
+ except ImportError:
716
+ pass
717
+ else:
718
+ if isinstance(x, LazyWrapper):
719
+ x = x._value
720
+
721
+ # Handle all ways to represent infinity first
722
+ if isinstance(x, InfinityElement):
723
+ return self.gen()
724
+ elif isinstance(x, float):
725
+ if x in [float('+inf'), float('-inf')]:
726
+ return self.gen()
727
+ elif isinstance(x, RingElement) and isinstance(x.parent(), sage.rings.abc.RealIntervalField):
728
+ if x.upper().is_infinity() or x.lower().is_infinity():
729
+ return self.gen()
730
+ else:
731
+ try:
732
+ # For example, RealField() implements this
733
+ if x.is_infinity():
734
+ return self.gen()
735
+ except AttributeError:
736
+ pass
737
+
738
+ # If we got here then x is not infinite
739
+ return self.less_than_infinity()
740
+
741
+ def _coerce_map_from_(self, R) -> bool:
742
+ """
743
+ EXAMPLES::
744
+
745
+ sage: UnsignedInfinityRing.has_coerce_map_from(int) # indirect doctest
746
+ True
747
+ sage: UnsignedInfinityRing.has_coerce_map_from(CC) # needs sage.rings.real_mpfr
748
+ True
749
+ sage: UnsignedInfinityRing.has_coerce_map_from(QuadraticField(-163, 'a')) # needs sage.rings.number_field
750
+ True
751
+ sage: UnsignedInfinityRing.has_coerce_map_from(QQ^3) # needs sage.modules
752
+ False
753
+ sage: UnsignedInfinityRing.has_coerce_map_from(SymmetricGroup(13)) # needs sage.groups
754
+ False
755
+ """
756
+ return R in Rings().Commutative() or R in (int, float, complex)
757
+
758
+
759
+ UnsignedInfinityRing = UnsignedInfinityRing_class()
760
+
761
+
762
+ class LessThanInfinity(_uniq, RingElement):
763
+ def __init__(self, parent=UnsignedInfinityRing):
764
+ """
765
+ Initialize ``self``.
766
+
767
+ EXAMPLES::
768
+
769
+ sage: sage.rings.infinity.LessThanInfinity() is UnsignedInfinityRing(5)
770
+ True
771
+ """
772
+ RingElement.__init__(self, parent)
773
+
774
+ def _repr_(self) -> str:
775
+ """
776
+ Return a string representation of ``self``.
777
+
778
+ EXAMPLES::
779
+
780
+ sage: UnsignedInfinityRing(5)._repr_()
781
+ 'A number less than infinity'
782
+ """
783
+ return "A number less than infinity"
784
+
785
+ def _latex_(self) -> str:
786
+ """
787
+ Return a latex representation of ``self``.
788
+
789
+ EXAMPLES::
790
+
791
+ sage: UnsignedInfinityRing(5)._latex_()
792
+ '(<\\infty)'
793
+ """
794
+ return "(<\\infty)"
795
+
796
+ def _add_(self, other):
797
+ """
798
+ EXAMPLES::
799
+
800
+ sage: UnsignedInfinityRing(5) + UnsignedInfinityRing(-3) # indirect doctest
801
+ A number less than infinity
802
+ sage: UnsignedInfinityRing(5) + unsigned_infinity
803
+ Infinity
804
+ """
805
+ if isinstance(other, UnsignedInfinity):
806
+ return other
807
+ return self
808
+
809
+ def _sub_(self, other):
810
+ """
811
+ EXAMPLES::
812
+
813
+ sage: UnsignedInfinityRing(5) - UnsignedInfinityRing(-3) # indirect doctest
814
+ A number less than infinity
815
+ sage: UnsignedInfinityRing(5) - unsigned_infinity
816
+ Infinity
817
+ """
818
+ if isinstance(other, UnsignedInfinity):
819
+ return other
820
+ return self
821
+
822
+ def _mul_(self, other):
823
+ """
824
+ EXAMPLES::
825
+
826
+ sage: UnsignedInfinityRing(4) * UnsignedInfinityRing(-3) # indirect doctest
827
+ A number less than infinity
828
+ sage: 5 * unsigned_infinity
829
+ Traceback (most recent call last):
830
+ ...
831
+ ValueError: oo times number < oo not defined
832
+ sage: unsigned_infinity * unsigned_infinity
833
+ Infinity
834
+ """
835
+ if isinstance(other, UnsignedInfinity):
836
+ raise ValueError("oo times number < oo not defined")
837
+ return self
838
+
839
+ def _div_(self, other):
840
+ """
841
+ Can't eliminate possibility of zero division....
842
+
843
+ EXAMPLES::
844
+
845
+ sage: UnsignedInfinityRing(2) / UnsignedInfinityRing(5) # indirect doctest
846
+ Traceback (most recent call last):
847
+ ...
848
+ ValueError: quotient of number < oo by number < oo not defined
849
+ sage: 1 / unsigned_infinity
850
+ 0
851
+ """
852
+ if isinstance(other, UnsignedInfinity):
853
+ return Integer(0) # noqa: F821
854
+ raise ValueError("quotient of number < oo by number < oo not defined")
855
+
856
+ def _richcmp_(self, other, op) -> bool:
857
+ """
858
+ Compare ``self`` to ``other``.
859
+
860
+ EXAMPLES::
861
+
862
+ sage: 1 == unsigned_infinity
863
+ False
864
+ """
865
+ if isinstance(other, UnsignedInfinity):
866
+ return rich_to_bool(op, -1)
867
+ return rich_to_bool(op, 0)
868
+
869
+ def sign(self):
870
+ """
871
+ Raise an error because the sign of ``self`` is not well defined.
872
+
873
+ EXAMPLES::
874
+
875
+ sage: sign(UnsignedInfinityRing(2))
876
+ Traceback (most recent call last):
877
+ ...
878
+ NotImplementedError: sign of number < oo is not well defined
879
+ sage: sign(UnsignedInfinityRing(0))
880
+ Traceback (most recent call last):
881
+ ...
882
+ NotImplementedError: sign of number < oo is not well defined
883
+ sage: sign(UnsignedInfinityRing(-2))
884
+ Traceback (most recent call last):
885
+ ...
886
+ NotImplementedError: sign of number < oo is not well defined
887
+ """
888
+ raise NotImplementedError("sign of number < oo is not well defined")
889
+
890
+
891
+ class UnsignedInfinity(_uniq, AnInfinity, InfinityElement):
892
+
893
+ _sign = 0
894
+ _sign_char = ''
895
+
896
+ def __init__(self):
897
+ """
898
+ Initialize ``self``.
899
+
900
+ TESTS::
901
+
902
+ sage: sage.rings.infinity.UnsignedInfinity() is sage.rings.infinity.UnsignedInfinity() is unsigned_infinity
903
+ True
904
+ """
905
+ InfinityElement.__init__(self, UnsignedInfinityRing)
906
+
907
+ def __hash__(self):
908
+ r"""
909
+ TESTS::
910
+
911
+ sage: hash(unsigned_infinity)
912
+ 9223372036854775806 # 64-bit
913
+ 2147483646 # 32-bit
914
+ """
915
+ return maxsize - 1
916
+
917
+ def _mul_(self, other):
918
+ """
919
+ Can't rule out an attempt at multiplication by 0.
920
+
921
+ EXAMPLES::
922
+
923
+ sage: unsigned_infinity * unsigned_infinity # indirect doctest
924
+ Infinity
925
+ sage: unsigned_infinity * 0
926
+ Traceback (most recent call last):
927
+ ...
928
+ ValueError: unsigned oo times smaller number not defined
929
+ sage: unsigned_infinity * 3
930
+ Traceback (most recent call last):
931
+ ...
932
+ ValueError: unsigned oo times smaller number not defined
933
+ """
934
+ if isinstance(other, UnsignedInfinity):
935
+ return self
936
+ raise ValueError("unsigned oo times smaller number not defined")
937
+
938
+ def _sympy_(self):
939
+ """
940
+ Convert ``unsigned_infinity`` to sympy ``zoo``.
941
+
942
+ EXAMPLES::
943
+
944
+ sage: # needs sympy
945
+ sage: import sympy
946
+ sage: SR(unsigned_infinity)._sympy_()
947
+ zoo
948
+ sage: gamma(-3)._sympy_() is sympy.factorial(-2)
949
+ True
950
+ sage: gamma(-3) is sympy.factorial(-2)._sage_()
951
+ True
952
+ """
953
+ import sympy
954
+ return sympy.zoo
955
+
956
+ def _richcmp_(self, other, op) -> bool:
957
+ """
958
+ Compare ``self`` to ``other``.
959
+
960
+ EXAMPLES::
961
+
962
+ sage: 1 == unsigned_infinity
963
+ False
964
+ """
965
+ if isinstance(other, LessThanInfinity):
966
+ return rich_to_bool(op, 1)
967
+ return rich_to_bool(op, 0)
968
+
969
+
970
+ unsigned_infinity = UnsignedInfinityRing.gen(0)
971
+ less_than_infinity = UnsignedInfinityRing.less_than_infinity()
972
+
973
+
974
+ def is_Infinite(x) -> bool:
975
+ """
976
+ This is a type check for infinity elements.
977
+
978
+ EXAMPLES::
979
+
980
+ sage: sage.rings.infinity.is_Infinite(oo)
981
+ doctest:warning...
982
+ DeprecationWarning: The function is_Infinite is deprecated;
983
+ use 'isinstance(..., InfinityElement)' instead.
984
+ See https://github.com/sagemath/sage/issues/38022 for details.
985
+ True
986
+ sage: sage.rings.infinity.is_Infinite(-oo)
987
+ True
988
+ sage: sage.rings.infinity.is_Infinite(unsigned_infinity)
989
+ True
990
+ sage: sage.rings.infinity.is_Infinite(3)
991
+ False
992
+ sage: sage.rings.infinity.is_Infinite(RR(infinity))
993
+ False
994
+ sage: sage.rings.infinity.is_Infinite(ZZ)
995
+ False
996
+ """
997
+ from sage.misc.superseded import deprecation
998
+ deprecation(38022, "The function is_Infinite is deprecated; use 'isinstance(..., InfinityElement)' instead.")
999
+
1000
+ return isinstance(x, InfinityElement)
1001
+
1002
+
1003
+ class SignError(ArithmeticError):
1004
+ """
1005
+ Sign error exception.
1006
+ """
1007
+ pass
1008
+
1009
+
1010
+ class InfinityRing_class(Singleton, CommutativeRing):
1011
+ def __init__(self):
1012
+ """
1013
+ Initialize ``self``.
1014
+
1015
+ TESTS::
1016
+
1017
+ sage: sage.rings.infinity.InfinityRing_class() is sage.rings.infinity.InfinityRing_class() is InfinityRing
1018
+ True
1019
+
1020
+ Comparison tests::
1021
+
1022
+ sage: InfinityRing == InfinityRing
1023
+ True
1024
+ sage: InfinityRing == UnsignedInfinityRing
1025
+ False
1026
+ """
1027
+ CommutativeRing.__init__(self, self, names=('oo',), normalize=False)
1028
+
1029
+ def fraction_field(self):
1030
+ """
1031
+ This isn't really a ring, let alone an integral domain.
1032
+
1033
+ TESTS::
1034
+
1035
+ sage: InfinityRing.fraction_field()
1036
+ Traceback (most recent call last):
1037
+ ...
1038
+ TypeError: infinity 'ring' has no fraction field
1039
+ """
1040
+ raise TypeError("infinity 'ring' has no fraction field")
1041
+
1042
+ def ngens(self) -> int:
1043
+ """
1044
+ The two generators are plus and minus infinity.
1045
+
1046
+ EXAMPLES::
1047
+
1048
+ sage: InfinityRing.ngens()
1049
+ 2
1050
+ sage: len(InfinityRing.gens())
1051
+ 2
1052
+ """
1053
+ return 2
1054
+
1055
+ def gen(self, n=0):
1056
+ """
1057
+ The two generators are plus and minus infinity.
1058
+
1059
+ EXAMPLES::
1060
+
1061
+ sage: InfinityRing.gen(0)
1062
+ +Infinity
1063
+ sage: InfinityRing.gen(1)
1064
+ -Infinity
1065
+ sage: InfinityRing.gen(2)
1066
+ Traceback (most recent call last):
1067
+ ...
1068
+ IndexError: n must be 0 or 1
1069
+ """
1070
+ try:
1071
+ if n == 0:
1072
+ return self._gen0
1073
+ elif n == 1:
1074
+ return self._gen1
1075
+ else:
1076
+ raise IndexError("n must be 0 or 1")
1077
+ except AttributeError:
1078
+ if n == 0:
1079
+ self._gen0 = PlusInfinity()
1080
+ return self._gen0
1081
+ elif n == 1:
1082
+ self._gen1 = MinusInfinity()
1083
+ return self._gen1
1084
+
1085
+ def gens(self) -> tuple:
1086
+ """
1087
+ The two generators are plus and minus infinity.
1088
+
1089
+ EXAMPLES::
1090
+
1091
+ sage: InfinityRing.gens()
1092
+ (+Infinity, -Infinity)
1093
+ """
1094
+ return (self.gen(0), self.gen(1))
1095
+
1096
+ def is_zero(self) -> bool:
1097
+ """
1098
+ The Infinity Ring is not zero
1099
+
1100
+ EXAMPLES::
1101
+
1102
+ sage: InfinityRing.is_zero()
1103
+ False
1104
+ """
1105
+ return False
1106
+
1107
+ def is_commutative(self) -> bool:
1108
+ """
1109
+ The Infinity Ring is commutative
1110
+
1111
+ EXAMPLES::
1112
+
1113
+ sage: InfinityRing.is_commutative()
1114
+ True
1115
+ """
1116
+ return True
1117
+
1118
+ def _repr_(self) -> str:
1119
+ """
1120
+ Return a string representation of ``self``.
1121
+
1122
+ TESTS::
1123
+
1124
+ sage: InfinityRing._repr_()
1125
+ 'The Infinity Ring'
1126
+ """
1127
+ return "The Infinity Ring"
1128
+
1129
+ def _element_constructor_(self, x):
1130
+ """
1131
+ The element constructor.
1132
+
1133
+ TESTS::
1134
+
1135
+ sage: InfinityRing(-oo) # indirect doctest
1136
+ -Infinity
1137
+ sage: InfinityRing(3)
1138
+ A positive finite number
1139
+ sage: InfinityRing(-1.5)
1140
+ A negative finite number
1141
+ sage: [InfinityRing(a) for a in [-2..2]]
1142
+ [A negative finite number, A negative finite number, Zero,
1143
+ A positive finite number, A positive finite number]
1144
+ sage: K.<a> = QuadraticField(3) # needs sage.rings.number_field
1145
+ sage: InfinityRing(a) # needs sage.rings.number_field
1146
+ A positive finite number
1147
+ sage: InfinityRing(a - 2) # needs sage.rings.number_field
1148
+ A negative finite number
1149
+ sage: InfinityRing(RDF(oo)), InfinityRing(RDF(-oo))
1150
+ (+Infinity, -Infinity)
1151
+ sage: InfinityRing(RR(oo)), InfinityRing(RR(-oo))
1152
+ (+Infinity, -Infinity)
1153
+ sage: InfinityRing(RIF(oo)), InfinityRing(RIF(-oo)) # needs sage.rings.real_interval_field
1154
+ (+Infinity, -Infinity)
1155
+ sage: InfinityRing(float('+inf')), InfinityRing(float('-inf'))
1156
+ (+Infinity, -Infinity)
1157
+ sage: InfinityRing(SR(oo)), InfinityRing(SR(-oo)) # needs sage.symbolic
1158
+ (+Infinity, -Infinity)
1159
+
1160
+ The following rings have ``is_positive_infinity`` /
1161
+ ``is_negative_infinity`` methods::
1162
+
1163
+ sage: RR(oo).is_positive_infinity(), RR(-oo).is_negative_infinity()
1164
+ (True, True)
1165
+ sage: SR(oo).is_positive_infinity(), SR(-oo).is_negative_infinity() # needs sage.symbolic
1166
+ (True, True)
1167
+
1168
+ Complex infinity raises an exception. This is fine (there is
1169
+ no coercion, so there is no promise of functoriality)::
1170
+
1171
+ sage: i_infinity = CC(0, oo) # needs sage.rings.real_mpfr
1172
+ sage: InfinityRing(CC(oo)), InfinityRing(CC(-oo)) # needs sage.rings.real_mpfr
1173
+ (+Infinity, -Infinity)
1174
+ sage: InfinityRing(i_infinity) # needs sage.rings.real_mpfr
1175
+ Traceback (most recent call last):
1176
+ ...
1177
+ ValueError: infinite but not with +/- phase
1178
+ sage: InfinityRing(CDF(oo)), InfinityRing(CDF(-oo)) # needs sage.rings.complex_double
1179
+ (+Infinity, -Infinity)
1180
+ sage: InfinityRing(CDF(i_infinity)) # needs sage.rings.complex_double sage.rings.real_mpfr
1181
+ Traceback (most recent call last):
1182
+ ...
1183
+ ValueError: infinite but not with +/- phase
1184
+ """
1185
+ # Lazy elements can wrap infinity or not, unwrap first
1186
+ try:
1187
+ from sage.rings.real_lazy import LazyWrapper
1188
+ except ImportError:
1189
+ pass
1190
+ else:
1191
+ if isinstance(x, LazyWrapper):
1192
+ x = x._value
1193
+
1194
+ # Handle all ways to represent infinity first
1195
+ if isinstance(x, InfinityElement):
1196
+ if x < 0:
1197
+ return self.gen(1)
1198
+ else:
1199
+ return self.gen(0)
1200
+ elif isinstance(x, float):
1201
+ if x == float('+inf'):
1202
+ return self.gen(0)
1203
+ if x == float('-inf'):
1204
+ return self.gen(1)
1205
+ elif isinstance(x, RingElement) and isinstance(x.parent(), sage.rings.abc.RealIntervalField):
1206
+ if x.upper().is_positive_infinity():
1207
+ return self.gen(0)
1208
+ if x.lower().is_negative_infinity():
1209
+ return self.gen(1)
1210
+ else:
1211
+ try:
1212
+ # For example, RealField() implements this
1213
+ if x.is_positive_infinity():
1214
+ return self.gen(0)
1215
+ if x.is_negative_infinity():
1216
+ return self.gen(1)
1217
+ if x.is_infinity():
1218
+ raise ValueError('infinite but not with +/- phase')
1219
+ except AttributeError:
1220
+ pass
1221
+
1222
+ # If we got here then x is not infinite
1223
+ c = int(bool(x > 0)) - int(bool(x < 0))
1224
+ return FiniteNumber(self, c)
1225
+
1226
+ def _coerce_map_from_(self, R) -> bool:
1227
+ r"""
1228
+ There is a coercion from anything that has a coercion into the reals.
1229
+
1230
+ The way Sage works is that everything that should be
1231
+ comparable with infinity can be coerced into the infinity
1232
+ ring, so if you ever compare with infinity the comparison is
1233
+ done there. If you don't have a coercion then you will get
1234
+ undesirable answers from the fallback comparison (likely
1235
+ memory location).
1236
+
1237
+ EXAMPLES::
1238
+
1239
+ sage: InfinityRing.has_coerce_map_from(int) # indirect doctest
1240
+ True
1241
+ sage: InfinityRing.has_coerce_map_from(AA) # needs sage.rings.number_field
1242
+ True
1243
+ sage: InfinityRing.has_coerce_map_from(RDF)
1244
+ True
1245
+ sage: InfinityRing.has_coerce_map_from(RIF) # needs sage.rings.real_interval_field
1246
+ True
1247
+
1248
+ As explained above, comparison works by coercing to the
1249
+ infinity ring::
1250
+
1251
+ sage: cm = get_coercion_model()
1252
+ sage: cm.explain(AA(3), oo, operator.lt) # needs sage.rings.number_field
1253
+ Coercion on left operand via
1254
+ Coercion map:
1255
+ From: Algebraic Real Field
1256
+ To: The Infinity Ring
1257
+ Arithmetic performed after coercions.
1258
+ Result lives in The Infinity Ring
1259
+ The Infinity Ring
1260
+
1261
+ The symbolic ring does not coerce to the infinity ring, so
1262
+ symbolic comparisons with infinities all happen in the
1263
+ symbolic ring::
1264
+
1265
+ sage: SR.has_coerce_map_from(InfinityRing) # needs sage.symbolic
1266
+ True
1267
+ sage: InfinityRing.has_coerce_map_from(SR) # needs sage.symbolic
1268
+ False
1269
+
1270
+ Complex numbers do not coerce into the infinity ring (what
1271
+ would `i \infty` coerce to?). This is fine since they can not
1272
+ be compared, so we do not have to enforce consistency when
1273
+ comparing with infinity either::
1274
+
1275
+ sage: InfinityRing.has_coerce_map_from(CDF) # needs sage.rings.complex_double
1276
+ False
1277
+ sage: InfinityRing.has_coerce_map_from(CC) # needs sage.rings.real_mpfr
1278
+ False
1279
+ sage: CC(0, oo) < CC(1) # does not coerce to infinity ring # needs sage.rings.real_mpfr
1280
+ True
1281
+ """
1282
+ from sage.structure.coerce import parent_is_real_numerical
1283
+ if parent_is_real_numerical(R):
1284
+ return True
1285
+ if isinstance(R, (sage.rings.abc.RealIntervalField,
1286
+ sage.rings.abc.RealBallField)):
1287
+ return True
1288
+ return False
1289
+
1290
+ def _pushout_(self, other):
1291
+ r"""
1292
+ EXAMPLES::
1293
+
1294
+ sage: QQbar(-2*i)*infinity # needs sage.rings.number_field sage.symbolic
1295
+ (-I)*Infinity
1296
+ """
1297
+ try:
1298
+ from sage.symbolic.ring import SR
1299
+ except ImportError:
1300
+ return None
1301
+ if SR.has_coerce_map_from(other):
1302
+ return SR
1303
+
1304
+
1305
+ class FiniteNumber(RingElement):
1306
+
1307
+ def __init__(self, parent, x):
1308
+ """
1309
+ Initialize ``self``.
1310
+
1311
+ TESTS::
1312
+
1313
+ sage: sage.rings.infinity.FiniteNumber(InfinityRing, 1)
1314
+ A positive finite number
1315
+ sage: sage.rings.infinity.FiniteNumber(InfinityRing, -1)
1316
+ A negative finite number
1317
+ sage: sage.rings.infinity.FiniteNumber(InfinityRing, 0)
1318
+ Zero
1319
+ """
1320
+ RingElement.__init__(self, parent)
1321
+ self.value = x
1322
+
1323
+ def _richcmp_(self, other, op) -> bool:
1324
+ """
1325
+ Compare ``self`` and ``other``.
1326
+
1327
+ EXAMPLES::
1328
+
1329
+ sage: P = InfinityRing
1330
+ sage: -oo < P(-5) < P(0) < P(1.5) < oo
1331
+ True
1332
+ sage: P(1) < P(100)
1333
+ False
1334
+ sage: P(-1) == P(-100)
1335
+ True
1336
+ """
1337
+ if isinstance(other, PlusInfinity):
1338
+ return rich_to_bool(op, -1)
1339
+ if isinstance(other, MinusInfinity):
1340
+ return rich_to_bool(op, 1)
1341
+ return richcmp(self.value, other.value, op)
1342
+
1343
+ def _add_(self, other):
1344
+ """
1345
+ EXAMPLES::
1346
+
1347
+ sage: P = InfinityRing
1348
+ sage: 4 + oo # indirect doctest
1349
+ +Infinity
1350
+ sage: P(4) + P(2)
1351
+ A positive finite number
1352
+ sage: P(-1) + P(1)
1353
+ Traceback (most recent call last):
1354
+ ...
1355
+ SignError: cannot add positive finite value to negative finite value
1356
+
1357
+ Subtraction is implemented by adding the negative::
1358
+
1359
+ sage: P = InfinityRing
1360
+ sage: 4 - oo # indirect doctest
1361
+ -Infinity
1362
+ sage: 5 - -oo
1363
+ +Infinity
1364
+ sage: P(44) - P(4)
1365
+ Traceback (most recent call last):
1366
+ ...
1367
+ SignError: cannot add positive finite value to negative finite value
1368
+ sage: P(44) - P(-1)
1369
+ A positive finite number
1370
+
1371
+ TESTS:
1372
+
1373
+ Check that :issue:`34231` is fixed::
1374
+
1375
+ sage: R = InfinityRing
1376
+ sage: all(R(0) + x == x + R(0) == x for x in [-oo, R(-1), R(0), R(1), oo])
1377
+ True
1378
+ """
1379
+ if isinstance(other, InfinityElement):
1380
+ return other
1381
+ if self.value * other.value < 0:
1382
+ raise SignError("cannot add positive finite value to negative finite value")
1383
+ return FiniteNumber(self.parent(), self.value + other.value)
1384
+
1385
+ def _mul_(self, other):
1386
+ """
1387
+ EXAMPLES::
1388
+
1389
+ sage: P = InfinityRing
1390
+ sage: 0 * oo # indirect doctest
1391
+ Traceback (most recent call last):
1392
+ ...
1393
+ SignError: cannot multiply infinity by zero
1394
+ sage: -1 * oo
1395
+ -Infinity
1396
+ sage: -2 * oo
1397
+ -Infinity
1398
+ sage: 3 * oo
1399
+ +Infinity
1400
+ sage: -oo * oo
1401
+ -Infinity
1402
+ sage: P(0) * 3
1403
+ 0
1404
+ sage: P(-3) * P(2/3)
1405
+ A negative finite number
1406
+ """
1407
+ if other.is_zero():
1408
+ if isinstance(self, InfinityElement):
1409
+ raise SignError("cannot multiply infinity by zero")
1410
+ return Integer(0) # noqa: F821
1411
+ if self.value < 0:
1412
+ if isinstance(other, InfinityElement):
1413
+ return -other
1414
+ return FiniteNumber(self.parent(), self.value * other.value)
1415
+ if self.value > 0:
1416
+ if isinstance(other, InfinityElement):
1417
+ return other
1418
+ return FiniteNumber(self.parent(), self.value * other.value)
1419
+ if self.value == 0:
1420
+ if isinstance(other, InfinityElement):
1421
+ raise SignError("cannot multiply infinity by zero")
1422
+ return Integer(0) # noqa: F821
1423
+
1424
+ def _div_(self, other):
1425
+ """
1426
+ EXAMPLES::
1427
+
1428
+ sage: P = InfinityRing
1429
+ sage: 1 / oo # indirect doctest
1430
+ 0
1431
+ sage: oo / 4
1432
+ +Infinity
1433
+ sage: oo / -4
1434
+ -Infinity
1435
+ sage: P(1) / P(-4)
1436
+ A negative finite number
1437
+ """
1438
+ return self * ~other
1439
+
1440
+ def __invert__(self):
1441
+ """
1442
+ EXAMPLES::
1443
+
1444
+ sage: P = InfinityRing
1445
+ sage: ~P(2)
1446
+ A positive finite number
1447
+ sage: ~P(-7)
1448
+ A negative finite number
1449
+ sage: ~P(0)
1450
+ Traceback (most recent call last):
1451
+ ...
1452
+ ZeroDivisionError: Cannot divide by zero
1453
+ """
1454
+ if self.value == 0:
1455
+ raise ZeroDivisionError("Cannot divide by zero")
1456
+ return self
1457
+
1458
+ def _neg_(self):
1459
+ """
1460
+ EXAMPLES::
1461
+
1462
+ sage: a = InfinityRing(5); a
1463
+ A positive finite number
1464
+ sage: -a # indirect doctest
1465
+ A negative finite number
1466
+ sage: -(-a) == a
1467
+ True
1468
+ sage: -InfinityRing(0)
1469
+ Zero
1470
+ """
1471
+ return FiniteNumber(self.parent(), -self.value)
1472
+
1473
+ def _repr_(self) -> str:
1474
+ """
1475
+ Return a string representation of ``self``.
1476
+
1477
+ EXAMPLES::
1478
+
1479
+ sage: InfinityRing(-2)._repr_()
1480
+ 'A negative finite number'
1481
+ sage: InfinityRing(7)._repr_()
1482
+ 'A positive finite number'
1483
+ sage: InfinityRing(0)._repr_()
1484
+ 'Zero'
1485
+ """
1486
+ if self.value < 0:
1487
+ return "A negative finite number"
1488
+ if self.value > 0:
1489
+ return "A positive finite number"
1490
+ return "Zero"
1491
+
1492
+ def _latex_(self) -> str:
1493
+ """
1494
+ Return a latex representation of ``self``.
1495
+
1496
+ TESTS::
1497
+
1498
+ sage: a = InfinityRing(pi); a # needs sage.symbolic
1499
+ A positive finite number
1500
+ sage: a._latex_() # needs sage.symbolic
1501
+ 'A positive finite number'
1502
+ sage: [latex(InfinityRing(a)) for a in [-2..2]]
1503
+ [A negative finite number, A negative finite number, Zero, A positive finite number, A positive finite number]
1504
+ """
1505
+ return self._repr_()
1506
+
1507
+ def __abs__(self):
1508
+ """
1509
+ EXAMPLES::
1510
+
1511
+ sage: abs(InfinityRing(-3))
1512
+ A positive finite number
1513
+ sage: abs(InfinityRing(3))
1514
+ A positive finite number
1515
+ sage: abs(InfinityRing(0))
1516
+ Zero
1517
+ """
1518
+ if self.value == 0:
1519
+ return FiniteNumber(self.parent(), 0)
1520
+ return FiniteNumber(self.parent(), 1)
1521
+
1522
+ def sign(self):
1523
+ """
1524
+ Return the sign of ``self``.
1525
+
1526
+ EXAMPLES::
1527
+
1528
+ sage: sign(InfinityRing(2))
1529
+ 1
1530
+ sage: sign(InfinityRing(0))
1531
+ 0
1532
+ sage: sign(InfinityRing(-2))
1533
+ -1
1534
+
1535
+ TESTS::
1536
+
1537
+ sage: sgn(InfinityRing(7))
1538
+ 1
1539
+ sage: sgn(InfinityRing(0))
1540
+ 0
1541
+ sage: sgn(InfinityRing(-7))
1542
+ -1
1543
+ """
1544
+ if self.value == 0:
1545
+ return 0
1546
+ if self.value > 0:
1547
+ return 1
1548
+ return -1
1549
+
1550
+ def sqrt(self):
1551
+ """
1552
+ EXAMPLES::
1553
+
1554
+ sage: InfinityRing(7).sqrt()
1555
+ A positive finite number
1556
+ sage: InfinityRing(0).sqrt()
1557
+ Zero
1558
+ sage: InfinityRing(-.001).sqrt()
1559
+ Traceback (most recent call last):
1560
+ ...
1561
+ SignError: cannot take square root of a negative number
1562
+ """
1563
+ if self.value < 0:
1564
+ raise SignError("cannot take square root of a negative number")
1565
+ return self
1566
+
1567
+
1568
+ class MinusInfinity(_uniq, AnInfinity, InfinityElement):
1569
+
1570
+ _sign = -1
1571
+ _sign_char = '-'
1572
+
1573
+ def __init__(self):
1574
+ """
1575
+ Initialize ``self``.
1576
+
1577
+ TESTS::
1578
+
1579
+ sage: sage.rings.infinity.MinusInfinity() is sage.rings.infinity.MinusInfinity() is -oo
1580
+ True
1581
+ """
1582
+ InfinityElement.__init__(self, InfinityRing)
1583
+
1584
+ def __hash__(self):
1585
+ r"""
1586
+ TESTS::
1587
+
1588
+ sage: hash(-infinity)
1589
+ -9223372036854775808 # 64-bit
1590
+ -2147483648 # 32-bit
1591
+ """
1592
+ return ~maxsize
1593
+
1594
+ def _richcmp_(self, other, op) -> bool:
1595
+ """
1596
+ Compare ``self`` and ``other``.
1597
+
1598
+ EXAMPLES::
1599
+
1600
+ sage: P = InfinityRing
1601
+ sage: -oo < P(-5) < P(0) < P(1.5) < oo
1602
+ True
1603
+ sage: P(1) < P(100)
1604
+ False
1605
+ sage: P(-1) == P(-100)
1606
+ True
1607
+ """
1608
+ if isinstance(other, MinusInfinity):
1609
+ return rich_to_bool(op, 0)
1610
+ return rich_to_bool(op, -1)
1611
+
1612
+ def _neg_(self):
1613
+ """
1614
+ EXAMPLES::
1615
+
1616
+ sage: -(-oo) # indirect doctest
1617
+ +Infinity
1618
+ """
1619
+ return self.parent().gen(0)
1620
+
1621
+ def sqrt(self):
1622
+ """
1623
+ EXAMPLES::
1624
+
1625
+ sage: (-oo).sqrt()
1626
+ Traceback (most recent call last):
1627
+ ...
1628
+ SignError: cannot take square root of negative infinity
1629
+ """
1630
+ raise SignError("cannot take square root of negative infinity")
1631
+
1632
+ def _sympy_(self):
1633
+ """
1634
+ Convert ``-oo`` to sympy ``-oo``.
1635
+
1636
+ Then you don't have to worry which ``oo`` you use, like in these
1637
+ examples:
1638
+
1639
+ EXAMPLES::
1640
+
1641
+ sage: # needs sympy
1642
+ sage: import sympy
1643
+ sage: bool(-oo == -sympy.oo)
1644
+ True
1645
+ sage: bool(SR(-oo) == -sympy.oo)
1646
+ True
1647
+ sage: bool((-oo)._sympy_() == -sympy.oo)
1648
+ True
1649
+ """
1650
+ import sympy
1651
+ return -sympy.oo
1652
+
1653
+ def _gap_init_(self) -> str:
1654
+ r"""
1655
+ Conversion to gap and libgap.
1656
+
1657
+ EXAMPLES::
1658
+
1659
+ sage: gap(-Infinity) # needs sage.libs.gap
1660
+ -infinity
1661
+ sage: libgap(-Infinity) # needs sage.libs.gap
1662
+ -infinity
1663
+ """
1664
+ return '-infinity'
1665
+
1666
+
1667
+ class PlusInfinity(_uniq, AnInfinity, InfinityElement):
1668
+
1669
+ _sign = 1
1670
+ _sign_char = '+'
1671
+
1672
+ def __init__(self):
1673
+ """
1674
+ Initialize ``self``.
1675
+
1676
+ TESTS::
1677
+
1678
+ sage: sage.rings.infinity.PlusInfinity() is sage.rings.infinity.PlusInfinity() is oo
1679
+ True
1680
+ """
1681
+ InfinityElement.__init__(self, InfinityRing)
1682
+
1683
+ def __hash__(self):
1684
+ r"""
1685
+ TESTS::
1686
+
1687
+ sage: hash(+infinity)
1688
+ 9223372036854775807 # 64-bit
1689
+ 2147483647 # 32-bit
1690
+ """
1691
+ return maxsize
1692
+
1693
+ def _richcmp_(self, other, op) -> bool:
1694
+ """
1695
+ Compare ``self`` and ``other``.
1696
+
1697
+ EXAMPLES::
1698
+
1699
+ sage: P = InfinityRing
1700
+ sage: -oo < P(-5) < P(0) < P(1.5) < oo
1701
+ True
1702
+ sage: P(1) < P(100)
1703
+ False
1704
+ sage: P(-1) == P(-100)
1705
+ True
1706
+ """
1707
+ if isinstance(other, PlusInfinity):
1708
+ return rich_to_bool(op, 0)
1709
+ return rich_to_bool(op, 1)
1710
+
1711
+ def _neg_(self):
1712
+ """
1713
+ TESTS::
1714
+
1715
+ sage: -oo # indirect doctest
1716
+ -Infinity
1717
+ """
1718
+ return self.parent().gen(1)
1719
+
1720
+ def sqrt(self):
1721
+ """
1722
+ The square root of ``self``.
1723
+
1724
+ The square root of infinity is infinity.
1725
+
1726
+ EXAMPLES::
1727
+
1728
+ sage: oo.sqrt()
1729
+ +Infinity
1730
+ """
1731
+ return self
1732
+
1733
+ def _sympy_(self):
1734
+ """
1735
+ Convert ``oo`` to sympy ``oo``.
1736
+
1737
+ Then you don't have to worry which ``oo`` you use, like in these
1738
+ examples:
1739
+
1740
+ EXAMPLES::
1741
+
1742
+ sage: import sympy # needs sympy
1743
+ sage: bool(oo == sympy.oo) # indirect doctest # needs sympy
1744
+ True
1745
+ sage: bool(SR(oo) == sympy.oo) # needs sympy sage.symbolic
1746
+ True
1747
+ """
1748
+ import sympy
1749
+ return sympy.oo
1750
+
1751
+ def _gap_init_(self) -> str:
1752
+ r"""
1753
+ Conversion to gap and libgap.
1754
+
1755
+ EXAMPLES::
1756
+
1757
+ sage: gap(+Infinity) # needs sage.libs.gap
1758
+ infinity
1759
+ sage: libgap(+Infinity) # needs sage.libs.gap
1760
+ infinity
1761
+ """
1762
+ return 'infinity'
1763
+
1764
+
1765
+ InfinityRing = InfinityRing_class()
1766
+ infinity = InfinityRing.gen(0)
1767
+ Infinity = infinity
1768
+ minus_infinity = InfinityRing.gen(1)
1769
+
1770
+
1771
+ def test_comparison(ring):
1772
+ """
1773
+ Check comparison with infinity.
1774
+
1775
+ INPUT:
1776
+
1777
+ - ``ring`` -- a sub-ring of the real numbers
1778
+
1779
+ OUTPUT:
1780
+
1781
+ Various attempts are made to generate elements of ``ring``. An
1782
+ assertion is triggered if one of these elements does not compare
1783
+ correctly with plus/minus infinity.
1784
+
1785
+ EXAMPLES::
1786
+
1787
+ sage: from sage.rings.infinity import test_comparison
1788
+ sage: rings = [ZZ, QQ, RDF]
1789
+ sage: rings += [RR, RealField(200)] # needs sage.rings.real_mpfr
1790
+ sage: rings += [RLF, RIF] # needs sage.rings.real_interval_field
1791
+ sage: for R in rings:
1792
+ ....: print('testing {}'.format(R))
1793
+ ....: test_comparison(R)
1794
+ testing Integer Ring
1795
+ testing Rational Field
1796
+ testing Real Double Field...
1797
+ sage: test_comparison(AA) # needs sage.rings.number_field
1798
+
1799
+ Comparison with number fields does not work::
1800
+
1801
+ sage: x = polygen(ZZ, 'x')
1802
+ sage: K.<sqrt3> = NumberField(x^2 - 3) # needs sage.rings.number_field
1803
+ sage: (-oo < 1 + sqrt3) and (1 + sqrt3 < oo) # known bug # needs sage.rings.number_field
1804
+ False
1805
+
1806
+ The symbolic ring handles its own infinities, but answers
1807
+ ``False`` (meaning: cannot decide) already for some very
1808
+ elementary comparisons::
1809
+
1810
+ sage: test_comparison(SR) # known bug # needs sage.symbolic
1811
+ Traceback (most recent call last):
1812
+ ...
1813
+ AssertionError: testing -1000.0 in Symbolic Ring: id = ...
1814
+ """
1815
+
1816
+ from sage.rings.rational_field import QQ
1817
+ elements = [-1e3, 99.9999, 0, 1, 100000]
1818
+ try:
1819
+ from sage.symbolic.ring import SR
1820
+ except ImportError:
1821
+ pass
1822
+ else:
1823
+ elements += [-SR(2).sqrt(), SR.pi(), 3 ** (-QQ.one() / 3)]
1824
+ elements.append(ring.an_element())
1825
+ elements.extend(ring.some_elements())
1826
+ for z in elements:
1827
+ try:
1828
+ z = ring(z)
1829
+ except (ValueError, TypeError):
1830
+ continue # ignore if z is not in ring
1831
+ msg = 'testing {} in {}: id = {}, {}, {}'.format(z, ring, id(z), id(infinity), id(minus_infinity))
1832
+ assert minus_infinity < z, msg
1833
+ assert z > minus_infinity, msg
1834
+ assert z < infinity, msg
1835
+ assert infinity > z, msg
1836
+ assert minus_infinity <= z, msg
1837
+ assert z >= minus_infinity, msg
1838
+ assert z <= infinity, msg
1839
+ assert infinity >= z, msg
1840
+
1841
+
1842
+ def test_signed_infinity(pos_inf):
1843
+ """
1844
+ Test consistency of infinity representations.
1845
+
1846
+ There are different possible representations of infinity in
1847
+ Sage. These are all consistent with the infinity ring, that is,
1848
+ compare with infinity in the expected way. See also :issue:`14045`
1849
+
1850
+ INPUT:
1851
+
1852
+ - ``pos_inf`` -- a representation of positive infinity
1853
+
1854
+ OUTPUT:
1855
+
1856
+ An assertion error is raised if the representation is not
1857
+ consistent with the infinity ring.
1858
+
1859
+ Check that :issue:`14045` is fixed::
1860
+
1861
+ sage: InfinityRing(float('+inf'))
1862
+ +Infinity
1863
+ sage: InfinityRing(float('-inf'))
1864
+ -Infinity
1865
+ sage: oo > float('+inf')
1866
+ False
1867
+ sage: oo == float('+inf')
1868
+ True
1869
+
1870
+ EXAMPLES::
1871
+
1872
+ sage: from sage.rings.infinity import test_signed_infinity
1873
+ sage: test_signed_infinity(oo)
1874
+ sage: test_signed_infinity(float('+inf'))
1875
+ sage: test_signed_infinity(RLF(oo)) # needs sage.rings.real_interval_field
1876
+ sage: test_signed_infinity(RIF(oo)) # needs sage.rings.real_interval_field
1877
+ sage: test_signed_infinity(SR(oo)) # needs sage.symbolic
1878
+ """
1879
+ msg = f'testing {pos_inf} ({type(pos_inf)})'
1880
+ assert InfinityRing(pos_inf) is infinity, msg
1881
+ assert InfinityRing(-pos_inf) is minus_infinity, msg
1882
+ assert infinity == pos_inf, msg
1883
+ assert not (infinity > pos_inf), msg
1884
+ assert not (infinity < pos_inf), msg
1885
+ assert minus_infinity == -pos_inf, msg
1886
+ assert not (minus_infinity > -pos_inf), msg
1887
+ assert not (minus_infinity < -pos_inf), msg
1888
+ assert pos_inf > -pos_inf, msg
1889
+ assert infinity > -pos_inf, msg
1890
+ assert pos_inf > minus_infinity, msg