passagemath-pari 10.6.32__cp314-cp314-musllinux_1_2_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-pari might be problematic. Click here for more details.

Files changed (331) hide show
  1. PARIKernel/__init__.py +2 -0
  2. PARIKernel/__main__.py +5 -0
  3. PARIKernel/io.cpython-314-x86_64-linux-musl.so +0 -0
  4. PARIKernel/io.pxd +7 -0
  5. PARIKernel/io.pyx +84 -0
  6. PARIKernel/kernel.cpython-314-x86_64-linux-musl.so +0 -0
  7. PARIKernel/kernel.pyx +260 -0
  8. PARIKernel/paridecl.pxd +95 -0
  9. PARIKernel/svg.cpython-314-x86_64-linux-musl.so +0 -0
  10. PARIKernel/svg.pyx +52 -0
  11. cypari2/__init__.py +8 -0
  12. cypari2/auto_paridecl.pxd +1070 -0
  13. cypari2/closure.cpython-314-x86_64-linux-musl.so +0 -0
  14. cypari2/closure.pxd +5 -0
  15. cypari2/closure.pyx +246 -0
  16. cypari2/convert.cpython-314-x86_64-linux-musl.so +0 -0
  17. cypari2/convert.pxd +80 -0
  18. cypari2/convert.pyx +613 -0
  19. cypari2/custom_block.cpython-314-x86_64-linux-musl.so +0 -0
  20. cypari2/custom_block.pyx +30 -0
  21. cypari2/cypari.h +13 -0
  22. cypari2/gen.cpython-314-x86_64-linux-musl.so +0 -0
  23. cypari2/gen.pxd +69 -0
  24. cypari2/gen.pyx +4819 -0
  25. cypari2/handle_error.cpython-314-x86_64-linux-musl.so +0 -0
  26. cypari2/handle_error.pxd +7 -0
  27. cypari2/handle_error.pyx +232 -0
  28. cypari2/pari_instance.cpython-314-x86_64-linux-musl.so +0 -0
  29. cypari2/pari_instance.pxd +27 -0
  30. cypari2/pari_instance.pyx +1438 -0
  31. cypari2/paridecl.pxd +5353 -0
  32. cypari2/paripriv.pxd +34 -0
  33. cypari2/pycore_long.h +98 -0
  34. cypari2/pycore_long.pxd +9 -0
  35. cypari2/stack.cpython-314-x86_64-linux-musl.so +0 -0
  36. cypari2/stack.pxd +27 -0
  37. cypari2/stack.pyx +278 -0
  38. cypari2/string_utils.cpython-314-x86_64-linux-musl.so +0 -0
  39. cypari2/string_utils.pxd +29 -0
  40. cypari2/string_utils.pyx +65 -0
  41. cypari2/types.pxd +147 -0
  42. passagemath_pari-10.6.32.data/data/etc/jupyter/nbconfig/notebook.d/gp-mode.json +5 -0
  43. passagemath_pari-10.6.32.data/data/share/jupyter/kernels/pari_jupyter/kernel.js +28 -0
  44. passagemath_pari-10.6.32.data/data/share/jupyter/kernels/pari_jupyter/kernel.json +6 -0
  45. passagemath_pari-10.6.32.data/data/share/jupyter/kernels/pari_jupyter/logo-64x64.png +0 -0
  46. passagemath_pari-10.6.32.data/data/share/jupyter/kernels/xeus-gp/kernel.json +13 -0
  47. passagemath_pari-10.6.32.data/data/share/jupyter/kernels/xeus-gp/logo-32x32.png +0 -0
  48. passagemath_pari-10.6.32.data/data/share/jupyter/kernels/xeus-gp/logo-64x64.png +0 -0
  49. passagemath_pari-10.6.32.data/data/share/jupyter/kernels/xeus-gp/logo-svg.svg +75 -0
  50. passagemath_pari-10.6.32.data/data/share/jupyter/nbextensions/gp-mode/gp.js +284 -0
  51. passagemath_pari-10.6.32.data/data/share/jupyter/nbextensions/gp-mode/main.js +15 -0
  52. passagemath_pari-10.6.32.dist-info/METADATA +209 -0
  53. passagemath_pari-10.6.32.dist-info/RECORD +331 -0
  54. passagemath_pari-10.6.32.dist-info/WHEEL +5 -0
  55. passagemath_pari-10.6.32.dist-info/top_level.txt +4 -0
  56. passagemath_pari.libs/libcrypto-f04afe95.so.3 +0 -0
  57. passagemath_pari.libs/libflint-fd6f12fc.so.21.0.0 +0 -0
  58. passagemath_pari.libs/libgcc_s-0cd532bd.so.1 +0 -0
  59. passagemath_pari.libs/libgf2x-9e30c3e3.so.3.0.0 +0 -0
  60. passagemath_pari.libs/libgfortran-2c33b284.so.5.0.0 +0 -0
  61. passagemath_pari.libs/libgivaro-9a94c711.so.9.2.1 +0 -0
  62. passagemath_pari.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
  63. passagemath_pari.libs/libgmpxx-9e08595c.so.4.7.0 +0 -0
  64. passagemath_pari.libs/libgsl-42cda06f.so.28.0.0 +0 -0
  65. passagemath_pari.libs/libmpfr-aaecbfc0.so.6.2.1 +0 -0
  66. passagemath_pari.libs/libncursesw-9c9e32c3.so.6.5 +0 -0
  67. passagemath_pari.libs/libntl-26885ca2.so.44.0.1 +0 -0
  68. passagemath_pari.libs/libopenblasp-r0-905cb27d.3.29.so +0 -0
  69. passagemath_pari.libs/libpari-gmp-tls-f31f908f.so.2.17.2 +0 -0
  70. passagemath_pari.libs/libquadmath-bb76a5fc.so.0.0.0 +0 -0
  71. passagemath_pari.libs/libreadline-06542304.so.8.2 +0 -0
  72. passagemath_pari.libs/libstdc++-5d72f927.so.6.0.33 +0 -0
  73. passagemath_pari.libs/libuuid-f3770415.so.1.3.0 +0 -0
  74. passagemath_pari.libs/libxeus-735780ff.so.13.1.0 +0 -0
  75. passagemath_pari.libs/libxeus-zmq-c68577b4.so.6.0.1 +0 -0
  76. passagemath_pari.libs/libzmq-1ba9a3da.so.5.2.5 +0 -0
  77. sage/all__sagemath_pari.py +26 -0
  78. sage/databases/all__sagemath_pari.py +7 -0
  79. sage/databases/conway.py +274 -0
  80. sage/ext/all__sagemath_pari.py +1 -0
  81. sage/ext/memory.cpython-314-x86_64-linux-musl.so +0 -0
  82. sage/ext/memory.pyx +98 -0
  83. sage/ext_data/pari/buzzard/DimensionSk.g +286 -0
  84. sage/ext_data/pari/buzzard/Tpprog.g +179 -0
  85. sage/ext_data/pari/buzzard/genusn.g +129 -0
  86. sage/ext_data/pari/dokchitser/computel.gp +740 -0
  87. sage/ext_data/pari/dokchitser/computel.gp.template +740 -0
  88. sage/ext_data/pari/dokchitser/ex-bsw +43 -0
  89. sage/ext_data/pari/dokchitser/ex-chgen +48 -0
  90. sage/ext_data/pari/dokchitser/ex-chqua +37 -0
  91. sage/ext_data/pari/dokchitser/ex-delta +35 -0
  92. sage/ext_data/pari/dokchitser/ex-eisen +30 -0
  93. sage/ext_data/pari/dokchitser/ex-gen2 +38 -0
  94. sage/ext_data/pari/dokchitser/ex-gen3 +49 -0
  95. sage/ext_data/pari/dokchitser/ex-gen4 +54 -0
  96. sage/ext_data/pari/dokchitser/ex-nf +48 -0
  97. sage/ext_data/pari/dokchitser/ex-shin +50 -0
  98. sage/ext_data/pari/dokchitser/ex-tau2 +30 -0
  99. sage/ext_data/pari/dokchitser/ex-zeta +27 -0
  100. sage/ext_data/pari/dokchitser/ex-zeta2 +47 -0
  101. sage/ext_data/pari/dokchitser/testall +13 -0
  102. sage/ext_data/pari/simon/ell.gp +2129 -0
  103. sage/ext_data/pari/simon/ellQ.gp +2151 -0
  104. sage/ext_data/pari/simon/ellcommon.gp +126 -0
  105. sage/ext_data/pari/simon/qfsolve.gp +722 -0
  106. sage/ext_data/pari/simon/resultant3.gp +306 -0
  107. sage/groups/all__sagemath_pari.py +3 -0
  108. sage/groups/pari_group.py +175 -0
  109. sage/interfaces/all__sagemath_pari.py +1 -0
  110. sage/interfaces/genus2reduction.py +464 -0
  111. sage/interfaces/gp.py +1114 -0
  112. sage/libs/all__sagemath_pari.py +2 -0
  113. sage/libs/linkages/__init__.py +1 -0
  114. sage/libs/linkages/padics/API.pxi +617 -0
  115. sage/libs/linkages/padics/Polynomial_ram.pxi +388 -0
  116. sage/libs/linkages/padics/Polynomial_shared.pxi +554 -0
  117. sage/libs/linkages/padics/__init__.py +1 -0
  118. sage/libs/linkages/padics/fmpz_poly_unram.pxi +869 -0
  119. sage/libs/linkages/padics/mpz.pxi +691 -0
  120. sage/libs/linkages/padics/relaxed/API.pxi +518 -0
  121. sage/libs/linkages/padics/relaxed/__init__.py +1 -0
  122. sage/libs/linkages/padics/relaxed/flint.pxi +543 -0
  123. sage/libs/linkages/padics/unram_shared.pxi +247 -0
  124. sage/libs/pari/__init__.py +210 -0
  125. sage/libs/pari/all.py +5 -0
  126. sage/libs/pari/convert_flint.cpython-314-x86_64-linux-musl.so +0 -0
  127. sage/libs/pari/convert_flint.pxd +14 -0
  128. sage/libs/pari/convert_flint.pyx +159 -0
  129. sage/libs/pari/convert_gmp.cpython-314-x86_64-linux-musl.so +0 -0
  130. sage/libs/pari/convert_gmp.pxd +14 -0
  131. sage/libs/pari/convert_gmp.pyx +210 -0
  132. sage/libs/pari/convert_sage.cpython-314-x86_64-linux-musl.so +0 -0
  133. sage/libs/pari/convert_sage.pxd +16 -0
  134. sage/libs/pari/convert_sage.pyx +588 -0
  135. sage/libs/pari/convert_sage_complex_double.cpython-314-x86_64-linux-musl.so +0 -0
  136. sage/libs/pari/convert_sage_complex_double.pxd +14 -0
  137. sage/libs/pari/convert_sage_complex_double.pyx +132 -0
  138. sage/libs/pari/convert_sage_matrix.cpython-314-x86_64-linux-musl.so +0 -0
  139. sage/libs/pari/convert_sage_matrix.pyx +106 -0
  140. sage/libs/pari/convert_sage_real_double.cpython-314-x86_64-linux-musl.so +0 -0
  141. sage/libs/pari/convert_sage_real_double.pxd +5 -0
  142. sage/libs/pari/convert_sage_real_double.pyx +14 -0
  143. sage/libs/pari/convert_sage_real_mpfr.cpython-314-x86_64-linux-musl.so +0 -0
  144. sage/libs/pari/convert_sage_real_mpfr.pxd +7 -0
  145. sage/libs/pari/convert_sage_real_mpfr.pyx +108 -0
  146. sage/libs/pari/misc.cpython-314-x86_64-linux-musl.so +0 -0
  147. sage/libs/pari/misc.pxd +4 -0
  148. sage/libs/pari/misc.pyx +26 -0
  149. sage/libs/pari/tests.py +1848 -0
  150. sage/matrix/all__sagemath_pari.py +1 -0
  151. sage/matrix/matrix_integer_pari.cpython-314-x86_64-linux-musl.so +0 -0
  152. sage/matrix/matrix_integer_pari.pyx +187 -0
  153. sage/matrix/matrix_rational_pari.cpython-314-x86_64-linux-musl.so +0 -0
  154. sage/matrix/matrix_rational_pari.pyx +160 -0
  155. sage/quadratic_forms/all__sagemath_pari.py +10 -0
  156. sage/quadratic_forms/genera/all.py +9 -0
  157. sage/quadratic_forms/genera/genus.py +3506 -0
  158. sage/quadratic_forms/genera/normal_form.py +1519 -0
  159. sage/quadratic_forms/genera/spinor_genus.py +243 -0
  160. sage/quadratic_forms/qfsolve.py +255 -0
  161. sage/quadratic_forms/quadratic_form__automorphisms.py +427 -0
  162. sage/quadratic_forms/quadratic_form__genus.py +141 -0
  163. sage/quadratic_forms/quadratic_form__local_density_interfaces.py +140 -0
  164. sage/quadratic_forms/quadratic_form__local_normal_form.py +421 -0
  165. sage/quadratic_forms/quadratic_form__local_representation_conditions.py +889 -0
  166. sage/quadratic_forms/quadratic_form__mass.py +69 -0
  167. sage/quadratic_forms/quadratic_form__mass__Conway_Sloane_masses.py +663 -0
  168. sage/quadratic_forms/quadratic_form__mass__Siegel_densities.py +373 -0
  169. sage/quadratic_forms/quadratic_form__siegel_product.py +198 -0
  170. sage/quadratic_forms/special_values.py +323 -0
  171. sage/rings/all__sagemath_pari.py +15 -0
  172. sage/rings/factorint_pari.cpython-314-x86_64-linux-musl.so +0 -0
  173. sage/rings/factorint_pari.pyx +80 -0
  174. sage/rings/finite_rings/all__sagemath_pari.py +1 -0
  175. sage/rings/finite_rings/element_givaro.cpython-314-x86_64-linux-musl.so +0 -0
  176. sage/rings/finite_rings/element_givaro.pxd +91 -0
  177. sage/rings/finite_rings/element_givaro.pyx +1769 -0
  178. sage/rings/finite_rings/element_ntl_gf2e.cpython-314-x86_64-linux-musl.so +0 -0
  179. sage/rings/finite_rings/element_ntl_gf2e.pxd +22 -0
  180. sage/rings/finite_rings/element_ntl_gf2e.pyx +1333 -0
  181. sage/rings/finite_rings/element_pari_ffelt.cpython-314-x86_64-linux-musl.so +0 -0
  182. sage/rings/finite_rings/element_pari_ffelt.pxd +13 -0
  183. sage/rings/finite_rings/element_pari_ffelt.pyx +1441 -0
  184. sage/rings/finite_rings/finite_field_givaro.py +612 -0
  185. sage/rings/finite_rings/finite_field_pari_ffelt.py +238 -0
  186. sage/rings/finite_rings/hom_finite_field_givaro.cpython-314-x86_64-linux-musl.so +0 -0
  187. sage/rings/finite_rings/hom_finite_field_givaro.pxd +28 -0
  188. sage/rings/finite_rings/hom_finite_field_givaro.pyx +280 -0
  189. sage/rings/finite_rings/residue_field_givaro.cpython-314-x86_64-linux-musl.so +0 -0
  190. sage/rings/finite_rings/residue_field_givaro.pyx +133 -0
  191. sage/rings/finite_rings/residue_field_pari_ffelt.cpython-314-x86_64-linux-musl.so +0 -0
  192. sage/rings/finite_rings/residue_field_pari_ffelt.pyx +128 -0
  193. sage/rings/function_field/all__sagemath_pari.py +1 -0
  194. sage/rings/function_field/valuation.py +1450 -0
  195. sage/rings/function_field/valuation_ring.py +212 -0
  196. sage/rings/number_field/all__sagemath_pari.py +14 -0
  197. sage/rings/number_field/totallyreal.cpython-314-x86_64-linux-musl.so +0 -0
  198. sage/rings/number_field/totallyreal.pyx +509 -0
  199. sage/rings/number_field/totallyreal_data.cpython-314-x86_64-linux-musl.so +0 -0
  200. sage/rings/number_field/totallyreal_data.pxd +26 -0
  201. sage/rings/number_field/totallyreal_data.pyx +928 -0
  202. sage/rings/number_field/totallyreal_phc.py +144 -0
  203. sage/rings/number_field/totallyreal_rel.py +1018 -0
  204. sage/rings/padics/CA_template.pxi +1847 -0
  205. sage/rings/padics/CA_template_header.pxi +50 -0
  206. sage/rings/padics/CR_template.pxi +2563 -0
  207. sage/rings/padics/CR_template_header.pxi +57 -0
  208. sage/rings/padics/FM_template.pxi +1575 -0
  209. sage/rings/padics/FM_template_header.pxi +50 -0
  210. sage/rings/padics/FP_template.pxi +2176 -0
  211. sage/rings/padics/FP_template_header.pxi +57 -0
  212. sage/rings/padics/all.py +3 -0
  213. sage/rings/padics/all__sagemath_pari.py +11 -0
  214. sage/rings/padics/common_conversion.cpython-314-x86_64-linux-musl.so +0 -0
  215. sage/rings/padics/common_conversion.pxd +15 -0
  216. sage/rings/padics/common_conversion.pyx +508 -0
  217. sage/rings/padics/eisenstein_extension_generic.py +232 -0
  218. sage/rings/padics/factory.py +3623 -0
  219. sage/rings/padics/generic_nodes.py +1615 -0
  220. sage/rings/padics/lattice_precision.py +2889 -0
  221. sage/rings/padics/morphism.cpython-314-x86_64-linux-musl.so +0 -0
  222. sage/rings/padics/morphism.pxd +11 -0
  223. sage/rings/padics/morphism.pyx +366 -0
  224. sage/rings/padics/padic_base_generic.py +467 -0
  225. sage/rings/padics/padic_base_leaves.py +1235 -0
  226. sage/rings/padics/padic_capped_absolute_element.cpython-314-x86_64-linux-musl.so +0 -0
  227. sage/rings/padics/padic_capped_absolute_element.pxd +15 -0
  228. sage/rings/padics/padic_capped_absolute_element.pyx +520 -0
  229. sage/rings/padics/padic_capped_relative_element.cpython-314-x86_64-linux-musl.so +0 -0
  230. sage/rings/padics/padic_capped_relative_element.pxd +14 -0
  231. sage/rings/padics/padic_capped_relative_element.pyx +614 -0
  232. sage/rings/padics/padic_extension_generic.py +990 -0
  233. sage/rings/padics/padic_extension_leaves.py +738 -0
  234. sage/rings/padics/padic_fixed_mod_element.cpython-314-x86_64-linux-musl.so +0 -0
  235. sage/rings/padics/padic_fixed_mod_element.pxd +15 -0
  236. sage/rings/padics/padic_fixed_mod_element.pyx +584 -0
  237. sage/rings/padics/padic_floating_point_element.cpython-314-x86_64-linux-musl.so +0 -0
  238. sage/rings/padics/padic_floating_point_element.pxd +14 -0
  239. sage/rings/padics/padic_floating_point_element.pyx +447 -0
  240. sage/rings/padics/padic_generic_element.cpython-314-x86_64-linux-musl.so +0 -0
  241. sage/rings/padics/padic_generic_element.pxd +48 -0
  242. sage/rings/padics/padic_generic_element.pyx +4642 -0
  243. sage/rings/padics/padic_lattice_element.py +1342 -0
  244. sage/rings/padics/padic_printing.cpython-314-x86_64-linux-musl.so +0 -0
  245. sage/rings/padics/padic_printing.pxd +38 -0
  246. sage/rings/padics/padic_printing.pyx +1505 -0
  247. sage/rings/padics/padic_relaxed_element.cpython-314-x86_64-linux-musl.so +0 -0
  248. sage/rings/padics/padic_relaxed_element.pxd +56 -0
  249. sage/rings/padics/padic_relaxed_element.pyx +18 -0
  250. sage/rings/padics/padic_relaxed_errors.cpython-314-x86_64-linux-musl.so +0 -0
  251. sage/rings/padics/padic_relaxed_errors.pxd +11 -0
  252. sage/rings/padics/padic_relaxed_errors.pyx +71 -0
  253. sage/rings/padics/padic_template_element.pxi +1212 -0
  254. sage/rings/padics/padic_template_element_header.pxi +50 -0
  255. sage/rings/padics/padic_valuation.py +1423 -0
  256. sage/rings/padics/pow_computer_flint.cpython-314-x86_64-linux-musl.so +0 -0
  257. sage/rings/padics/pow_computer_flint.pxd +38 -0
  258. sage/rings/padics/pow_computer_flint.pyx +641 -0
  259. sage/rings/padics/pow_computer_relative.cpython-314-x86_64-linux-musl.so +0 -0
  260. sage/rings/padics/pow_computer_relative.pxd +29 -0
  261. sage/rings/padics/pow_computer_relative.pyx +415 -0
  262. sage/rings/padics/qadic_flint_CA.cpython-314-x86_64-linux-musl.so +0 -0
  263. sage/rings/padics/qadic_flint_CA.pxd +21 -0
  264. sage/rings/padics/qadic_flint_CA.pyx +130 -0
  265. sage/rings/padics/qadic_flint_CR.cpython-314-x86_64-linux-musl.so +0 -0
  266. sage/rings/padics/qadic_flint_CR.pxd +13 -0
  267. sage/rings/padics/qadic_flint_CR.pyx +172 -0
  268. sage/rings/padics/qadic_flint_FM.cpython-314-x86_64-linux-musl.so +0 -0
  269. sage/rings/padics/qadic_flint_FM.pxd +14 -0
  270. sage/rings/padics/qadic_flint_FM.pyx +111 -0
  271. sage/rings/padics/qadic_flint_FP.cpython-314-x86_64-linux-musl.so +0 -0
  272. sage/rings/padics/qadic_flint_FP.pxd +12 -0
  273. sage/rings/padics/qadic_flint_FP.pyx +165 -0
  274. sage/rings/padics/relative_extension_leaves.py +429 -0
  275. sage/rings/padics/relative_ramified_CA.cpython-314-x86_64-linux-musl.so +0 -0
  276. sage/rings/padics/relative_ramified_CA.pxd +9 -0
  277. sage/rings/padics/relative_ramified_CA.pyx +33 -0
  278. sage/rings/padics/relative_ramified_CR.cpython-314-x86_64-linux-musl.so +0 -0
  279. sage/rings/padics/relative_ramified_CR.pxd +8 -0
  280. sage/rings/padics/relative_ramified_CR.pyx +33 -0
  281. sage/rings/padics/relative_ramified_FM.cpython-314-x86_64-linux-musl.so +0 -0
  282. sage/rings/padics/relative_ramified_FM.pxd +9 -0
  283. sage/rings/padics/relative_ramified_FM.pyx +33 -0
  284. sage/rings/padics/relative_ramified_FP.cpython-314-x86_64-linux-musl.so +0 -0
  285. sage/rings/padics/relative_ramified_FP.pxd +8 -0
  286. sage/rings/padics/relative_ramified_FP.pyx +33 -0
  287. sage/rings/padics/relaxed_template.pxi +4229 -0
  288. sage/rings/padics/relaxed_template_header.pxi +160 -0
  289. sage/rings/padics/tests.py +35 -0
  290. sage/rings/padics/tutorial.py +341 -0
  291. sage/rings/padics/unramified_extension_generic.py +335 -0
  292. sage/rings/padics/witt_vector.py +917 -0
  293. sage/rings/padics/witt_vector_ring.py +934 -0
  294. sage/rings/pari_ring.py +235 -0
  295. sage/rings/polynomial/all__sagemath_pari.py +1 -0
  296. sage/rings/polynomial/padics/all.py +1 -0
  297. sage/rings/polynomial/padics/polynomial_padic.py +360 -0
  298. sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py +1324 -0
  299. sage/rings/polynomial/padics/polynomial_padic_flat.py +72 -0
  300. sage/rings/power_series_pari.cpython-314-x86_64-linux-musl.so +0 -0
  301. sage/rings/power_series_pari.pxd +6 -0
  302. sage/rings/power_series_pari.pyx +934 -0
  303. sage/rings/tate_algebra.py +1282 -0
  304. sage/rings/tate_algebra_element.cpython-314-x86_64-linux-musl.so +0 -0
  305. sage/rings/tate_algebra_element.pxd +49 -0
  306. sage/rings/tate_algebra_element.pyx +3464 -0
  307. sage/rings/tate_algebra_ideal.cpython-314-x86_64-linux-musl.so +0 -0
  308. sage/rings/tate_algebra_ideal.pxd +7 -0
  309. sage/rings/tate_algebra_ideal.pyx +1307 -0
  310. sage/rings/valuation/all.py +7 -0
  311. sage/rings/valuation/augmented_valuation.py +2118 -0
  312. sage/rings/valuation/developing_valuation.py +362 -0
  313. sage/rings/valuation/gauss_valuation.py +812 -0
  314. sage/rings/valuation/inductive_valuation.py +1686 -0
  315. sage/rings/valuation/limit_valuation.py +946 -0
  316. sage/rings/valuation/mapped_valuation.py +656 -0
  317. sage/rings/valuation/scaled_valuation.py +322 -0
  318. sage/rings/valuation/trivial_valuation.py +382 -0
  319. sage/rings/valuation/valuation.py +1119 -0
  320. sage/rings/valuation/valuation_space.py +1615 -0
  321. sage/rings/valuation/valuations_catalog.py +10 -0
  322. sage/rings/valuation/value_group.py +697 -0
  323. sage/schemes/all__sagemath_pari.py +1 -0
  324. sage/schemes/elliptic_curves/all__sagemath_pari.py +1 -0
  325. sage/schemes/elliptic_curves/descent_two_isogeny_pari.cpython-314-x86_64-linux-musl.so +0 -0
  326. sage/schemes/elliptic_curves/descent_two_isogeny_pari.pyx +46 -0
  327. sage_wheels/bin/gp +0 -0
  328. sage_wheels/bin/gp2c +0 -0
  329. sage_wheels/bin/gp2c-run +57 -0
  330. sage_wheels/bin/xeus-gp +0 -0
  331. sage_wheels/share/gp2c/func.dsc +18414 -0
@@ -0,0 +1,1615 @@
1
+ # sage_setup: distribution = sagemath-pari
2
+ """
3
+ `p`-adic Generic Nodes
4
+
5
+ This file contains a bunch of intermediate classes for the `p`-adic
6
+ parents, allowing a function to be implemented at the right level of
7
+ generality.
8
+
9
+ AUTHORS:
10
+
11
+ - David Roe
12
+ """
13
+
14
+ # ****************************************************************************
15
+ # Copyright (C) 2007-2013 David Roe <roed.math@gmail.com>
16
+ # William Stein <wstein@gmail.com>
17
+ #
18
+ # Distributed under the terms of the GNU General Public License (GPL)
19
+ # as published by the Free Software Foundation; either version 2 of
20
+ # the License, or (at your option) any later version.
21
+ #
22
+ # http://www.gnu.org/licenses/
23
+ #*****************************************************************************
24
+
25
+ from sage.rings.padics.local_generic import LocalGeneric
26
+ from sage.rings.padics.padic_generic import pAdicGeneric
27
+ import sage.rings.abc
28
+ from sage.rings.padics.padic_base_generic import pAdicBaseGeneric
29
+ from sage.rings.integer_ring import ZZ
30
+ from sage.rings.rational_field import QQ
31
+ from sage.rings.infinity import infinity, SignError
32
+ from .lattice_precision import PrecisionLattice, PrecisionModule
33
+ from sage.rings.padics.precision_error import PrecisionError
34
+ from .padic_lattice_element import pAdicLatticeElement, pAdicLatticeCapElement, pAdicLatticeFloatElement
35
+
36
+
37
+ class CappedAbsoluteGeneric(LocalGeneric):
38
+ def is_capped_absolute(self):
39
+ """
40
+ Return whether this `p`-adic ring bounds precision in a
41
+ capped absolute fashion.
42
+
43
+ The absolute precision of an element is the power of `p` modulo
44
+ which that element is defined. In a capped absolute ring, the
45
+ absolute precision of elements are bounded by a constant
46
+ depending on the ring.
47
+
48
+ EXAMPLES::
49
+
50
+ sage: R = ZpCA(5, 15)
51
+ sage: R.is_capped_absolute()
52
+ True
53
+ sage: R(5^7)
54
+ 5^7 + O(5^15)
55
+ sage: S = Zp(5, 15)
56
+ sage: S.is_capped_absolute()
57
+ False
58
+ sage: S(5^7)
59
+ 5^7 + O(5^22)
60
+ """
61
+ return True
62
+
63
+ def _prec_type(self):
64
+ """
65
+ Return the precision handling type.
66
+
67
+ EXAMPLES::
68
+
69
+ sage: ZpCA(5)._prec_type()
70
+ 'capped-abs'
71
+ """
72
+ return 'capped-abs'
73
+
74
+
75
+ class CappedRelativeGeneric(LocalGeneric):
76
+ def is_capped_relative(self):
77
+ """
78
+ Return whether this `p`-adic ring bounds precision in a capped
79
+ relative fashion.
80
+
81
+ The relative precision of an element is the power of p modulo
82
+ which the unit part of that element is defined. In a capped
83
+ relative ring, the relative precision of elements are bounded
84
+ by a constant depending on the ring.
85
+
86
+ EXAMPLES::
87
+
88
+ sage: R = ZpCA(5, 15)
89
+ sage: R.is_capped_relative()
90
+ False
91
+ sage: R(5^7)
92
+ 5^7 + O(5^15)
93
+ sage: S = Zp(5, 15)
94
+ sage: S.is_capped_relative()
95
+ True
96
+ sage: S(5^7)
97
+ 5^7 + O(5^22)
98
+ """
99
+ return True
100
+
101
+ def _prec_type(self):
102
+ """
103
+ Return the precision handling type.
104
+
105
+ EXAMPLES::
106
+
107
+ sage: Zp(5)._prec_type()
108
+ 'capped-rel'
109
+ """
110
+ return 'capped-rel'
111
+
112
+
113
+ class FixedModGeneric(LocalGeneric):
114
+ def is_fixed_mod(self):
115
+ """
116
+ Return whether this `p`-adic ring bounds precision in a fixed
117
+ modulus fashion.
118
+
119
+ The absolute precision of an element is the power of p modulo
120
+ which that element is defined. In a fixed modulus ring, the
121
+ absolute precision of every element is defined to be the
122
+ precision cap of the parent. This means that some operations,
123
+ such as division by `p`, don't return a well defined answer.
124
+
125
+ EXAMPLES::
126
+
127
+ sage: R = ZpFM(5,15)
128
+ sage: R.is_fixed_mod()
129
+ True
130
+ sage: R(5^7,absprec=9)
131
+ 5^7
132
+ sage: S = ZpCA(5, 15)
133
+ sage: S.is_fixed_mod()
134
+ False
135
+ sage: S(5^7,absprec=9)
136
+ 5^7 + O(5^9)
137
+ """
138
+ return True
139
+
140
+ def _prec_type(self):
141
+ """
142
+ Return the precision handling type.
143
+
144
+ EXAMPLES::
145
+
146
+ sage: ZpFM(5)._prec_type()
147
+ 'fixed-mod'
148
+ """
149
+ return 'fixed-mod'
150
+
151
+
152
+ class FloatingPointGeneric(LocalGeneric):
153
+ def is_floating_point(self):
154
+ """
155
+ Return whether this `p`-adic ring uses a floating point precision model.
156
+
157
+ Elements in the floating point model are stored by giving a
158
+ valuation and a unit part. Arithmetic is done where the unit
159
+ part is truncated modulo a fixed power of the uniformizer,
160
+ stored in the precision cap of the parent.
161
+
162
+ EXAMPLES::
163
+
164
+ sage: R = ZpFP(5,15)
165
+ sage: R.is_floating_point()
166
+ True
167
+ sage: R(5^7,absprec=9)
168
+ 5^7
169
+ sage: S = ZpCR(5,15)
170
+ sage: S.is_floating_point()
171
+ False
172
+ sage: S(5^7,absprec=9)
173
+ 5^7 + O(5^9)
174
+ """
175
+ return True
176
+
177
+ def _prec_type(self):
178
+ """
179
+ Return the precision handling type.
180
+
181
+ EXAMPLES::
182
+
183
+ sage: ZpFP(5)._prec_type()
184
+ 'floating-point'
185
+ """
186
+ return 'floating-point'
187
+
188
+ def _test_distributivity(self, **options):
189
+ r"""
190
+ Test the distributivity of `*` on `+` on (not necessarily
191
+ all) elements of this set.
192
+
193
+ `p`-adic floating point rings only satisfy distributivity
194
+ up to a precision that depends on the elements.
195
+
196
+ INPUT:
197
+
198
+ - ``options`` -- any keyword arguments accepted by :meth:`_tester`
199
+
200
+ EXAMPLES:
201
+
202
+ By default, this method runs the tests only on the
203
+ elements returned by ``self.some_elements()``::
204
+
205
+ sage: R = ZpFP(5,3)
206
+ sage: R.some_elements()
207
+ [0, 1, 5, 1 + 3*5 + 3*5^2, 5 + 4*5^2 + 4*5^3]
208
+ sage: R._test_distributivity()
209
+
210
+ However, the elements tested can be customized with the
211
+ ``elements`` keyword argument::
212
+
213
+ sage: R._test_distributivity(elements=[R(0),~R(0),R(42)])
214
+
215
+ See the documentation for :class:`TestSuite` for more information.
216
+ """
217
+ tester = self._tester(**options)
218
+ S = tester.some_elements()
219
+ from sage.misc.misc import some_tuples
220
+ for x,y,z in some_tuples(S, 3, tester._max_runs):
221
+ yz_prec = min(y.precision_absolute(), z.precision_absolute())
222
+ yz_val = (y + z).valuation()
223
+ try:
224
+ prec = min(x.valuation() + yz_val + min(x.precision_relative(), yz_prec - yz_val),
225
+ x.valuation() + y.valuation() + (x * y).precision_relative(),
226
+ x.valuation() + z.valuation() + (x * z).precision_relative())
227
+ except SignError:
228
+ pass
229
+ else:
230
+ if prec > -infinity:
231
+ # only check left distributivity, since multiplication commutative
232
+ tester.assertTrue((x * (y + z)).is_equal_to((x * y) + (x * z),prec))
233
+
234
+ def _test_additive_associativity(self, **options):
235
+ r"""
236
+ Test associativity for (not necessarily all) elements of this
237
+ additive semigroup.
238
+
239
+ INPUT:
240
+
241
+ - ``options`` -- any keyword arguments accepted by :meth:`_tester`
242
+
243
+ EXAMPLES:
244
+
245
+ By default, this method tests only the elements returned by
246
+ ``self.some_elements()``::
247
+
248
+ sage: R = QpFP(7,3)
249
+ sage: R._test_additive_associativity()
250
+
251
+ However, the elements tested can be customized with the
252
+ ``elements`` keyword argument::
253
+
254
+ sage: R._test_additive_associativity(elements = [R(0), ~R(0), R(42)])
255
+
256
+ See the documentation for :class:`TestSuite` for more information.
257
+ """
258
+ tester = self._tester(**options)
259
+ S = tester.some_elements()
260
+ from sage.misc.misc import some_tuples
261
+ for x, y, z in some_tuples(S, 3, tester._max_runs):
262
+ tester.assertTrue(((x + y) + z).is_equal_to(x + (y + z), min(x.precision_absolute(), y.precision_absolute(), z.precision_absolute())))
263
+
264
+
265
+ class FloatingPointRingGeneric(FloatingPointGeneric):
266
+ pass
267
+
268
+
269
+ class FloatingPointFieldGeneric(FloatingPointGeneric):
270
+ # in category of Fields()
271
+ pass
272
+
273
+
274
+ class CappedRelativeRingGeneric(CappedRelativeGeneric):
275
+ pass
276
+
277
+
278
+ class CappedRelativeFieldGeneric(CappedRelativeGeneric):
279
+ # in category of Fields()
280
+ pass
281
+
282
+
283
+ class pAdicLatticeGeneric(pAdicGeneric):
284
+ r"""
285
+ An implementation of the `p`-adic rationals with lattice precision.
286
+
287
+ INPUT:
288
+
289
+ - ``p`` -- the underlying prime number
290
+
291
+ - ``prec`` -- the precision
292
+
293
+ - ``subtype`` -- either ``'cap'`` or ``'float'``,
294
+ specifying the precision model used for tracking precision
295
+
296
+ - ``label`` -- string or ``None`` (default: ``None``)
297
+
298
+ TESTS::
299
+
300
+ sage: R = ZpLC(17) # indirect doctest
301
+ doctest:...: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation.
302
+ See https://github.com/sagemath/sage/issues/23505 for details.
303
+ sage: R._prec_type()
304
+ 'lattice-cap'
305
+
306
+ sage: R = ZpLF(17) # indirect doctest
307
+ sage: R._prec_type()
308
+ 'lattice-float'
309
+
310
+ sage: R = QpLC(17) # indirect doctest
311
+ sage: R._prec_type()
312
+ 'lattice-cap'
313
+
314
+ sage: R = QpLF(17) # indirect doctest
315
+ sage: R._prec_type()
316
+ 'lattice-float'
317
+ """
318
+ def __init__(self, p, prec, print_mode, names, label=None, category=None):
319
+ """
320
+ Initialization.
321
+
322
+ TESTS::
323
+
324
+ sage: R = ZpLC(17) # indirect doctest
325
+ sage: R._prec_type()
326
+ 'lattice-cap'
327
+ sage: R._subtype
328
+ 'cap'
329
+
330
+ sage: R = ZpLF(17) # indirect doctest
331
+ sage: R._prec_type()
332
+ 'lattice-float'
333
+ sage: R._subtype
334
+ 'float'
335
+ """
336
+ from sage.rings.padics.lattice_precision import pRational
337
+ self._approx_zero = pRational(p, 0)
338
+ self._approx_one = pRational(p, 1)
339
+ self._approx_minusone = pRational(p, -1)
340
+ if label is None:
341
+ self._label = None
342
+ else:
343
+ self._label = str(label)
344
+ # We do not use the standard attribute element_class
345
+ # because we need to be careful with precision
346
+ # Instead we implement _element_constructor_ (cf below)
347
+ if self._subtype == 'cap':
348
+ (self._prec_cap_relative, self._prec_cap_absolute) = prec
349
+ self._zero_cap = None
350
+ self._precision = PrecisionLattice(p, label)
351
+ element_class = pAdicLatticeCapElement
352
+ elif self._subtype == 'float':
353
+ self._prec_cap_relative = prec
354
+ self._prec_cap_absolute = infinity
355
+ self._zero_cap = prec
356
+ self._precision = PrecisionModule(p, label, prec)
357
+ element_class = pAdicLatticeFloatElement
358
+ else:
359
+ raise ValueError("subtype must be either 'cap' or 'float'")
360
+ self._element_class = self.__make_element_class__(element_class)
361
+ pAdicGeneric.__init__(self, self, p, prec, print_mode, names, None, category=category)
362
+
363
+ def _prec_type(self):
364
+ """
365
+ Return the precision handling type.
366
+
367
+ EXAMPLES::
368
+
369
+ sage: ZpLC(5)._prec_type()
370
+ 'lattice-cap'
371
+ """
372
+ return 'lattice-' + self._subtype
373
+
374
+ def is_lattice_prec(self):
375
+ """
376
+ Return whether this `p`-adic ring bounds precision using
377
+ a lattice model.
378
+
379
+ In lattice precision, relationships between elements
380
+ are stored in a precision object of the parent, which
381
+ allows for optimal precision tracking at the cost of
382
+ increased memory usage and runtime.
383
+
384
+ EXAMPLES::
385
+
386
+ sage: R = ZpCR(5, 15)
387
+ sage: R.is_lattice_prec()
388
+ False
389
+ sage: x = R(25, 8)
390
+ sage: x - x
391
+ O(5^8)
392
+ sage: S = ZpLC(5, 15)
393
+ sage: S.is_lattice_prec()
394
+ True
395
+ sage: x = S(25, 8)
396
+ sage: x - x
397
+ O(5^30)
398
+ """
399
+ return True
400
+
401
+ def precision_cap(self):
402
+ """
403
+ Return the relative precision cap for this ring if it is finite.
404
+ Otherwise return the absolute precision cap.
405
+
406
+ EXAMPLES::
407
+
408
+ sage: R = ZpLC(3)
409
+ sage: R.precision_cap()
410
+ 20
411
+ sage: R.precision_cap_relative()
412
+ 20
413
+
414
+ sage: R = ZpLC(3, prec=(infinity,20))
415
+ sage: R.precision_cap()
416
+ 20
417
+ sage: R.precision_cap_relative()
418
+ +Infinity
419
+ sage: R.precision_cap_absolute()
420
+ 20
421
+
422
+ .. SEEALSO::
423
+
424
+ :meth:`precision_cap_relative`, :meth:`precision_cap_absolute`
425
+ """
426
+ if self._prec_cap_relative is not infinity:
427
+ return self._prec_cap_relative
428
+ else:
429
+ return self._prec_cap_absolute
430
+
431
+ def _precision_cap(self):
432
+ """
433
+ Return the pair of precisions (for ``lattice-cap``)
434
+ or the relative precision cap (for ``lattice-float``).
435
+
436
+ EXAMPLES::
437
+
438
+ sage: R = ZpLC(11, (27,37))
439
+ sage: R._precision_cap()
440
+ (27, 37)
441
+ sage: R = ZpLF(11, 14)
442
+ sage: R._precision_cap()
443
+ 14
444
+ """
445
+ if self._subtype == 'cap':
446
+ return (self._prec_cap_relative, self._prec_cap_absolute)
447
+ else:
448
+ return self._prec_cap_relative
449
+
450
+ def precision_cap_relative(self):
451
+ """
452
+ Return the relative precision cap for this ring.
453
+
454
+ EXAMPLES::
455
+
456
+ sage: R = ZpLC(3)
457
+ sage: R.precision_cap_relative()
458
+ 20
459
+
460
+ sage: R = ZpLC(3, prec=(infinity,20))
461
+ sage: R.precision_cap_relative()
462
+ +Infinity
463
+
464
+ .. SEEALSO::
465
+
466
+ :meth:`precision_cap`, :meth:`precision_cap_absolute`
467
+ """
468
+ return self._prec_cap_relative
469
+
470
+ def precision_cap_absolute(self):
471
+ """
472
+ Return the absolute precision cap for this ring.
473
+
474
+ EXAMPLES::
475
+
476
+ sage: R = ZpLC(3)
477
+ sage: R.precision_cap_absolute()
478
+ 40
479
+
480
+ sage: R = ZpLC(3, prec=(infinity,20))
481
+ sage: R.precision_cap_absolute()
482
+ 20
483
+
484
+ .. SEEALSO::
485
+
486
+ :meth:`precision_cap`, :meth:`precision_cap_relative`
487
+ """
488
+ return self._prec_cap_absolute
489
+
490
+ def precision(self):
491
+ """
492
+ Return the lattice precision object attached to this parent.
493
+
494
+ EXAMPLES::
495
+
496
+ sage: R = ZpLC(5, label='precision')
497
+ sage: R.precision()
498
+ Precision lattice on 0 objects (label: precision)
499
+
500
+ sage: x = R(1, 10); y = R(1, 5)
501
+ sage: R.precision()
502
+ Precision lattice on 2 objects (label: precision)
503
+
504
+ .. SEEALSO::
505
+
506
+ :class:`sage.rings.padics.lattice_precision.PrecisionLattice`
507
+ """
508
+ return self._precision
509
+
510
+ def label(self):
511
+ """
512
+ Return the label of this parent.
513
+
514
+ NOTE:
515
+
516
+ Labels can be used to distinguish between parents with
517
+ the same defining data.
518
+
519
+ They are useful in the lattice precision framework in order
520
+ to limit the size of the lattice modeling the precision (which
521
+ is roughly the number of elements having this parent).
522
+
523
+ Elements of a parent with some label do not coerce to a parent
524
+ with a different label. However conversions are allowed.
525
+
526
+ EXAMPLES::
527
+
528
+ sage: R = ZpLC(5)
529
+ sage: R.label() # no label by default
530
+
531
+ sage: R = ZpLC(5, label='mylabel')
532
+ sage: R.label()
533
+ 'mylabel'
534
+
535
+ Labels are typically useful to isolate computations.
536
+ For example, assume that we first want to do some calculations
537
+ with matrices::
538
+
539
+ sage: R = ZpLC(5, label='matrices')
540
+ sage: M = random_matrix(R, 4, 4) # needs sage.geometry.polyhedron
541
+ sage: d = M.determinant() # needs sage.geometry.polyhedron
542
+
543
+ Now, if we want to do another unrelated computation, we can
544
+ use a different label::
545
+
546
+ sage: R = ZpLC(5, label='polynomials')
547
+ sage: S.<x> = PolynomialRing(R)
548
+ sage: P = (x-1)*(x-2)*(x-3)*(x-4)*(x-5)
549
+
550
+ Without labels, the software would have modeled the
551
+ precision on the matrices and on the polynomials using the same
552
+ lattice (manipulating a lattice of higher
553
+ dimension can have a significant impact on performance).
554
+ """
555
+ return self._label
556
+
557
+ def _element_constructor_(self, x, prec=None):
558
+ """
559
+ Create an element of this parent.
560
+
561
+ INPUT:
562
+
563
+ - ``x`` -- the datum from which the element is created
564
+
565
+ - ``prec`` -- integer or ``None`` (the default); the
566
+ absolute precision of the created element
567
+
568
+ NOTE:
569
+
570
+ This function tries to be sharp on precision as much as
571
+ possible.
572
+ For instance, if the datum ``x`` is itself an element of the
573
+ same parent, the software remembers that the created element
574
+ is actually equal to ``x`` (at infinite precision)::
575
+
576
+ sage: R = ZpLC(2, prec=(infinity,50))
577
+ sage: x = R(1, 10); x
578
+ 1 + O(2^10)
579
+ sage: y = R(x) # indirect doctest
580
+ sage: y
581
+ 1 + O(2^10)
582
+ sage: x - y
583
+ O(2^50)
584
+
585
+ TESTS::
586
+
587
+ sage: R(x, prec=5)
588
+ 1 + O(2^5)
589
+ """
590
+ # We first try the _copy method which is sharp on precision
591
+ try:
592
+ if prec is None:
593
+ return x._copy(parent=self)
594
+ elif x.parent() is self:
595
+ return x.add_bigoh(prec)
596
+ else:
597
+ return x._copy(parent=self).add_bigoh(prec)
598
+ except (TypeError, ValueError, AttributeError):
599
+ pass
600
+ return self._element_class(self, x, prec)
601
+
602
+ def convert_multiple(self, *elts):
603
+ """
604
+ Convert a list of elements to this parent.
605
+
606
+ NOTE:
607
+
608
+ This function tries to be sharp on precision as much as
609
+ possible.
610
+ In particular, if the precision of the input elements are
611
+ handled by a lattice, diffused digits of precision are
612
+ preserved during the conversion.
613
+
614
+ EXAMPLES::
615
+
616
+ sage: R = ZpLC(2)
617
+ sage: x = R(1, 10); y = R(1, 5)
618
+ sage: x,y = x+y, x-y
619
+
620
+ Remark that the pair `(x,y)` has diffused digits of precision::
621
+
622
+ sage: x
623
+ 2 + O(2^5)
624
+ sage: y
625
+ O(2^5)
626
+ sage: x + y
627
+ 2 + O(2^11)
628
+
629
+ sage: R.precision().diffused_digits([x,y]) # needs sage.geometry.polyhedron
630
+ 6
631
+
632
+ As a consequence, if we convert ``x`` and ``y`` separately, we
633
+ lose some precision::
634
+
635
+ sage: R2 = ZpLC(2, label='copy')
636
+ sage: x2 = R2(x); y2 = R2(y)
637
+ sage: x2
638
+ 2 + O(2^5)
639
+ sage: y2
640
+ O(2^5)
641
+ sage: x2 + y2
642
+ 2 + O(2^5)
643
+
644
+ sage: R2.precision().diffused_digits([x2,y2]) # needs sage.geometry.polyhedron
645
+ 0
646
+
647
+ On the other hand, this issue disappears when we use multiple
648
+ conversion::
649
+
650
+ sage: x2,y2 = R2.convert_multiple(x,y) # needs sage.geometry.polyhedron
651
+ sage: x2 + y2 # needs sage.geometry.polyhedron sage.rings.padics
652
+ 2 + O(2^11)
653
+
654
+ sage: R2.precision().diffused_digits([x2,y2]) # needs sage.geometry.polyhedron
655
+ 6
656
+ """
657
+ p = self.prime()
658
+
659
+ # We sort elements by precision lattice
660
+ elt_by_prec = {}
661
+ elt_other = []
662
+ indices = {}
663
+ for i in range(len(elts)):
664
+ x = elts[i]
665
+ idx = id(x)
666
+ if idx in indices:
667
+ indices[idx].append(i)
668
+ else:
669
+ indices[idx] = [i]
670
+ if isinstance(x, pAdicLatticeElement):
671
+ prec = x.parent().precision()
672
+ if prec.prime() != p:
673
+ raise TypeError("conversion between different p-adic rings not supported")
674
+ if prec in elt_by_prec:
675
+ elt_by_prec[prec].append(x)
676
+ else:
677
+ elt_by_prec[prec] = [x]
678
+ else:
679
+ elt_other.append(x)
680
+
681
+ # We create the elements
682
+ ans = len(elts)*[None]
683
+ selfprec = self._precision
684
+ # First the elements with precision lattice
685
+ for (prec, L) in elt_by_prec.items():
686
+ if prec is selfprec:
687
+ # Here, we use the _copy method in order
688
+ # to be sharp on precision
689
+ for x in L:
690
+ y = x._copy(parent=self)
691
+ for i in indices[id(x)]:
692
+ ans[i] = y
693
+ else:
694
+ try:
695
+ lattice = prec.precision_lattice(L)
696
+ except PrecisionError:
697
+ raise NotImplementedError("multiple conversion of a set of variables for which the module precision is not a lattice is not implemented yet")
698
+ for j in range(len(L)):
699
+ x = L[j]
700
+ dx = [[L[i], lattice[i, j]] for i in range(j)]
701
+ prec = lattice[j, j].valuation(p)
702
+ y = self._element_class(self, x.value(), prec, dx=dx, dx_mode='values', check=False, reduce=False)
703
+ for i in indices[id(x)]:
704
+ ans[i] = y
705
+ L[j] = y
706
+ # Now the other elements
707
+ for x in elt_other:
708
+ y = self._element_class(self, x)
709
+ for i in indices[id(x)]:
710
+ ans[i] = y
711
+
712
+ # We return the created elements
713
+ return ans
714
+
715
+
716
+ class pAdicRelaxedGeneric(pAdicGeneric):
717
+ r"""
718
+ Generic class for relaxed `p`-adics.
719
+
720
+ INPUT:
721
+
722
+ - ``p`` -- the underlying prime number
723
+
724
+ - ``prec`` -- the default precision
725
+
726
+ TESTS::
727
+
728
+ sage: R = ZpER(17) # indirect doctest # needs sage.libs.flint
729
+ sage: R._prec_type() # needs sage.libs.flint
730
+ 'relaxed'
731
+ """
732
+ def _get_element_class(self, name=None):
733
+ r"""
734
+ Return the class handling an element of type ``name``.
735
+
736
+ INPUT:
737
+
738
+ - ``name`` -- string or ``None`` (default: ``None``); if ``None``,
739
+ return the generic class from which all the others derive
740
+
741
+ TESTS::
742
+
743
+ sage: # needs sage.libs.flint
744
+ sage: R = ZpER(5)
745
+ sage: R._get_element_class()
746
+ <class 'sage.rings.padics.padic_relaxed_element.pAdicRelaxedElement'>
747
+ sage: R._get_element_class("add")
748
+ <class 'sage.rings.padics.padic_relaxed_element.pAdicRelaxedElement_add'>
749
+ sage: R._get_element_class("unknown")
750
+ <class 'sage.rings.padics.padic_relaxed_element.pAdicRelaxedElement_unknown'>
751
+ sage: R._get_element_class("foobar")
752
+ Traceback (most recent call last):
753
+ ...
754
+ AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
755
+ """
756
+ if name is None:
757
+ return self.Element
758
+ clsname = self._element_class_prefix + name
759
+ cls = getattr(self._element_class_module, clsname)
760
+ return cls
761
+
762
+ def _prec_type(self):
763
+ r"""
764
+ Return the precision handling type.
765
+
766
+ EXAMPLES::
767
+
768
+ sage: ZpER(5)._prec_type() # needs sage.libs.flint
769
+ 'relaxed'
770
+ """
771
+ return 'relaxed'
772
+
773
+ def is_relaxed(self):
774
+ r"""
775
+ Return whether this `p`-adic ring is relaxed.
776
+
777
+ EXAMPLES::
778
+
779
+ sage: R = Zp(5)
780
+ sage: R.is_relaxed()
781
+ False
782
+ sage: S = ZpER(5) # needs sage.libs.flint
783
+ sage: S.is_relaxed() # needs sage.libs.flint
784
+ True
785
+ """
786
+ return True
787
+
788
+ def is_secure(self):
789
+ r"""
790
+ Return ``False`` if this `p`-adic relaxed ring is not secure
791
+ (i.e., if indistinguishable elements at the working precision
792
+ are considered as equal); ``True`` otherwise (in which case,
793
+ an error is raised when equality cannot be decided).
794
+
795
+ EXAMPLES::
796
+
797
+ sage: # needs sage.libs.flint
798
+ sage: R = ZpER(5)
799
+ sage: R.is_secure()
800
+ False
801
+ sage: x = R(20/21)
802
+ sage: y = x + 5^50
803
+ sage: x == y
804
+ True
805
+
806
+ sage: # needs sage.libs.flint
807
+ sage: S = ZpER(5, secure=True)
808
+ sage: S.is_secure()
809
+ True
810
+ sage: x = S(20/21)
811
+ sage: y = x + 5^50
812
+ sage: x == y
813
+ Traceback (most recent call last):
814
+ ...
815
+ PrecisionError: unable to decide equality; try to bound precision
816
+ """
817
+ return self._secure
818
+
819
+ def default_prec(self):
820
+ r"""
821
+ Return the default precision of this relaxed `p`-adic ring.
822
+
823
+ The default precision is mostly used for printing: it is the
824
+ number of digits which are printed for unbounded elements
825
+ (that is elements having infinite absolute precision).
826
+
827
+ EXAMPLES::
828
+
829
+ sage: # needs sage.libs.flint
830
+ sage: R = ZpER(5, print_mode='digits')
831
+ sage: R.default_prec()
832
+ 20
833
+ sage: R(1/17)
834
+ ...34024323104201213403
835
+ sage: S = ZpER(5, prec=10, print_mode='digits')
836
+ sage: S.default_prec()
837
+ 10
838
+ sage: S(1/17)
839
+ ...4201213403
840
+ """
841
+ return self._default_prec
842
+
843
+ def halting_prec(self):
844
+ r"""
845
+ Return the default halting precision of this relaxed `p`-adic ring.
846
+
847
+ The halting precision is the precision at which elements of this
848
+ parent are compared (unless more digits have been previously
849
+ computed).
850
+ By default, it is twice the default precision.
851
+
852
+ EXAMPLES::
853
+
854
+ sage: R = ZpER(5, print_mode='digits') # needs sage.libs.flint
855
+ sage: R.halting_prec() # needs sage.libs.flint
856
+ 40
857
+ """
858
+ return self._halting_prec
859
+
860
+ def precision_cap(self):
861
+ r"""
862
+ Return the precision cap of this `p`-adic ring, which is infinite
863
+ in the case of relaxed rings.
864
+
865
+ EXAMPLES::
866
+
867
+ sage: R = ZpER(5) # needs sage.libs.flint
868
+ sage: R.precision_cap() # needs sage.libs.flint
869
+ +Infinity
870
+ """
871
+ return infinity
872
+
873
+ def _coerce_map_from_(self, R):
874
+ r"""
875
+ Return ``True`` if there is a coercion map from ``R`` to this ring.
876
+
877
+ EXAMPLES::
878
+
879
+ sage: # needs sage.libs.flint
880
+ sage: R = ZpER(5)
881
+ sage: K = R.fraction_field()
882
+ sage: K.has_coerce_map_from(R) # indirect doctest
883
+ True
884
+ sage: R.has_coerce_map_from(K) # indirect doctest
885
+ False
886
+ """
887
+ if isinstance(R, pAdicRelaxedGeneric) and self is R.fraction_field():
888
+ return True
889
+
890
+ def _element_constructor_(self, x, prec=None):
891
+ r"""
892
+ Return an element of this ring.
893
+
894
+ INPUT:
895
+
896
+ - ``x`` -- the datum from which the element is created
897
+
898
+ - ``prec`` -- integer or ``None`` (default: ``None``);
899
+ if given, bound the precision of the element to ``prec``
900
+
901
+ EXAMPLES::
902
+
903
+ sage: # needs sage.libs.flint
904
+ sage: R = ZpER(7, prec=5)
905
+ sage: a = R(17/71); a
906
+ 3 + 3*7^2 + 4*7^3 + 4*7^4 + ...
907
+ sage: a.precision_absolute()
908
+ +Infinity
909
+ sage: b = R(17/71, prec=10); b
910
+ 3 + 3*7^2 + 4*7^3 + 4*7^4 + 2*7^5 + 7^6 + 5*7^8 + 5*7^9 + O(7^10)
911
+ sage: b.precision_absolute()
912
+ 10
913
+
914
+ TESTS::
915
+
916
+ sage: R(1/7) # needs sage.libs.flint
917
+ Traceback (most recent call last):
918
+ ...
919
+ ValueError: negative valuation
920
+
921
+ We check that conversion from other types of `p`-adics works::
922
+
923
+ sage: S = Qp(7)
924
+ sage: c = S(7^5)
925
+ sage: c
926
+ 7^5 + O(7^25)
927
+ sage: R(c) # needs sage.libs.flint
928
+ 7^5 + O(7^25)
929
+ """
930
+ parent = x.parent()
931
+ if parent is self and prec is None:
932
+ return x
933
+ elif isinstance(parent, pAdicRelaxedGeneric):
934
+ if parent.Element is self.Element:
935
+ if not self.is_field() and x.valuation() < 0:
936
+ raise ValueError("negative valuation")
937
+ return self._get_element_class('bound')(self, x, prec)
938
+ raise NotImplementedError
939
+ elif isinstance(parent, pAdicGeneric):
940
+ if not self.is_field() and x.valuation() < 0:
941
+ raise ValueError("negative valuation")
942
+ if prec is None:
943
+ prec = x.precision_absolute()
944
+ else:
945
+ prec = min(prec, x.precision_absolute())
946
+ return self._get_element_class('value')(self, x.lift(), precbound=prec)
947
+ elif x == 0 and prec is None:
948
+ return self._get_element_class('zero')(self)
949
+ elif x == 1 and prec is None:
950
+ return self._get_element_class('one')(self)
951
+ else:
952
+ try:
953
+ x = self.exact_ring()(x)
954
+ return self._get_element_class('value')(self, x, precbound=prec)
955
+ except (TypeError, ValueError):
956
+ pass
957
+ try:
958
+ x = self.exact_field()(x)
959
+ num = x.numerator()
960
+ denom = x.denominator()
961
+ except (TypeError, ValueError, AttributeError):
962
+ pass
963
+ else:
964
+ if not self.is_field() and denom % self.prime() == 0:
965
+ raise ValueError("negative valuation")
966
+ num = self._get_element_class('value')(self, num)
967
+ denom = self._get_element_class('value')(self, denom)
968
+ return self._get_element_class('div')(self, num, denom, precbound=prec)
969
+ raise TypeError("unable to convert '%s' to a relaxed %s-adic integer" % (x, self.prime()))
970
+
971
+ def an_element(self, unbounded=False):
972
+ r"""
973
+ Return an element in this ring.
974
+
975
+ EXAMPLES::
976
+
977
+ sage: R = ZpER(7, prec=5) # needs sage.libs.flint
978
+ sage: R.an_element() # needs sage.libs.flint
979
+ 7 + O(7^5)
980
+ sage: R.an_element(unbounded=True) # needs sage.libs.flint
981
+ 7 + ...
982
+ """
983
+ p = self(self.prime())
984
+ if not unbounded:
985
+ p = p.at_precision_absolute()
986
+ return p
987
+
988
+ def some_elements(self, unbounded=False):
989
+ r"""
990
+ Return a list of elements in this ring.
991
+
992
+ This is typically used for running generic tests (see :class:`TestSuite`).
993
+
994
+ EXAMPLES::
995
+
996
+ sage: R = ZpER(7, prec=5) # needs sage.libs.flint
997
+ sage: R.some_elements() # needs sage.libs.flint
998
+ [O(7^5),
999
+ 1 + O(7^5),
1000
+ 7 + O(7^5),
1001
+ 7 + O(7^5),
1002
+ 1 + 5*7 + 3*7^2 + 6*7^3 + O(7^5),
1003
+ 7 + 6*7^2 + 6*7^3 + 6*7^4 + O(7^5)]
1004
+
1005
+ sage: R.some_elements(unbounded=True) # needs sage.libs.flint
1006
+ [0,
1007
+ 1 + ...,
1008
+ 7 + ...,
1009
+ 7 + ...,
1010
+ 1 + 5*7 + 3*7^2 + 6*7^3 + ...,
1011
+ 7 + 6*7^2 + 6*7^3 + 6*7^4 + ...]
1012
+ """
1013
+ p = self(self.prime())
1014
+ a = self.gen()
1015
+ one = self.one()
1016
+ L = [self.zero(), one, p, a, (one+p+p).inverse_of_unit(), p-p**2]
1017
+ if self.is_field():
1018
+ L.extend([~(p-p-a),p**(-20)])
1019
+ if not unbounded:
1020
+ L = [ x.at_precision_absolute() for x in L ]
1021
+ return L
1022
+
1023
+ def unknown(self, start_val=0, digits=None):
1024
+ r"""
1025
+ Return a self-referent number in this ring.
1026
+
1027
+ INPUT:
1028
+
1029
+ - ``start_val`` -- integer (default: 0); a lower bound on the
1030
+ valuation of the returned element
1031
+
1032
+ - ``digits`` -- an element, a list, or ``None`` (default: ``None``);
1033
+ the first digit or the list of the digits of the returned element
1034
+
1035
+ NOTE:
1036
+
1037
+ Self-referent numbers are numbers whose digits are defined in terms
1038
+ of the previous ones. This method is used to declare a self-referent
1039
+ number (and optionally, to set its first digits).
1040
+ The definition of the number itself will be given afterwords using
1041
+ to method :meth:`sage.rings.padics.relaxed_template.RelaxedElement_unknown.set`
1042
+ of the element.
1043
+
1044
+ EXAMPLES:
1045
+
1046
+ sage: R = ZpER(5, prec=10) # needs sage.libs.flint
1047
+
1048
+ We declare a self-referent number::
1049
+
1050
+ sage: a = R.unknown() # needs sage.libs.flint
1051
+
1052
+ So far, we do not know anything on `a` (except that it has nonnegative
1053
+ valuation)::
1054
+
1055
+ sage: a # needs sage.libs.flint
1056
+ O(5^0)
1057
+
1058
+ We can now use the method :meth:`sage.rings.padics.relaxed_template.RelaxedElement_unknown.set`
1059
+ to define `a`. Below, for example, we say that the digits of `a` have to
1060
+ agree with the digits of `1 + 5 a`. Note that the factor `5` shifts the
1061
+ digits; the `n`-th digit of `a` is then defined by the previous ones::
1062
+
1063
+ sage: a.set(1 + 5*a) # needs sage.libs.flint
1064
+ True
1065
+
1066
+ After this, `a` contains the solution of the equation `a = 1 + 5 a`, that
1067
+ is `a = -1/4`::
1068
+
1069
+ sage: a # needs sage.libs.flint
1070
+ 1 + 5 + 5^2 + 5^3 + 5^4 + 5^5 + 5^6 + 5^7 + 5^8 + 5^9 + ...
1071
+
1072
+ Here is another example with an equation of degree `2`::
1073
+
1074
+ sage: # needs sage.libs.flint
1075
+ sage: b = R.unknown()
1076
+ sage: b.set(1 - 5*b^2)
1077
+ True
1078
+ sage: b
1079
+ 1 + 4*5 + 5^2 + 3*5^4 + 4*5^6 + 4*5^8 + 2*5^9 + ...
1080
+ sage: (sqrt(R(21)) - 1) / 10
1081
+ 1 + 4*5 + 5^2 + 3*5^4 + 4*5^6 + 4*5^8 + 2*5^9 + ...
1082
+
1083
+ Cross self-referent definitions are also allowed::
1084
+
1085
+ sage: # needs sage.libs.flint
1086
+ sage: u = R.unknown()
1087
+ sage: v = R.unknown()
1088
+ sage: w = R.unknown()
1089
+ sage: u.set(1 + 2*v + 3*w^2 + 5*u*v*w)
1090
+ True
1091
+ sage: v.set(2 + 4*w + sqrt(1 + 5*u + 10*v + 15*w))
1092
+ True
1093
+ sage: w.set(3 + 25*(u*v + v*w + u*w))
1094
+ True
1095
+ sage: u
1096
+ 3 + 3*5 + 4*5^2 + 5^3 + 3*5^4 + 5^5 + 5^6 + 3*5^7 + 5^8 + 3*5^9 + ...
1097
+ sage: v
1098
+ 4*5 + 2*5^2 + 4*5^3 + 5^4 + 5^5 + 3*5^6 + 5^8 + 5^9 + ...
1099
+ sage: w
1100
+ 3 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 2*5^6 + 5^8 + 5^9 + ...
1101
+
1102
+ TESTS::
1103
+
1104
+ sage: # needs sage.libs.flint
1105
+ sage: a = R.unknown()
1106
+ sage: a.set(1 + 3*a)
1107
+ True
1108
+ sage: a
1109
+ O(5^0)
1110
+ sage: a.at_precision_absolute(10)
1111
+ Traceback (most recent call last):
1112
+ ...
1113
+ RecursionError: definition looks circular
1114
+ """
1115
+ valuation = ZZ(start_val)
1116
+ if (not self.is_field()) and valuation < 0:
1117
+ raise ValueError("valuation must be nonnegative")
1118
+ if digits is not None and not isinstance(digits, (list, tuple)):
1119
+ digits = [digits]
1120
+ return self._get_element_class('unknown')(self, valuation, digits)
1121
+
1122
+ def random_element(self, integral=False, prec=None):
1123
+ r"""
1124
+ Return a random element in this ring.
1125
+
1126
+ INPUT:
1127
+
1128
+ - ``integral`` -- boolean (default: ``False``); if ``True``,
1129
+ return a random element in the ring of integers of this ring
1130
+
1131
+ - ``prec`` -- integer or ``None`` (default: ``None``);
1132
+ if given, bound the precision of the output to ``prec``
1133
+
1134
+ EXAMPLES::
1135
+
1136
+ sage: R = ZpER(5, prec=10) # needs sage.libs.flint
1137
+
1138
+ By default, this method returns a unbounded element::
1139
+
1140
+ sage: a = R.random_element() # needs sage.libs.flint
1141
+ sage: a # random # needs sage.libs.flint
1142
+ 4 + 3*5 + 3*5^2 + 5^3 + 3*5^4 + 2*5^5 + 2*5^6 + 5^7 + 5^9 + ...
1143
+ sage: a.precision_absolute() # needs sage.libs.flint
1144
+ +Infinity
1145
+
1146
+ The precision can be bounded by passing in a precision::
1147
+
1148
+ sage: b = R.random_element(prec=15) # needs sage.libs.flint
1149
+ sage: b # random # needs sage.libs.flint
1150
+ 2 + 3*5^2 + 5^3 + 3*5^4 + 5^5 + 3*5^6 + 3*5^8 + 3*5^9 + 4*5^10
1151
+ + 5^11 + 4*5^12 + 5^13 + 2*5^14 + O(5^15)
1152
+ sage: b.precision_absolute() # needs sage.libs.flint
1153
+ 15
1154
+ """
1155
+ if integral or (not self.is_field()):
1156
+ return self._get_element_class('random')(self, 0, prec)
1157
+ else:
1158
+ return self._get_element_class('random')(self, None, prec)
1159
+
1160
+ def teichmuller(self, x):
1161
+ r"""
1162
+ Return the Teichmuller representative of `x`.
1163
+
1164
+ EXAMPLES::
1165
+
1166
+ sage: R = ZpER(5, print_mode='digits') # needs sage.libs.flint
1167
+ sage: R.teichmuller(2) # needs sage.libs.flint
1168
+ ...40423140223032431212
1169
+ """
1170
+ x = self(x)
1171
+ if x.valuation() < 0:
1172
+ raise ValueError("negative valuation")
1173
+ return self._get_element_class('teichmuller')(self, self.exact_ring()(x.residue()))
1174
+
1175
+ def teichmuller_system(self):
1176
+ r"""
1177
+ Return a set of teichmuller representatives for the invertible elements
1178
+ of `\ZZ / p\ZZ`.
1179
+
1180
+ EXAMPLES::
1181
+
1182
+ sage: R = ZpER(7, print_mode='digits') # needs sage.libs.flint
1183
+ sage: R.teichmuller_system() # needs sage.libs.flint
1184
+ [...00000000000000000001,
1185
+ ...16412125443426203642,
1186
+ ...16412125443426203643,
1187
+ ...50254541223240463024,
1188
+ ...50254541223240463025,
1189
+ ...66666666666666666666]
1190
+ """
1191
+ R = self.residue_class_field()
1192
+ return [ self.teichmuller(ZZ(i)) for i in R if i != 0 ]
1193
+
1194
+
1195
+ class pAdicRingGeneric(pAdicGeneric, sage.rings.abc.pAdicRing):
1196
+ def is_field(self, proof=True):
1197
+ """
1198
+ Return whether this ring is actually a field, ie ``False``.
1199
+
1200
+ EXAMPLES::
1201
+
1202
+ sage: Zp(5).is_field()
1203
+ False
1204
+ """
1205
+ return False
1206
+
1207
+ def krull_dimension(self):
1208
+ r"""
1209
+ Return the Krull dimension of self, i.e. 1.
1210
+
1211
+ INPUT:
1212
+
1213
+ - ``self`` -- a `p`-adic ring
1214
+
1215
+ OUTPUT: the Krull dimension of ``self``. Since ``self`` is a `p`-adic
1216
+ ring, this is 1.
1217
+
1218
+ EXAMPLES::
1219
+
1220
+ sage: Zp(5).krull_dimension()
1221
+ 1
1222
+ """
1223
+ return 1
1224
+
1225
+ def _xgcd_univariate_polynomial(self, f, g):
1226
+ """
1227
+ Extended gcd for univariate polynomial rings over ``self``.
1228
+
1229
+ Should not be called directly. Use ``f.xgcd(g)`` instead.
1230
+
1231
+ INPUT:
1232
+
1233
+ - ``f``, ``g`` -- the polynomials of which to take the xgcd
1234
+
1235
+ OUTPUT:
1236
+
1237
+ A tuple (a, b, c) which satisfies a = b*f + c*g. There
1238
+ is no guarantee that a, b, and c are minimal.
1239
+
1240
+ .. WARNING::
1241
+
1242
+ The computations are performed using the standard Euclidean
1243
+ algorithm which might produce mathematically incorrect results in
1244
+ some cases. See :issue:`13439`.
1245
+
1246
+ EXAMPLES::
1247
+
1248
+ sage: R.<x> = Zp(3,3)[] # needs sage.libs.ntl
1249
+ sage: f = x + 1 # needs sage.libs.ntl
1250
+ sage: f.xgcd(f^2) # needs sage.libs.ntl
1251
+ ((1 + O(3^3))*x + 1 + O(3^3), 1 + O(3^3), 0)
1252
+
1253
+ We check that :issue:`13439` has been fixed::
1254
+
1255
+ sage: # needs sage.libs.ntl
1256
+ sage: R.<x> = Zp(3,3)[]
1257
+ sage: f = 3*x + 7
1258
+ sage: g = 5*x + 9
1259
+ sage: f.xgcd(f*g)
1260
+ ((3 + O(3^4))*x + 1 + 2*3 + O(3^3), 1 + O(3^3), 0)
1261
+
1262
+ sage: # needs sage.libs.ntl
1263
+ sage: R.<x> = Zp(3)[]
1264
+ sage: f = 357555295953*x + 257392844
1265
+ sage: g = 225227399*x - 511940255230575
1266
+ sage: f.xgcd(f*g)
1267
+ ((3^9 + O(3^29))*x + 2 + 2*3 + 3^2 + 2*3^5 + 3^6 + 3^7
1268
+ + 3^8 + 3^10 + 3^11 + 2*3^13 + 3^14 + 3^16 + 2*3^19 +
1269
+ O(3^20), 1 + 2*3^2 + 3^4 + 2*3^5 + 3^6 + 3^7 +
1270
+ 2*3^8 + 2*3^10 + 2*3^12 + 3^13 + 3^14 + 3^15 + 2*3^17
1271
+ + 3^18 + O(3^20), 0)
1272
+
1273
+ We check low precision computations::
1274
+
1275
+ sage: # needs sage.libs.ntl
1276
+ sage: R.<x> = Zp(3,1)[]
1277
+ sage: h = 3*x + 7
1278
+ sage: i = 4*x + 9
1279
+ sage: h.xgcd(h*i)
1280
+ ((3 + O(3^2))*x + 1 + O(3), 1 + O(3), 0)
1281
+ """
1282
+ from sage.misc.stopgap import stopgap
1283
+ stopgap("Extended gcd computations over p-adic fields are performed using the standard Euclidean algorithm which might produce mathematically incorrect results in some cases.", 13439)
1284
+
1285
+ base_ring = f.base_ring()
1286
+ fracfield = base_ring.fraction_field()
1287
+ f_field = f.change_ring(fracfield)
1288
+ g_field = g.change_ring(fracfield)
1289
+ xgcd = fracfield._xgcd_univariate_polynomial(f_field,g_field)
1290
+ lcm = base_ring(1)
1291
+ for f in xgcd:
1292
+ for i in f:
1293
+ lcm = (i.denominator()).lcm(lcm)
1294
+ returnlst = []
1295
+ for f in xgcd:
1296
+ f *= lcm
1297
+ returnlst.append(f.change_ring(base_ring))
1298
+ return tuple(returnlst)
1299
+
1300
+ def _gcd_univariate_polynomial(self, f, g):
1301
+ """
1302
+ gcd for univariate polynomial rings over ``self``.
1303
+
1304
+ INPUT:
1305
+
1306
+ - ``f``, ``g`` -- the polynomials of which to take the gcd
1307
+
1308
+ OUTPUT: a polynomial
1309
+
1310
+ EXAMPLES::
1311
+
1312
+ sage: # needs sage.libs.ntl
1313
+ sage: R.<a> = Zq(27)
1314
+ sage: K.<x> = R[]
1315
+ sage: h = 3*x + a
1316
+ sage: i = 4*x + 2
1317
+ sage: h.gcd(h*i)
1318
+ (3 + O(3^21))*x + a + O(3^20)
1319
+ """
1320
+ return self._xgcd_univariate_polynomial(f, g)[0]
1321
+
1322
+
1323
+ class pAdicFieldGeneric(pAdicGeneric, sage.rings.abc.pAdicField):
1324
+ def is_field(self, proof=True):
1325
+ """
1326
+ Return whether this ring is actually a field, ie ``True``.
1327
+
1328
+ EXAMPLES::
1329
+
1330
+ sage: Qp(5).is_field()
1331
+ True
1332
+ """
1333
+ return True
1334
+
1335
+ #def class_field(self, group=None, map=None, generators=None):
1336
+ # raise NotImplementedError
1337
+
1338
+ #def composite(self, subfield1, subfield2):
1339
+ # raise NotImplementedError
1340
+
1341
+ #def norm_equation(self):
1342
+ # raise NotImplementedError
1343
+
1344
+ #def norm_group(self):
1345
+ # raise NotImplementedError
1346
+
1347
+ #def norm_group_discriminant(self, group=None, map=None, generators=None):
1348
+ # raise NotImplementedError
1349
+
1350
+ #def number_of_extensions(self, degree, discriminant=None, e=None, f=None):
1351
+ # raise NotImplementedError
1352
+
1353
+ #def list_of_extensions(self, degree, discriminant=None, e=None, f=None):
1354
+ # raise NotImplementedError
1355
+
1356
+ #def subfield(self, list):
1357
+ # raise NotImplementedError
1358
+
1359
+ #def subfield_lattice(self):
1360
+ # raise NotImplementedError
1361
+
1362
+ #def subfields_of_degree(self, n):
1363
+ # raise NotImplementedError
1364
+
1365
+
1366
+ class pAdicFixedModRingGeneric(pAdicRingGeneric, FixedModGeneric):
1367
+ pass
1368
+
1369
+
1370
+ class pAdicCappedAbsoluteRingGeneric(pAdicRingGeneric, CappedAbsoluteGeneric):
1371
+ pass
1372
+
1373
+
1374
+ class pAdicCappedRelativeRingGeneric(pAdicRingGeneric, CappedRelativeRingGeneric):
1375
+ pass
1376
+
1377
+
1378
+ class pAdicCappedRelativeFieldGeneric(pAdicFieldGeneric, CappedRelativeFieldGeneric):
1379
+ pass
1380
+
1381
+
1382
+ class pAdicFloatingPointRingGeneric(pAdicRingGeneric, FloatingPointRingGeneric):
1383
+ pass
1384
+
1385
+
1386
+ class pAdicFloatingPointFieldGeneric(pAdicFieldGeneric, FloatingPointFieldGeneric):
1387
+ pass
1388
+
1389
+
1390
+ class pAdicRingBaseGeneric(pAdicBaseGeneric, pAdicRingGeneric):
1391
+ def construction(self, forbid_frac_field=False):
1392
+ """
1393
+ Return the functorial construction of ``self``, namely,
1394
+ completion of the rational numbers with respect to a given prime.
1395
+
1396
+ Also preserves other information that makes this field unique
1397
+ (e.g., precision, rounding, print mode).
1398
+
1399
+ INPUT:
1400
+
1401
+ - ``forbid_frac_field`` -- ignored, for compatibility with other `p`-adic types
1402
+
1403
+ EXAMPLES::
1404
+
1405
+ sage: K = Zp(17, 8, print_mode='val-unit', print_sep='&')
1406
+ sage: c, L = K.construction(); L
1407
+ Integer Ring
1408
+ sage: c(L)
1409
+ 17-adic Ring with capped relative precision 8
1410
+ sage: K == c(L)
1411
+ True
1412
+
1413
+ TESTS::
1414
+
1415
+ sage: R = ZpLC(13,(31,41))
1416
+ sage: R._precision_cap()
1417
+ (31, 41)
1418
+ sage: F, Z = R.construction()
1419
+ sage: S = F(Z)
1420
+ sage: S._precision_cap()
1421
+ (31, 41)
1422
+
1423
+ The `secure` attribute for relaxed type is included in the functor::
1424
+
1425
+ sage: R = ZpER(5, secure=True) # needs sage.libs.flint
1426
+ sage: R.construction() # needs sage.libs.flint
1427
+ (Completion[5, prec=(20, 40, True)], Integer Ring)
1428
+ """
1429
+ from sage.categories.pushout import CompletionFunctor
1430
+ extras = {'print_mode':self._printer.dict(), 'type':self._prec_type(), 'names':self._names}
1431
+ if hasattr(self, '_label'):
1432
+ extras['label'] = self._label
1433
+ if self._prec_type() == "relaxed":
1434
+ prec = (self._default_prec, self._halting_prec, self._secure)
1435
+ else:
1436
+ prec = self._precision_cap()
1437
+ return (CompletionFunctor(self.prime(), prec, extras), ZZ)
1438
+
1439
+ def random_element(self, algorithm='default'):
1440
+ r"""
1441
+ Return a random element of ``self``, optionally using the
1442
+ ``algorithm`` argument to decide how it generates the
1443
+ element. Algorithms currently implemented:
1444
+
1445
+ - ``'default'``: Choose `a_i`, `i \geq 0`, randomly between `0` and
1446
+ `p-1` until a nonzero choice is made. Then continue choosing
1447
+ `a_i` randomly between `0` and `p-1` until we reach
1448
+ precision_cap, and return `\sum a_i p^i`.
1449
+
1450
+ EXAMPLES::
1451
+
1452
+ sage: Zp(5,6).random_element().parent() is Zp(5,6)
1453
+ True
1454
+ sage: ZpCA(5,6).random_element().parent() is ZpCA(5,6)
1455
+ True
1456
+ sage: ZpFM(5,6).random_element().parent() is ZpFM(5,6)
1457
+ True
1458
+ """
1459
+ if (algorithm == 'default'):
1460
+ if self.is_capped_relative():
1461
+ i = 0
1462
+ a_i = ZZ.random_element(self.prime())
1463
+ while a_i.is_zero():
1464
+ i += 1
1465
+ a_i = ZZ.random_element(self.prime())
1466
+ return self((self.prime()**i)*(a_i + self.prime()*ZZ.random_element(self.prime_pow.pow_Integer_Integer(self.precision_cap()-1))))
1467
+ else:
1468
+ return self(ZZ.random_element(self.prime_pow.pow_Integer_Integer(self.precision_cap())))
1469
+ else:
1470
+ raise NotImplementedError("Don't know %s algorithm" % algorithm)
1471
+
1472
+ #def unit_group(self):
1473
+ # raise NotImplementedError
1474
+
1475
+ #def unit_group_gens(self):
1476
+ # raise NotImplementedError
1477
+
1478
+ #def principal_unit_group(self):
1479
+ # raise NotImplementedError
1480
+
1481
+
1482
+ class pAdicFieldBaseGeneric(pAdicBaseGeneric, pAdicFieldGeneric):
1483
+ def composite(self, subfield1, subfield2):
1484
+ r"""
1485
+ Return the composite of two subfields of ``self``, i.e., the
1486
+ largest subfield containing both
1487
+
1488
+ INPUT:
1489
+
1490
+ - ``self`` -- a `p`-adic field
1491
+ - ``subfield1`` -- a subfield
1492
+ - ``subfield2`` -- a subfield
1493
+
1494
+ OUTPUT: the composite of ``subfield1`` and ``subfield2``
1495
+
1496
+ EXAMPLES::
1497
+
1498
+ sage: K = Qp(17); K.composite(K, K) is K
1499
+ True
1500
+ """
1501
+ #should be overridden for extension fields
1502
+ if (subfield1 is self) and (subfield2 is self):
1503
+ return self
1504
+ raise ValueError("Arguments must be subfields of self.")
1505
+
1506
+ def subfields_of_degree(self, n):
1507
+ r"""
1508
+ Return the number of subfields of ``self`` of degree `n`.
1509
+
1510
+ INPUT:
1511
+
1512
+ - ``self`` -- a `p`-adic field
1513
+ - ``n`` -- integer
1514
+
1515
+ OUTPUT:
1516
+
1517
+ integer -- the number of subfields of degree `n` over ``self.base_ring()``
1518
+
1519
+ EXAMPLES::
1520
+
1521
+ sage: K = Qp(17)
1522
+ sage: K.subfields_of_degree(1)
1523
+ 1
1524
+ """
1525
+ if n == 1:
1526
+ return 1
1527
+ else:
1528
+ return 0
1529
+
1530
+ def subfield(self, list):
1531
+ r"""
1532
+ Return the subfield generated by the elements in ``list``.
1533
+
1534
+ INPUT:
1535
+
1536
+ - ``self`` -- a `p`-adic field
1537
+ - ``list`` -- list of elements of ``self``
1538
+
1539
+ OUTPUT: the subfield of ``self`` generated by the elements of ``list``
1540
+
1541
+ EXAMPLES::
1542
+
1543
+ sage: K = Qp(17); K.subfield([K(17), K(1827)]) is K
1544
+ True
1545
+ """
1546
+ for x in list:
1547
+ if x not in self:
1548
+ raise TypeError("Members of the list of generators must be elements of self.")
1549
+ return self
1550
+
1551
+ def construction(self, forbid_frac_field=False):
1552
+ """
1553
+ Return the functorial construction of ``self``, namely,
1554
+ completion of the rational numbers with respect a given prime.
1555
+
1556
+ Also preserves other information that makes this field unique
1557
+ (e.g., precision, rounding, print mode).
1558
+
1559
+ INPUT:
1560
+
1561
+ - ``forbid_frac_field`` -- require a completion functor rather
1562
+ than a fraction field functor. This is used in the
1563
+ :meth:`sage.rings.padics.local_generic.LocalGeneric.change` method.
1564
+
1565
+ EXAMPLES::
1566
+
1567
+ sage: K = Qp(17, 8, print_mode='val-unit', print_sep='&')
1568
+ sage: c, L = K.construction(); L
1569
+ 17-adic Ring with capped relative precision 8
1570
+ sage: c
1571
+ FractionField
1572
+ sage: c(L)
1573
+ 17-adic Field with capped relative precision 8
1574
+ sage: K == c(L)
1575
+ True
1576
+
1577
+ We can get a completion functor by forbidding the fraction field::
1578
+
1579
+ sage: c, L = K.construction(forbid_frac_field=True); L
1580
+ Rational Field
1581
+ sage: c
1582
+ Completion[17, prec=8]
1583
+ sage: c(L)
1584
+ 17-adic Field with capped relative precision 8
1585
+ sage: K == c(L)
1586
+ True
1587
+
1588
+ TESTS::
1589
+
1590
+ sage: R = QpLC(13,(31,41))
1591
+ sage: R._precision_cap()
1592
+ (31, 41)
1593
+ sage: F, Z = R.construction()
1594
+ sage: S = F(Z)
1595
+ sage: S._precision_cap()
1596
+ (31, 41)
1597
+
1598
+ The `secure` attribute for relaxed type is included in the functor::
1599
+
1600
+ sage: K = QpER(5, secure=True) # needs sage.libs.flint
1601
+ sage: K.construction(forbid_frac_field=True) # needs sage.libs.flint
1602
+ (Completion[5, prec=(20, 40, True)], Rational Field)
1603
+ """
1604
+ from sage.categories.pushout import FractionField, CompletionFunctor
1605
+ if forbid_frac_field:
1606
+ extras = {'print_mode':self._printer.dict(), 'type':self._prec_type(), 'names':self._names}
1607
+ if hasattr(self, '_label'):
1608
+ extras['label'] = self._label
1609
+ if self._prec_type() == "relaxed":
1610
+ prec = (self._default_prec, self._halting_prec, self._secure)
1611
+ else:
1612
+ prec = self._precision_cap()
1613
+ return (CompletionFunctor(self.prime(), prec, extras), QQ)
1614
+ else:
1615
+ return FractionField(), self.integer_ring()