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,1235 @@
1
+ # sage_setup: distribution = sagemath-pari
2
+ r"""
3
+ `p`-adic Base Leaves
4
+
5
+ Implementations of `\ZZ_p` and `\QQ_p`
6
+
7
+ AUTHORS:
8
+
9
+ - David Roe
10
+ - Genya Zaytman: documentation
11
+ - David Harvey: doctests
12
+ - William Stein: doctest updates
13
+
14
+ EXAMPLES:
15
+
16
+ `p`-adic rings and fields are examples of inexact structures, as the
17
+ reals are. That means that elements cannot generally be stored
18
+ exactly: to do so would take an infinite amount of storage. Instead,
19
+ we store an approximation to the elements with varying precision.
20
+
21
+ There are two types of precision for a `p`-adic element. The first is
22
+ relative precision, which gives the number of known `p`-adic digits::
23
+
24
+ sage: R = Qp(5, 20, 'capped-rel', 'series'); a = R(675); a
25
+ 2*5^2 + 5^4 + O(5^22)
26
+ sage: a.precision_relative()
27
+ 20
28
+
29
+ The second type of precision is absolute precision, which gives the
30
+ power of `p` that this element is stored modulo::
31
+
32
+ sage: a.precision_absolute()
33
+ 22
34
+
35
+ The number of times that `p` divides the element is called the
36
+ valuation, and can be accessed with the methods :meth:`valuation` and
37
+ :meth:`ordp`:
38
+
39
+ sage: a.valuation()
40
+ 2
41
+
42
+ The following relationship holds:
43
+
44
+ ``self.valuation() + self.precision_relative() == self.precision_absolute().``
45
+
46
+ sage: a.valuation() + a.precision_relative() == a.precision_absolute()
47
+ True
48
+
49
+ In the capped relative case, the relative precision of an element
50
+ is restricted to be at most a certain value, specified at the
51
+ creation of the field. Individual elements also store their own
52
+ precision, so the effect of various arithmetic operations on
53
+ precision is tracked. When you cast an exact element into a
54
+ capped relative field, it truncates it to the precision cap of the
55
+ field.::
56
+
57
+ sage: R = Qp(5, 5); a = R(4006); a
58
+ 1 + 5 + 2*5^3 + 5^4 + O(5^5)
59
+ sage: b = R(17/3); b
60
+ 4 + 2*5 + 3*5^2 + 5^3 + 3*5^4 + O(5^5)
61
+ sage: c = R(4025); c
62
+ 5^2 + 2*5^3 + 5^4 + 5^5 + O(5^7)
63
+ sage: a + b
64
+ 4*5 + 3*5^2 + 3*5^3 + 4*5^4 + O(5^5)
65
+ sage: a + b + c
66
+ 4*5 + 4*5^2 + 5^4 + O(5^5)
67
+
68
+ ::
69
+
70
+ sage: R = Zp(5, 5, 'capped-rel', 'series'); a = R(4006); a
71
+ 1 + 5 + 2*5^3 + 5^4 + O(5^5)
72
+ sage: b = R(17/3); b
73
+ 4 + 2*5 + 3*5^2 + 5^3 + 3*5^4 + O(5^5)
74
+ sage: c = R(4025); c
75
+ 5^2 + 2*5^3 + 5^4 + 5^5 + O(5^7)
76
+ sage: a + b
77
+ 4*5 + 3*5^2 + 3*5^3 + 4*5^4 + O(5^5)
78
+ sage: a + b + c
79
+ 4*5 + 4*5^2 + 5^4 + O(5^5)
80
+
81
+ In the capped absolute type, instead of having a cap on the
82
+ relative precision of an element there is instead a cap on the
83
+ absolute precision. Elements still store their own precisions,
84
+ and as with the capped relative case, exact elements are truncated
85
+ when cast into the ring.::
86
+
87
+ sage: R = ZpCA(5, 5); a = R(4005); a
88
+ 5 + 2*5^3 + 5^4 + O(5^5)
89
+ sage: b = R(4025); b
90
+ 5^2 + 2*5^3 + 5^4 + O(5^5)
91
+ sage: a * b
92
+ 5^3 + 2*5^4 + O(5^5)
93
+ sage: (a * b) // 5^3
94
+ 1 + 2*5 + O(5^2)
95
+ sage: type((a * b) // 5^3)
96
+ <class 'sage.rings.padics.padic_capped_absolute_element.pAdicCappedAbsoluteElement'>
97
+ sage: (a * b) / 5^3
98
+ 1 + 2*5 + O(5^2)
99
+ sage: type((a * b) / 5^3)
100
+ <class 'sage.rings.padics.padic_capped_relative_element.pAdicCappedRelativeElement'>
101
+
102
+ The fixed modulus type is the leanest of the `p`-adic rings: it is
103
+ basically just a wrapper around `\ZZ / p^n \ZZ`
104
+ providing a unified interface with the rest of the `p`-adics. This is
105
+ the type you should use if your primary interest is in speed (though
106
+ it's not all that much faster than other `p`-adic types). It does not
107
+ track precision of elements.::
108
+
109
+ sage: R = ZpFM(5, 5); a = R(4005); a
110
+ 5 + 2*5^3 + 5^4
111
+ sage: a // 5
112
+ 1 + 2*5^2 + 5^3
113
+
114
+ `p`-adic rings and fields should be created using the creation
115
+ functions :func:`Zp` and :func:`Qp` as above. This will ensure that there is
116
+ only one instance of `\ZZ_p` and `\QQ_p` of a given
117
+ type, `p`, print mode and precision. It also saves typing very long
118
+ class names.::
119
+
120
+ sage: Qp(17,10)
121
+ 17-adic Field with capped relative precision 10
122
+ sage: R = Qp(7, prec = 20, print_mode = 'val-unit'); S = Qp(7, prec = 20, print_mode = 'val-unit'); R is S
123
+ True
124
+ sage: Qp(2)
125
+ 2-adic Field with capped relative precision 20
126
+
127
+ Once one has a `p`-adic ring or field, one can cast elements into it
128
+ in the standard way. Integers, ints, longs, Rationals, other `p`-adic
129
+ types, pari `p`-adics and elements of `\ZZ / p^n \ZZ`
130
+ can all be cast into a `p`-adic field.::
131
+
132
+ sage: R = Qp(5, 5, 'capped-rel','series'); a = R(16); a
133
+ 1 + 3*5 + O(5^5)
134
+ sage: b = R(23/15); b
135
+ 5^-1 + 3 + 3*5 + 5^2 + 3*5^3 + O(5^4)
136
+ sage: S = Zp(5, 5, 'fixed-mod','val-unit'); c = S(Mod(75,125)); c
137
+ 5^2 * 3
138
+ sage: R(c)
139
+ 3*5^2 + O(5^5)
140
+
141
+ In the previous example, since fixed-mod elements don't keep track
142
+ of their precision, we assume that it has the full precision of
143
+ the ring. This is why you have to cast manually here.
144
+
145
+ While you can cast explicitly as above, the chains of automatic
146
+ coercion are more restricted. As always in Sage, the following
147
+ arrows are transitive and the diagram is commutative.::
148
+
149
+ int -> long -> Integer -> Zp capped-rel -> Zp capped_abs -> IntegerMod
150
+ Integer -> Zp fixed-mod -> IntegerMod
151
+ Integer -> Zp capped-abs -> Qp capped-rel
152
+
153
+ In addition, there are arrows within each type. For capped relative
154
+ and capped absolute rings and fields, these arrows go from lower
155
+ precision cap to higher precision cap. This works since elements
156
+ track their own precision: choosing the parent with higher precision
157
+ cap means that precision is less likely to be truncated unnecessarily.
158
+ For fixed modulus parents, the arrow goes from higher precision cap to
159
+ lower. The fact that elements do not track precision necessitates
160
+ this choice in order to not produce incorrect results.
161
+
162
+ TESTS::
163
+
164
+ sage: R = Qp(5, 15, print_mode='bars', print_sep='&')
165
+ sage: repr(R(2777))[3:]
166
+ '0&0&0&0&0&0&0&0&0&0&4&2&1&0&2'
167
+ sage: TestSuite(R).run() # needs sage.geometry.polyhedron
168
+
169
+ sage: R = Zp(5, 15, print_mode='bars', print_sep='&')
170
+ sage: repr(R(2777))[3:]
171
+ '0&0&0&0&0&0&0&0&0&0&4&2&1&0&2'
172
+ sage: TestSuite(R).run() # needs sage.geometry.polyhedron
173
+
174
+ sage: R = ZpCA(5, 15, print_mode='bars', print_sep='&')
175
+ sage: repr(R(2777))[3:]
176
+ '0&0&0&0&0&0&0&0&0&0&4&2&1&0&2'
177
+ sage: TestSuite(R).run() # needs sage.geometry.polyhedron
178
+ """
179
+
180
+ #*****************************************************************************
181
+ # Copyright (C) 2008 David Roe <roed.math@gmail.com>
182
+ # William Stein <wstein@gmail.com>
183
+ #
184
+ # Distributed under the terms of the GNU General Public License (GPL)
185
+ # as published by the Free Software Foundation; either version 2 of
186
+ # the License, or (at your option) any later version.
187
+ #
188
+ # http://www.gnu.org/licenses/
189
+ #*****************************************************************************
190
+ from sage.structure.richcmp import op_LE
191
+
192
+ from .generic_nodes import pAdicFieldBaseGeneric, \
193
+ pAdicCappedRelativeFieldGeneric, \
194
+ pAdicRingBaseGeneric, \
195
+ pAdicCappedRelativeRingGeneric, \
196
+ pAdicFixedModRingGeneric, \
197
+ pAdicCappedAbsoluteRingGeneric, \
198
+ pAdicFloatingPointRingGeneric, \
199
+ pAdicFloatingPointFieldGeneric, \
200
+ pAdicLatticeGeneric, \
201
+ pAdicRelaxedGeneric
202
+ from .padic_capped_relative_element import pAdicCappedRelativeElement
203
+ from .padic_capped_absolute_element import pAdicCappedAbsoluteElement
204
+ from .padic_fixed_mod_element import pAdicFixedModElement
205
+ from .padic_floating_point_element import pAdicFloatingPointElement
206
+
207
+ from sage.rings.integer_ring import ZZ
208
+
209
+
210
+ class pAdicRingCappedRelative(pAdicRingBaseGeneric, pAdicCappedRelativeRingGeneric):
211
+ r"""
212
+ An implementation of the `p`-adic integers with capped relative
213
+ precision.
214
+ """
215
+ def __init__(self, p, prec, print_mode, names, category=None):
216
+ """
217
+ Initialization.
218
+
219
+ INPUT:
220
+
221
+ - ``p`` -- prime
222
+ - ``prec`` -- precision cap
223
+ - ``print_mode`` -- dictionary with print options
224
+ - ``names`` -- how to print the prime
225
+
226
+ EXAMPLES::
227
+
228
+ sage: R = ZpCR(next_prime(10^60)) # indirect doctest
229
+ sage: type(R)
230
+ <class 'sage.rings.padics.padic_base_leaves.pAdicRingCappedRelative_with_category'>
231
+
232
+ TESTS::
233
+
234
+ sage: # needs sage.geometry.polyhedron
235
+ sage: R = ZpCR(2)
236
+ sage: TestSuite(R).run()
237
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time
238
+ ....: max_runs=2^12, skip='_test_metric_function')
239
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
240
+ sage: R = ZpCR(3, 1)
241
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)])
242
+ sage: R = ZpCR(3, 2)
243
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time
244
+ ....: skip='_test_metric_function')
245
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
246
+ sage: R = ZpCR(next_prime(10^60))
247
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time
248
+ ....: max_runs=2^5, skip='_test_log')
249
+ sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) # long time
250
+ """
251
+ pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement, category=category)
252
+
253
+ def _coerce_map_from_(self, R):
254
+ """
255
+ Return ``True`` if there is a coerce map from ``R`` to ``self``.
256
+
257
+ EXAMPLES::
258
+
259
+ sage: K = Zp(17)
260
+ sage: K(1) + 1 # indirect doctest
261
+ 2 + O(17^20)
262
+ sage: K.has_coerce_map_from(ZZ)
263
+ True
264
+ sage: K.has_coerce_map_from(int)
265
+ True
266
+ sage: K.has_coerce_map_from(QQ)
267
+ False
268
+ sage: K.has_coerce_map_from(RR)
269
+ False
270
+ sage: K.has_coerce_map_from(Qp(7))
271
+ False
272
+ sage: K.has_coerce_map_from(Zp(17,40))
273
+ False
274
+ sage: K.has_coerce_map_from(Zp(17,10))
275
+ True
276
+ sage: K.has_coerce_map_from(ZpCA(17,40))
277
+ False
278
+ """
279
+ #if isinstance(R, pAdicRingRelaxed) and R.prime() == self.prime():
280
+ # return True
281
+ if isinstance(R, pAdicRingCappedRelative) and R.prime() == self.prime():
282
+ if R.precision_cap() < self.precision_cap():
283
+ return True
284
+ elif (R.precision_cap() == self.precision_cap() and
285
+ self._printer.richcmp_modes(R._printer, op_LE)):
286
+ return True
287
+
288
+ def _convert_map_from_(self, R):
289
+ """
290
+ Finds conversion maps from R to this ring.
291
+
292
+ EXAMPLES::
293
+
294
+ sage: Zp(7).convert_map_from(Zmod(343))
295
+ Lifting morphism:
296
+ From: Ring of integers modulo 343
297
+ To: 7-adic Ring with capped relative precision 20
298
+ """
299
+ from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic
300
+ if isinstance(R, IntegerModRing_generic):
301
+ N = R.cardinality()
302
+ p = self.prime()
303
+ n = N.exact_log(p)
304
+ if N == p**n:
305
+ from sage.rings.padics.padic_generic import ResidueLiftingMap
306
+ return ResidueLiftingMap._create_(R, self)
307
+
308
+
309
+ class pAdicRingCappedAbsolute(pAdicRingBaseGeneric, pAdicCappedAbsoluteRingGeneric):
310
+ r"""
311
+ An implementation of the `p`-adic integers with capped absolute precision.
312
+ """
313
+ def __init__(self, p, prec, print_mode, names, category=None):
314
+ """
315
+ Initialization.
316
+
317
+ INPUT:
318
+
319
+ - ``p`` -- prime
320
+ - ``prec`` -- precision cap
321
+ - ``print_mode`` -- dictionary with print options
322
+ - ``names`` -- how to print the prime
323
+
324
+ EXAMPLES::
325
+
326
+ sage: R = ZpCA(next_prime(10^60)) # indirect doctest
327
+ sage: type(R)
328
+ <class 'sage.rings.padics.padic_base_leaves.pAdicRingCappedAbsolute_with_category'>
329
+
330
+ TESTS::
331
+
332
+ sage: # needs sage.geometry.polyhedron
333
+ sage: R = ZpCA(2)
334
+ sage: TestSuite(R).run()
335
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time
336
+ ....: max_runs=2^12, skip='_test_metric_function')
337
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
338
+ sage: R = ZpCA(3, 1)
339
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)])
340
+ sage: R = ZpCA(3, 2)
341
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time
342
+ ....: skip='_test_metric_function')
343
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
344
+ sage: R = ZpCA(next_prime(10^60))
345
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time
346
+ ....: max_runs=2^5, skip='_test_log')
347
+ sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)])
348
+ """
349
+ pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedAbsoluteElement, category=category)
350
+
351
+ def _coerce_map_from_(self, R):
352
+ """
353
+ Return ``True`` if there is a coerce map from ``R`` to ``self``.
354
+
355
+ EXAMPLES::
356
+
357
+ sage: K = ZpCA(17)
358
+ sage: K(1) + 1 # indirect doctest
359
+ 2 + O(17^20)
360
+ sage: K.has_coerce_map_from(ZZ)
361
+ True
362
+ sage: K.has_coerce_map_from(int)
363
+ True
364
+ sage: K.has_coerce_map_from(QQ)
365
+ False
366
+ sage: K.has_coerce_map_from(RR)
367
+ False
368
+ sage: K.has_coerce_map_from(Qp(7))
369
+ False
370
+ sage: K.has_coerce_map_from(ZpCA(17,40))
371
+ False
372
+ sage: K.has_coerce_map_from(ZpCA(17,10))
373
+ True
374
+ sage: K.has_coerce_map_from(Zp(17,40))
375
+ True
376
+ """
377
+ #if isinstance(R, pAdicRingRelaxed) and R.prime() == self.prime():
378
+ # return True
379
+ if isinstance(R, pAdicRingCappedRelative) and R.prime() == self.prime():
380
+ return True
381
+ if isinstance(R, pAdicRingCappedAbsolute) and R.prime() == self.prime():
382
+ if R.precision_cap() < self.precision_cap():
383
+ return True
384
+ elif (R.precision_cap() == self.precision_cap() and
385
+ self._printer.richcmp_modes(R._printer, op_LE)):
386
+ return True
387
+
388
+ def _convert_map_from_(self, R):
389
+ """
390
+ Finds conversion maps from R to this ring.
391
+
392
+ EXAMPLES::
393
+
394
+ sage: ZpCA(7).convert_map_from(Zmod(343))
395
+ Lifting morphism:
396
+ From: Ring of integers modulo 343
397
+ To: 7-adic Ring with capped absolute precision 20
398
+ """
399
+ from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic
400
+ if isinstance(R, IntegerModRing_generic):
401
+ N = R.cardinality()
402
+ p = self.prime()
403
+ n = N.exact_log(p)
404
+ if N == p**n:
405
+ from sage.rings.padics.padic_generic import ResidueLiftingMap
406
+ return ResidueLiftingMap._create_(R, self)
407
+
408
+ def _magma_init_(self, magma):
409
+ """
410
+ Conversion to magma.
411
+
412
+ EXAMPLES::
413
+
414
+ sage: # optional - magma
415
+ sage: F = Qp(5,7,"capped-abs")
416
+ sage: magma(F)
417
+ 5-adic field mod 5^7
418
+ """
419
+ return f"pAdicRing({self.prime()},{self.precision_cap()})"
420
+
421
+
422
+ class pAdicRingFloatingPoint(pAdicRingBaseGeneric, pAdicFloatingPointRingGeneric):
423
+ r"""
424
+ An implementation of the `p`-adic integers with floating point
425
+ precision.
426
+ """
427
+ def __init__(self, p, prec, print_mode, names, category=None):
428
+ """
429
+ Initialization.
430
+
431
+ INPUT:
432
+
433
+ - ``p`` -- prime
434
+ - ``prec`` -- precision cap
435
+ - ``print_mode`` -- dictionary with print options
436
+ - ``names`` -- how to print the prime
437
+
438
+ EXAMPLES::
439
+
440
+ sage: R = ZpFP(next_prime(10^60)) # indirect doctest
441
+ sage: type(R)
442
+ <class 'sage.rings.padics.padic_base_leaves.pAdicRingFloatingPoint_with_category'>
443
+
444
+ TESTS::
445
+
446
+ sage: # needs sage.geometry.polyhedron
447
+ sage: R = ZpFP(2)
448
+ sage: TestSuite(R).run()
449
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time
450
+ ....: max_runs=2^12, skip='_test_metric_function')
451
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
452
+ sage: R = ZpFP(3, 1)
453
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)])
454
+ sage: R = ZpFP(3, 2)
455
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time
456
+ ....: skip='_test_metric_function')
457
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
458
+ sage: R = ZpFP(next_prime(10^60))
459
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time
460
+ ....: max_runs=2^5, skip='_test_log')
461
+ sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)])
462
+ """
463
+ pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement, category=category)
464
+
465
+ def _coerce_map_from_(self, R):
466
+ """
467
+ Return ``True`` if there is a coerce map from ``R`` to ``self``.
468
+
469
+ EXAMPLES::
470
+
471
+ sage: K = ZpFP(17)
472
+ sage: K(1) + 1 # indirect doctest
473
+ 2
474
+ sage: K.has_coerce_map_from(ZZ)
475
+ True
476
+ sage: K.has_coerce_map_from(int)
477
+ True
478
+ sage: K.has_coerce_map_from(QQ)
479
+ False
480
+ sage: K.has_coerce_map_from(RR)
481
+ False
482
+ sage: K.has_coerce_map_from(Qp(7))
483
+ False
484
+ sage: K.has_coerce_map_from(Zp(17,40))
485
+ False
486
+ sage: K.has_coerce_map_from(Zp(17,10))
487
+ False
488
+ sage: K.has_coerce_map_from(ZpCA(17,40))
489
+ False
490
+ """
491
+ if isinstance(R, pAdicRingFloatingPoint) and R.prime() == self.prime():
492
+ if R.precision_cap() > self.precision_cap():
493
+ return True
494
+ elif R.precision_cap() == self.precision_cap() and self._printer.richcmp_modes(R._printer, op_LE):
495
+ return True
496
+
497
+ def _convert_map_from_(self, R):
498
+ """
499
+ Finds conversion maps from ``R`` to this ring.
500
+
501
+ EXAMPLES::
502
+
503
+ sage: ZpFP(7).convert_map_from(Zmod(343))
504
+ Lifting morphism:
505
+ From: Ring of integers modulo 343
506
+ To: 7-adic Ring with floating precision 20
507
+ """
508
+ from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic
509
+ if isinstance(R, IntegerModRing_generic):
510
+ N = R.cardinality()
511
+ p = self.prime()
512
+ n = N.exact_log(p)
513
+ if N == p**n:
514
+ from sage.rings.padics.padic_generic import ResidueLiftingMap
515
+ return ResidueLiftingMap._create_(R, self)
516
+
517
+
518
+ class pAdicRingFixedMod(pAdicRingBaseGeneric, pAdicFixedModRingGeneric):
519
+ r"""
520
+ An implementation of the `p`-adic integers using fixed modulus.
521
+ """
522
+ def __init__(self, p, prec, print_mode, names, category=None):
523
+ """
524
+ Initialization.
525
+
526
+ INPUT:
527
+
528
+ - ``p`` -- prime
529
+ - ``prec`` -- precision cap
530
+ - ``print_mode`` -- dictionary with print options
531
+ - ``names`` -- how to print the prime
532
+
533
+ EXAMPLES::
534
+
535
+ sage: R = ZpFM(next_prime(10^60)) # indirect doctest
536
+ sage: type(R)
537
+ <class 'sage.rings.padics.padic_base_leaves.pAdicRingFixedMod_with_category'>
538
+
539
+ TESTS::
540
+
541
+ sage: # needs sage.geometry.polyhedron
542
+ sage: R = ZpFM(2)
543
+ sage: TestSuite(R).run()
544
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time
545
+ ....: max_runs=2^12, skip='_test_metric_function')
546
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
547
+ sage: R = ZpFM(3, 1)
548
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)])
549
+ sage: R = ZpFM(3, 2)
550
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time
551
+ ....: skip='_test_metric_function')
552
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
553
+ sage: R = ZpFM(next_prime(10^60))
554
+ sage: TestSuite(R).run(skip='_test_log')
555
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^4)], # long time
556
+ ....: max_runs=2^6, skip='_test_log')
557
+ sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)])
558
+
559
+ Fraction fields work after :issue:`23510`::
560
+
561
+ sage: R = ZpFM(5)
562
+ sage: K = R.fraction_field(); K
563
+ 5-adic Field with floating precision 20
564
+ sage: K(R(90))
565
+ 3*5 + 3*5^2
566
+ """
567
+ pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFixedModElement, category=category)
568
+
569
+ def _coerce_map_from_(self, R):
570
+ """
571
+ Return ``True`` if there is a coerce map from ``R`` to ``self``.
572
+
573
+ EXAMPLES::
574
+
575
+ sage: K = ZpFM(17)
576
+ sage: K(1) + 1 # indirect doctest
577
+ 2
578
+ sage: K.has_coerce_map_from(ZZ)
579
+ True
580
+ sage: K.has_coerce_map_from(int)
581
+ True
582
+ sage: K.has_coerce_map_from(QQ)
583
+ False
584
+ sage: K.has_coerce_map_from(RR)
585
+ False
586
+ sage: K.has_coerce_map_from(Zp(7))
587
+ False
588
+ sage: K.has_coerce_map_from(ZpFM(17,40))
589
+ True
590
+ sage: K.has_coerce_map_from(ZpFM(17,10))
591
+ False
592
+ sage: K.has_coerce_map_from(Zp(17,40))
593
+ False
594
+ """
595
+ #if isinstance(R, pAdicRingRelaxed) and R.prime() == self.prime():
596
+ # return True
597
+ if isinstance(R, pAdicRingFixedMod) and R.prime() == self.prime():
598
+ if R.precision_cap() > self.precision_cap():
599
+ return True
600
+ elif (R.precision_cap() == self.precision_cap() and
601
+ self._printer.richcmp_modes(R._printer, op_LE)):
602
+ return True
603
+
604
+ def _convert_map_from_(self, R):
605
+ """
606
+ Finds conversion maps from R to this ring.
607
+
608
+ EXAMPLES::
609
+
610
+ sage: ZpFM(7).convert_map_from(Zmod(343))
611
+ Lifting morphism:
612
+ From: Ring of integers modulo 343
613
+ To: 7-adic Ring of fixed modulus 7^20
614
+ """
615
+ from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic
616
+ if isinstance(R, IntegerModRing_generic):
617
+ N = R.cardinality()
618
+ p = self.prime()
619
+ n = N.exact_log(p)
620
+ if N == p**n:
621
+ from sage.rings.padics.padic_generic import ResidueLiftingMap
622
+ return ResidueLiftingMap._create_(R, self)
623
+
624
+ def _magma_init_(self, magma):
625
+ """
626
+ Conversion to magma.
627
+
628
+ EXAMPLES::
629
+
630
+ sage: # optional - magma
631
+ sage: F = Zp(5,7,"fixed-mod")
632
+ sage: magma(F)
633
+ Quotient of the 5-adic ring modulo the ideal generated by 5^7
634
+ """
635
+ return f"pAdicQuotientRing({self.prime()},{self.precision_cap()})"
636
+
637
+
638
+ class pAdicFieldCappedRelative(pAdicFieldBaseGeneric, pAdicCappedRelativeFieldGeneric):
639
+ r"""
640
+ An implementation of `p`-adic fields with capped relative precision.
641
+
642
+ EXAMPLES::
643
+
644
+ sage: K = Qp(17, 1000000) # indirect doctest
645
+ sage: K = Qp(101) # indirect doctest
646
+ """
647
+
648
+ def __init__(self, p, prec, print_mode, names, category=None):
649
+ """
650
+ Initialization.
651
+
652
+ INPUT:
653
+
654
+ - ``p`` -- prime
655
+ - ``prec`` -- precision cap
656
+ - ``print_mode`` -- dictionary with print options
657
+ - ``names`` -- how to print the prime
658
+
659
+ EXAMPLES::
660
+
661
+ sage: K = Qp(next_prime(10^60)) # indirect doctest
662
+ sage: type(K)
663
+ <class 'sage.rings.padics.padic_base_leaves.pAdicFieldCappedRelative_with_category'>
664
+
665
+ TESTS::
666
+
667
+ sage: # needs sage.geometry.polyhedron
668
+ sage: R = Qp(2)
669
+ sage: TestSuite(R).run()
670
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time
671
+ ....: max_runs=2^12, skip='_test_metric_function')
672
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
673
+
674
+ sage: R = Qp(3, 1)
675
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time, needs sage.geometry.polyhedron
676
+ ....: skip='_test_metric_function')
677
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
678
+
679
+ sage: R = Qp(3, 2)
680
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^9)], # long time, needs sage.geometry.polyhedron
681
+ ....: skip='_test_metric_function')
682
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(3^3)])
683
+
684
+ sage: R = Qp(next_prime(10^60))
685
+ sage: TestSuite(R).run(skip='_test_log') # needs sage.geometry.polyhedron
686
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time, needs sage.geometry.polyhedron
687
+ ....: max_runs=2^5, skip='_test_log')
688
+ sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)])
689
+ """
690
+ pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement, category=category)
691
+
692
+ def _coerce_map_from_(self, R):
693
+ """
694
+ Return ``True`` if there is a coerce map from ``R`` to ``self``.
695
+
696
+ EXAMPLES::
697
+
698
+ sage: K = Qp(17)
699
+ sage: K(1) + 1 # indirect doctest
700
+ 2 + O(17^20)
701
+ sage: K.has_coerce_map_from(ZZ)
702
+ True
703
+ sage: K.has_coerce_map_from(int)
704
+ True
705
+ sage: K.has_coerce_map_from(QQ)
706
+ True
707
+ sage: K.has_coerce_map_from(RR)
708
+ False
709
+ sage: K.has_coerce_map_from(Qp(7))
710
+ False
711
+ sage: K.has_coerce_map_from(Qp(17,40))
712
+ False
713
+ sage: K.has_coerce_map_from(Qp(17,10))
714
+ True
715
+ sage: K.has_coerce_map_from(Zp(17,40))
716
+ True
717
+ """
718
+ #if isinstance(R, pAdicRingRelaxed) or isinstance(R, pAdicFieldRelaxed) and R.prime() == self.prime():
719
+ # return True
720
+ if isinstance(R, (pAdicRingCappedRelative, pAdicRingCappedAbsolute)) and R.prime() == self.prime():
721
+ return True
722
+ if isinstance(R, pAdicFieldCappedRelative) and R.prime() == self.prime():
723
+ if R.precision_cap() < self.precision_cap():
724
+ return True
725
+ elif (R.precision_cap() == self.precision_cap() and
726
+ self._printer.richcmp_modes(R._printer, op_LE)):
727
+ return True
728
+
729
+ def _convert_map_from_(self, R):
730
+ """
731
+ Finds conversion maps from R to this ring.
732
+
733
+ EXAMPLES::
734
+
735
+ sage: Qp(7).convert_map_from(Zmod(343))
736
+ Lifting morphism:
737
+ From: Ring of integers modulo 343
738
+ To: 7-adic Field with capped relative precision 20
739
+ """
740
+ from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic
741
+ if isinstance(R, IntegerModRing_generic):
742
+ N = R.cardinality()
743
+ p = self.prime()
744
+ n = N.exact_log(p)
745
+ if N == p**n:
746
+ from sage.rings.padics.padic_generic import ResidueLiftingMap
747
+ return ResidueLiftingMap._create_(R, self)
748
+
749
+ def _magma_init_(self, magma):
750
+ """
751
+ Conversion to magma.
752
+
753
+ EXAMPLES::
754
+
755
+ sage: # optional - magma
756
+ sage: F = Qp(5,7,"capped-rel")
757
+ sage: magma(F)
758
+ 5-adic field mod 5^7
759
+ """
760
+ return f"pAdicField({self.prime()},{self.precision_cap()})"
761
+
762
+ def random_element(self, algorithm='default'):
763
+ r"""
764
+ Return a random element of ``self``, optionally using the ``algorithm``
765
+ argument to decide how it generates the element. Algorithms currently
766
+ implemented:
767
+
768
+ - ``'default'``: Choose an integer `k` using the standard
769
+ distribution on the integers. Then choose an integer `a`
770
+ uniformly in the range `0 \le a < p^N` where `N` is the
771
+ precision cap of ``self``. Return ``self(p^k * a, absprec =
772
+ k + self.precision_cap())``.
773
+
774
+ EXAMPLES::
775
+
776
+ sage: Qp(17,6).random_element().parent() is Qp(17,6)
777
+ True
778
+ """
779
+ if (algorithm == 'default'):
780
+ k = ZZ.random_element()
781
+ a = ZZ.random_element(self.prime()**self.precision_cap())
782
+ return self(self.prime()**k * a, absprec=k + self.precision_cap())
783
+ else:
784
+ raise NotImplementedError("Don't know %s algorithm" % algorithm)
785
+
786
+
787
+ class pAdicFieldFloatingPoint(pAdicFieldBaseGeneric, pAdicFloatingPointFieldGeneric):
788
+ r"""
789
+ An implementation of the `p`-adic rationals with floating point
790
+ precision.
791
+ """
792
+ def __init__(self, p, prec, print_mode, names, category=None):
793
+ """
794
+ Initialization.
795
+
796
+ INPUT:
797
+
798
+ - ``p`` -- prime
799
+ - ``prec`` -- precision cap
800
+ - ``print_mode`` -- dictionary with print options
801
+ - ``names`` -- how to print the prime
802
+
803
+ EXAMPLES::
804
+
805
+ sage: R = QpFP(next_prime(10^60)) # indirect doctest
806
+ sage: type(R)
807
+ <class 'sage.rings.padics.padic_base_leaves.pAdicFieldFloatingPoint_with_category'>
808
+
809
+ TESTS::
810
+
811
+ sage: # needs sage.geometry.polyhedron
812
+ sage: R = QpFP(2)
813
+ sage: TestSuite(R).run()
814
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^10)], # long time
815
+ ....: max_runs=2^12, skip='_test_metric_function')
816
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
817
+ sage: R = QpFP(3, 1)
818
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^3)])
819
+ sage: R = QpFP(3, 2)
820
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(3^6)], # long time
821
+ ....: skip='_test_metric_function')
822
+ sage: R._test_metric_function(elements=[R.random_element() for i in range(2^3)]) # long time
823
+ sage: R = QpFP(next_prime(10^60))
824
+ sage: TestSuite(R).run(skip='_test_log')
825
+ sage: TestSuite(R).run(elements=[R.random_element() for i in range(2^3)], # long time
826
+ ....: max_runs=2^5, skip='_test_log')
827
+ sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)])
828
+ """
829
+ pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement, category=category)
830
+
831
+ def _coerce_map_from_(self, R):
832
+ """
833
+ Return ``True`` if there is a coerce map from ``R`` to ``self``.
834
+
835
+ EXAMPLES::
836
+
837
+ sage: K = QpFP(17)
838
+ sage: K(1) + 1 # indirect doctest
839
+ 2
840
+ sage: K.has_coerce_map_from(ZZ)
841
+ True
842
+ sage: K.has_coerce_map_from(int)
843
+ True
844
+ sage: K.has_coerce_map_from(QQ)
845
+ True
846
+ sage: K.has_coerce_map_from(RR)
847
+ False
848
+ sage: K.has_coerce_map_from(Qp(7))
849
+ False
850
+ sage: K.has_coerce_map_from(Zp(17,40))
851
+ False
852
+ sage: K.has_coerce_map_from(Qp(17,10))
853
+ False
854
+ sage: K.has_coerce_map_from(ZpFP(17))
855
+ True
856
+ sage: K.has_coerce_map_from(ZpCA(17,40))
857
+ False
858
+ """
859
+ if isinstance(R, (pAdicRingFixedMod, pAdicRingFloatingPoint, pAdicFieldFloatingPoint)) and R.prime() == self.prime():
860
+ if R.precision_cap() > self.precision_cap():
861
+ return True
862
+ elif R.precision_cap() == self.precision_cap() and self._printer.richcmp_modes(R._printer, op_LE):
863
+ return True
864
+
865
+ def _convert_map_from_(self, R):
866
+ """
867
+ Finds conversion maps from R to this ring.
868
+
869
+ EXAMPLES::
870
+
871
+ sage: QpFP(7).convert_map_from(Zmod(343))
872
+ Lifting morphism:
873
+ From: Ring of integers modulo 343
874
+ To: 7-adic Field with floating precision 20
875
+ """
876
+ from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic
877
+ if isinstance(R, IntegerModRing_generic):
878
+ N = R.cardinality()
879
+ p = self.prime()
880
+ n = N.exact_log(p)
881
+ if N == p**n:
882
+ from sage.rings.padics.padic_generic import ResidueLiftingMap
883
+ return ResidueLiftingMap._create_(R, self)
884
+
885
+ # Lattice precision
886
+ ###################
887
+
888
+
889
+ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
890
+ """
891
+ An implementation of the `p`-adic integers with lattice precision.
892
+
893
+ INPUT:
894
+
895
+ - ``p`` -- prime
896
+
897
+ - ``prec`` -- precision cap, given as a pair (``relative_cap``, ``absolute_cap``)
898
+
899
+ - ``subtype`` -- either ``'cap'`` or ``'float'``
900
+
901
+ - ``print_mode`` -- dictionary with print options
902
+
903
+ - ``names`` -- how to print the prime
904
+
905
+ - ``label`` -- the label of this ring
906
+
907
+ .. SEEALSO::
908
+
909
+ :meth:`label`
910
+
911
+ EXAMPLES::
912
+
913
+ sage: R = ZpLC(next_prime(10^60)) # indirect doctest
914
+ doctest:...: FutureWarning: This class/method/function is marked as experimental.
915
+ It, its functionality or its interface might change without a formal deprecation.
916
+ See https://github.com/sagemath/sage/issues/23505 for details.
917
+ sage: type(R)
918
+ <class 'sage.rings.padics.padic_base_leaves.pAdicRingLattice_with_category'>
919
+
920
+ sage: R = ZpLC(2, label='init') # indirect doctest
921
+ sage: R
922
+ 2-adic Ring with lattice-cap precision (label: init)
923
+ """
924
+ def __init__(self, p, prec, subtype, print_mode, names, label=None, category=None):
925
+ """
926
+ Initialization.
927
+
928
+ TESTS:
929
+
930
+ sage: R = ZpLC(7, label='init')
931
+ sage: TestSuite(R).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time
932
+ """
933
+ # We need to set the subtype first, so that
934
+ # pAdicRingBaseGeneric.__init__ can work
935
+ self._subtype = subtype
936
+ if isinstance(prec, tuple):
937
+ pAdicRingBaseGeneric.__init__(self, p, prec[1], print_mode, names, None, category=category)
938
+ else:
939
+ pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, None, category=category)
940
+ pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label, category=category)
941
+
942
+ def _coerce_map_from_(self, R):
943
+ """
944
+ Return ``True`` if there is a coerce map from ``R`` to this ring.
945
+
946
+ EXAMPLES::
947
+
948
+ sage: R = ZpLC(2)
949
+ sage: R.has_coerce_map_from(ZZ)
950
+ True
951
+ sage: R.has_coerce_map_from(QQ)
952
+ False
953
+
954
+ sage: K = R.fraction_field()
955
+ sage: K.has_coerce_map_from(R)
956
+ True
957
+ sage: K.has_coerce_map_from(QQ)
958
+ True
959
+
960
+ Note that coerce map does not exist between ``p``-adic rings with
961
+ lattice precision and other ``p``-adic rings. ::
962
+
963
+ sage: S = Zp(2)
964
+ sage: R.has_coerce_map_from(S)
965
+ False
966
+ sage: S.has_coerce_map_from(R)
967
+ False
968
+
969
+ Similarly there is no coercion maps between ``p``-adic rings with
970
+ different labels. ::
971
+
972
+ sage: R2 = ZpLC(2, label='coerce')
973
+ sage: R.has_coerce_map_from(R2)
974
+ False
975
+ sage: R2.has_coerce_map_from(R)
976
+ False
977
+ """
978
+ if isinstance(R, pAdicRingLattice) and R.precision() is self.precision():
979
+ return True
980
+
981
+ def random_element(self, prec=None):
982
+ """
983
+ Return a random element of this ring.
984
+
985
+ INPUT:
986
+
987
+ - ``prec`` -- integer or ``None`` (default); the
988
+ absolute precision of the generated random element
989
+
990
+ EXAMPLES::
991
+
992
+ sage: R = ZpLC(2)
993
+ sage: R.random_element() # random
994
+ 2^3 + 2^4 + 2^5 + 2^6 + 2^7 + 2^10 + 2^11 + 2^14 + 2^15 + 2^16
995
+ + 2^17 + 2^18 + 2^19 + 2^21 + O(2^23)
996
+
997
+ sage: R.random_element(prec=10) # random
998
+ 1 + 2^3 + 2^4 + 2^7 + O(2^10)
999
+ """
1000
+ p = self.prime()
1001
+ if self._subtype == 'cap':
1002
+ if prec is None:
1003
+ prec = self._prec_cap_absolute
1004
+ x = ZZ.random_element(p**prec)
1005
+ relcap = x.valuation(p) + self._prec_cap_relative
1006
+ prec = min(relcap, prec)
1007
+ return self._element_class(self, x, prec=prec)
1008
+ else:
1009
+ if prec is None:
1010
+ cap = self._prec_cap_relative
1011
+ else:
1012
+ cap = prec
1013
+ x = ZZ.random_element(p**cap)
1014
+ v = x.valuation(p)
1015
+ if prec is None and v > 0:
1016
+ x += p**cap * ZZ.random_element(p**v)
1017
+ return self._element_class(self, x, prec=prec)
1018
+
1019
+
1020
+ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
1021
+ """
1022
+ An implementation of the `p`-adic numbers with lattice precision.
1023
+
1024
+ INPUT:
1025
+
1026
+ - ``p`` -- prime
1027
+
1028
+ - ``prec`` -- precision cap, given as a pair (``relative_cap``, ``absolute_cap``)
1029
+
1030
+ - ``subtype`` -- either ``'cap'`` or ``'float'``
1031
+
1032
+ - ``print_mode`` -- dictionary with print options
1033
+
1034
+ - ``names`` -- how to print the prime
1035
+
1036
+ - ``label`` -- the label of this ring
1037
+
1038
+ .. SEEALSO::
1039
+
1040
+ :meth:`label`
1041
+
1042
+ EXAMPLES::
1043
+
1044
+ sage: R = QpLC(next_prime(10^60)) # indirect doctest
1045
+ doctest:...: FutureWarning: This class/method/function is marked as experimental.
1046
+ It, its functionality or its interface might change without a formal deprecation.
1047
+ See https://github.com/sagemath/sage/issues/23505 for details.
1048
+ sage: type(R)
1049
+ <class 'sage.rings.padics.padic_base_leaves.pAdicFieldLattice_with_category'>
1050
+
1051
+ sage: R = QpLC(2,label='init') # indirect doctest
1052
+ sage: R
1053
+ 2-adic Field with lattice-cap precision (label: init)
1054
+ """
1055
+ def __init__(self, p, prec, subtype, print_mode, names, label=None, category=None):
1056
+ """
1057
+ Initialization.
1058
+
1059
+ TESTS::
1060
+
1061
+ sage: R = QpLC(7, label='init')
1062
+ sage: TestSuite(R).run(skip=['_test_teichmuller', '_test_matrix_smith']) # long time
1063
+ """
1064
+ # We need to set the subtype first, so that
1065
+ # pAdicFieldBaseGeneric.__init__ can work
1066
+ self._subtype = subtype
1067
+ if isinstance(prec, tuple):
1068
+ pAdicFieldBaseGeneric.__init__(self, p, prec[1], print_mode, names, None, category=category)
1069
+ else:
1070
+ pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, None, category=category)
1071
+ pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label, category=category)
1072
+
1073
+ def _coerce_map_from_(self, R):
1074
+ """
1075
+ Return ``True`` if there is a coerce map from ``R`` to this ring.
1076
+
1077
+ EXAMPLES::
1078
+
1079
+ sage: R = ZpLC(2)
1080
+ sage: R.has_coerce_map_from(ZZ)
1081
+ True
1082
+ sage: R.has_coerce_map_from(QQ)
1083
+ False
1084
+
1085
+ sage: K = R.fraction_field()
1086
+ sage: K.has_coerce_map_from(R)
1087
+ True
1088
+ sage: K.has_coerce_map_from(QQ)
1089
+ True
1090
+
1091
+ Note that coerce map does not exist between ``p``-adic fields with
1092
+ lattice precision and other ``p``-adic rings. ::
1093
+
1094
+ sage: L = Qp(2)
1095
+ sage: K.has_coerce_map_from(L)
1096
+ False
1097
+ sage: L.has_coerce_map_from(K)
1098
+ False
1099
+
1100
+ Similarly there is no coercion maps between ``p``-adic rings with
1101
+ different labels.
1102
+
1103
+ sage: K2 = QpLC(2, label='coerce')
1104
+ sage: K.has_coerce_map_from(K2)
1105
+ False
1106
+ sage: K2.has_coerce_map_from(K)
1107
+ False
1108
+ """
1109
+ if isinstance(R, (pAdicRingLattice, pAdicFieldLattice)) and R.precision() is self.precision():
1110
+ return True
1111
+
1112
+ def random_element(self, prec=None, integral=False):
1113
+ """
1114
+ Return a random element of this ring.
1115
+
1116
+ INPUT:
1117
+
1118
+ - ``prec`` -- integer or ``None`` (default); the
1119
+ absolute precision of the generated random element
1120
+
1121
+ - ``integral`` -- boolean (default: ``False``); if ``True``,
1122
+ return an element in the ring of integers
1123
+
1124
+ EXAMPLES::
1125
+
1126
+ sage: K = QpLC(2)
1127
+ sage: K.random_element() # not tested, known bug (see :issue:`32126`)
1128
+ 2^-8 + 2^-7 + 2^-6 + 2^-5 + 2^-3 + 1 + 2^2 + 2^3 + 2^5 + O(2^12)
1129
+ sage: K.random_element(integral=True) # random
1130
+ 2^3 + 2^4 + 2^5 + 2^6 + 2^7 + 2^10 + 2^11 + 2^14 + 2^15 + 2^16
1131
+ + 2^17 + 2^18 + 2^19 + O(2^20)
1132
+
1133
+ sage: K.random_element(prec=10) # random
1134
+ 2^(-3) + 1 + 2 + 2^4 + 2^8 + O(2^10)
1135
+
1136
+ If the given precision is higher than the internal cap of the
1137
+ parent, then the cap is used::
1138
+
1139
+ sage: K.precision_cap_relative()
1140
+ 20
1141
+ sage: K.random_element(prec=100) # random
1142
+ 2^5 + 2^8 + 2^11 + 2^12 + 2^14 + 2^18 + 2^20 + 2^24 + O(2^25)
1143
+ """
1144
+ if integral:
1145
+ val = 0
1146
+ else:
1147
+ val = ZZ.random_element()
1148
+ if prec is None:
1149
+ prec = self._prec_cap_absolute - val
1150
+ p = self.prime()
1151
+ x = ZZ.random_element(p**prec)
1152
+ relcap = x.valuation(p) + self._prec_cap_relative
1153
+ prec = min(relcap, prec)
1154
+ return self._element_class(self, x*(p**val), prec=prec)
1155
+
1156
+ # Relaxed
1157
+ #########
1158
+
1159
+
1160
+ class pAdicRingRelaxed(pAdicRelaxedGeneric, pAdicRingBaseGeneric):
1161
+ r"""
1162
+ An implementation of relaxed arithmetics over `\ZZ_p`.
1163
+
1164
+ INPUT:
1165
+
1166
+ - ``p`` -- prime
1167
+
1168
+ - ``prec`` -- default precision
1169
+
1170
+ - ``print_mode`` -- dictionary with print options
1171
+
1172
+ - ``names`` -- how to print the prime
1173
+
1174
+ EXAMPLES::
1175
+
1176
+ sage: R = ZpER(5) # indirect doctest # needs sage.libs.flint
1177
+ sage: type(R) # needs sage.libs.flint
1178
+ <class 'sage.rings.padics.padic_base_leaves.pAdicRingRelaxed_with_category'>
1179
+ """
1180
+ def __init__(self, p, prec, print_mode, names, category=None):
1181
+ """
1182
+ Initialization.
1183
+
1184
+ TESTS::
1185
+
1186
+ sage: # needs sage.libs.flint
1187
+ sage: R = ZpER(7)
1188
+ sage: TestSuite(R).run(skip=['_test_log', '_test_matrix_smith'])
1189
+ sage: R = ZpER(7, secure=True)
1190
+ sage: TestSuite(R).run(skip=['_test_log', '_test_matrix_smith'])
1191
+ """
1192
+ from sage.rings.padics import padic_relaxed_element
1193
+ self._default_prec, self._halting_prec, self._secure = prec
1194
+ pAdicRingBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement, category=category)
1195
+ self._element_class_module = padic_relaxed_element
1196
+ self._element_class_prefix = "pAdicRelaxedElement_"
1197
+
1198
+
1199
+ class pAdicFieldRelaxed(pAdicRelaxedGeneric, pAdicFieldBaseGeneric):
1200
+ r"""
1201
+ An implementation of relaxed arithmetics over `\QQ_p`.
1202
+
1203
+ INPUT:
1204
+
1205
+ - ``p`` -- prime
1206
+
1207
+ - ``prec`` -- default precision
1208
+
1209
+ - ``print_mode`` -- dictionary with print options
1210
+
1211
+ - ``names`` -- how to print the prime
1212
+
1213
+ EXAMPLES::
1214
+
1215
+ sage: R = QpER(5) # indirect doctest # needs sage.libs.flint
1216
+ sage: type(R) # needs sage.libs.flint
1217
+ <class 'sage.rings.padics.padic_base_leaves.pAdicFieldRelaxed_with_category'>
1218
+ """
1219
+ def __init__(self, p, prec, print_mode, names, category=None):
1220
+ """
1221
+ Initialization.
1222
+
1223
+ TESTS::
1224
+
1225
+ sage: # needs sage.libs.flint
1226
+ sage: K = QpER(7)
1227
+ sage: TestSuite(K).run(skip=['_test_log', '_test_matrix_smith'])
1228
+ sage: K = QpER(7, secure=True)
1229
+ sage: TestSuite(K).run(skip=['_test_log', '_test_matrix_smith'])
1230
+ """
1231
+ from sage.rings.padics import padic_relaxed_element
1232
+ self._default_prec, self._halting_prec, self._secure = prec
1233
+ pAdicFieldBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement, category=category)
1234
+ self._element_class_module = padic_relaxed_element
1235
+ self._element_class_prefix = "pAdicRelaxedElement_"