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,1847 @@
1
+ # sage_setup: distribution = sagemath-pari
2
+ r"""
3
+ Capped absolute template for complete discrete valuation rings
4
+
5
+ In order to use this template you need to write a linkage file and gluing file.
6
+ For an example see ``mpz_linkage.pxi`` (linkage file) and
7
+ ``padic_capped_absolute_element.pyx`` (gluing file).
8
+
9
+ The linkage file implements a common API that is then used in the class
10
+ :class:`CAElement` defined here.
11
+ See the documentation of ``mpz_linkage.pxi`` for the functions needed.
12
+
13
+ The gluing file does the following:
14
+
15
+ - ctypedef's celement to be the appropriate type (e.g. ``mpz_t``)
16
+ - includes the linkage file
17
+ - includes this template
18
+ - defines a concrete class inheriting from :class:`CAElement`, and implements
19
+ any desired extra methods
20
+
21
+ AUTHORS:
22
+
23
+ - David Roe (2012-3-1) -- initial version
24
+ """
25
+
26
+ #*****************************************************************************
27
+ # Copyright (C) 2012 David Roe <roed.math@gmail.com>
28
+ # William Stein <wstein@gmail.com>
29
+ #
30
+ # Distributed under the terms of the GNU General Public License (GPL)
31
+ # as published by the Free Software Foundation; either version 2 of
32
+ # the License, or (at your option) any later version.
33
+ #
34
+ # http://www.gnu.org/licenses/
35
+ #*****************************************************************************
36
+
37
+ # This file implements common functionality among template elements
38
+ include "padic_template_element.pxi"
39
+
40
+ from collections.abc import Iterable
41
+ from sage.structure.element cimport Element
42
+ from sage.rings.padics.common_conversion cimport comb_prec, _process_args_and_kwds
43
+ from sage.rings.integer_ring import ZZ
44
+ from sage.rings.rational_field import QQ
45
+ from sage.categories.sets_cat import Sets
46
+ from sage.categories.sets_with_partial_maps import SetsWithPartialMaps
47
+ from sage.categories.homset import Hom
48
+
49
+ cdef class CAElement(pAdicTemplateElement):
50
+ cdef int _set(self, x, long val, long xprec, absprec, relprec) except -1:
51
+ """
52
+ Set the value of this element from given defining data.
53
+
54
+ This function is intended for use in conversion, and should
55
+ not be called on an element created with :meth:`_new_c`.
56
+
57
+ INPUT:
58
+
59
+ - ``x`` -- data defining a `p`-adic element: int,
60
+ Integer, Rational, other `p`-adic element...
61
+
62
+ - ``val`` -- the valuation of the resulting element
63
+
64
+ - ``xprec -- an inherent precision of ``x``
65
+
66
+ - ``absprec`` -- an absolute precision cap for this element
67
+
68
+ - ``relprec`` -- a relative precision cap for this element
69
+
70
+ TESTS::
71
+
72
+ sage: R = ZpCA(5)
73
+ sage: a = R(17,5); a # indirect doctest
74
+ 2 + 3*5 + O(5^5)
75
+ sage: a = R(75, absprec = 5, relprec = 4); a # indirect doctest
76
+ 3*5^2 + O(5^5)
77
+ sage: a = R(25/9, absprec = 5); a # indirect doctest
78
+ 4*5^2 + 2*5^3 + O(5^5)
79
+ sage: a = R(25/9, absprec = 5, relprec = 4); a # indirect doctest
80
+ 4*5^2 + 2*5^3 + O(5^5)
81
+ """
82
+ IF CELEMENT_IS_PY_OBJECT:
83
+ polyt = type(self.prime_pow.modulus)
84
+ self.value = <celement>polyt.__new__(polyt)
85
+ cconstruct(self.value, self.prime_pow)
86
+ cdef long rprec = comb_prec(relprec, self.prime_pow.ram_prec_cap)
87
+ cdef long aprec = comb_prec(absprec, min(self.prime_pow.ram_prec_cap, xprec))
88
+ if aprec <= val:
89
+ csetzero(self.value, self.prime_pow)
90
+ self.absprec = aprec
91
+ else:
92
+ self.absprec = min(aprec, val + rprec)
93
+ if isinstance(x, CAElement) and x.parent() is self.parent():
94
+ cshift_notrunc(self.value, (<CAElement>x).value, 0, self.absprec, self.prime_pow, True)
95
+ else:
96
+ cconv(self.value, x, self.absprec, 0, self.prime_pow)
97
+
98
+ cdef CAElement _new_c(self):
99
+ """
100
+ Create a new element with the same basic info.
101
+
102
+ TESTS::
103
+
104
+ sage: R = ZpCA(5); R(6,5) * R(7,8) # indirect doctest
105
+ 2 + 3*5 + 5^2 + O(5^5)
106
+
107
+ sage: # needs sage.libs.flint
108
+ sage: R.<a> = ZqCA(25)
109
+ sage: S.<x> = ZZ[]
110
+ sage: W.<w> = R.ext(x^2 - 5)
111
+ sage: w * (w+1) # indirect doctest
112
+ w + w^2 + O(w^40)
113
+ """
114
+ cdef type t = type(self)
115
+ cdef CAElement ans = t.__new__(t)
116
+ ans._parent = self._parent
117
+ ans.prime_pow = self.prime_pow
118
+ IF CELEMENT_IS_PY_OBJECT:
119
+ polyt = type(self.prime_pow.modulus)
120
+ ans.value = <celement>polyt.__new__(polyt)
121
+ cconstruct(ans.value, ans.prime_pow)
122
+ return ans
123
+
124
+ cdef pAdicTemplateElement _new_with_value(self, celement value, long absprec):
125
+ """
126
+ Create a new element with a given value and absolute precision.
127
+
128
+ Used by code that doesn't know the precision type.
129
+ """
130
+ cdef CAElement ans = self._new_c()
131
+ ans.absprec = absprec
132
+ self.check_preccap()
133
+ creduce(ans.value, value, absprec, ans.prime_pow)
134
+ return ans
135
+
136
+ cdef int _get_unit(self, celement value) except -1:
137
+ """
138
+ Set ``value`` to the unit of this `p`-adic element.
139
+ """
140
+ cremove(value, self.value, self.absprec, self.prime_pow, True)
141
+
142
+ cdef int check_preccap(self) except -1:
143
+ """
144
+ Check that this element doesn't have precision higher than
145
+ allowed by the precision cap.
146
+
147
+ TESTS::
148
+
149
+ sage: ZpCA(5)(1).lift_to_precision(30) # indirect doctest
150
+ Traceback (most recent call last):
151
+ ...
152
+ PrecisionError: precision higher than allowed by the precision cap
153
+ """
154
+ if self.absprec > self.prime_pow.ram_prec_cap:
155
+ raise PrecisionError("precision higher than allowed by the precision cap")
156
+
157
+ def __copy__(self):
158
+ """
159
+ Return a copy of this element.
160
+
161
+ EXAMPLES::
162
+
163
+ sage: a = ZpCA(5,6)(17); b = copy(a)
164
+ sage: a == b
165
+ True
166
+ sage: a is b
167
+ False
168
+ """
169
+ cdef CAElement ans = self._new_c()
170
+ ans.absprec = self.absprec
171
+ ccopy(ans.value, self.value, ans.prime_pow)
172
+ return ans
173
+
174
+ def __dealloc__(self):
175
+ """
176
+ Deallocate the underlying data structure.
177
+
178
+ TESTS::
179
+
180
+ sage: R = ZpCA(5)
181
+ sage: a = R(17)
182
+ sage: del(a)
183
+ """
184
+ cdestruct(self.value, self.prime_pow)
185
+
186
+ def __reduce__(self):
187
+ """
188
+ Return a tuple of a function and data that can be used to unpickle this
189
+ element.
190
+
191
+ TESTS::
192
+
193
+ sage: a = ZpCA(5)(-3)
194
+ sage: type(a)
195
+ <class 'sage.rings.padics.padic_capped_absolute_element.pAdicCappedAbsoluteElement'>
196
+ sage: loads(dumps(a)) == a
197
+ True
198
+ """
199
+ return unpickle_cae_v2, (self.__class__, self.parent(), cpickle(self.value, self.prime_pow), self.absprec)
200
+
201
+ cpdef _neg_(self):
202
+ """
203
+ Return the additive inverse of this element.
204
+
205
+ EXAMPLES::
206
+
207
+ sage: R = Zp(5, prec=10, type='capped-abs')
208
+ sage: a = R(1)
209
+ sage: -a # indirect doctest
210
+ 4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + O(5^10)
211
+ """
212
+ cdef CAElement ans = self._new_c()
213
+ ans.absprec = self.absprec
214
+ cneg(ans.value, self.value, ans.absprec, ans.prime_pow)
215
+ creduce_small(ans.value, ans.value, ans.absprec, ans.prime_pow)
216
+ return ans
217
+
218
+ cpdef _add_(self, _right):
219
+ """
220
+ Return the sum of this element and ``_right``.
221
+
222
+ EXAMPLES::
223
+
224
+ sage: R = ZpCA(13, 4)
225
+ sage: R(2) + R(3) # indirect doctest
226
+ 5 + O(13^4)
227
+ sage: R(12) + R(1)
228
+ 13 + O(13^4)
229
+
230
+ Check that :issue:`20245` is resolved::
231
+
232
+ sage: R(1,1) + R(169,3)
233
+ 1 + O(13)
234
+ """
235
+ cdef CAElement right = _right
236
+ cdef CAElement ans = self._new_c()
237
+ ans.absprec = min(self.absprec, right.absprec)
238
+ cadd(ans.value, self.value, right.value, ans.absprec, ans.prime_pow)
239
+ creduce(ans.value, ans.value, ans.absprec, ans.prime_pow)
240
+ return ans
241
+
242
+ cpdef _sub_(self, _right):
243
+ """
244
+ Return the difference of this element and ``_right``.
245
+
246
+ EXAMPLES::
247
+
248
+ sage: R = ZpCA(13, 4)
249
+ sage: R(10) - R(10) # indirect doctest
250
+ O(13^4)
251
+ sage: R(10) - R(11)
252
+ 12 + 12*13 + 12*13^2 + 12*13^3 + O(13^4)
253
+ """
254
+ cdef CAElement right = _right
255
+ cdef CAElement ans = self._new_c()
256
+ ans.absprec = min(self.absprec, right.absprec)
257
+ csub(ans.value, self.value, right.value, ans.absprec, ans.prime_pow)
258
+ creduce(ans.value, ans.value, ans.absprec, ans.prime_pow)
259
+ return ans
260
+
261
+ def __invert__(self):
262
+ """
263
+ Return the multiplicative inverse of this element.
264
+
265
+ .. NOTE::
266
+
267
+ The result always lives in the fraction field, even if this element
268
+ is a unit.
269
+
270
+ EXAMPLES::
271
+
272
+ sage: R = ZpCA(17)
273
+ sage: ~R(-1) == R(-1)
274
+ True
275
+ sage: ~R(5) * 5
276
+ 1 + O(17^20)
277
+ sage: ~R(5)
278
+ 7 + 3*17 + 10*17^2 + 13*17^3 + 6*17^4 + 3*17^5 + 10*17^6 + 13*17^7
279
+ + 6*17^8 + 3*17^9 + 10*17^10 + 13*17^11 + 6*17^12 + 3*17^13
280
+ + 10*17^14 + 13*17^15 + 6*17^16 + 3*17^17 + 10*17^18 + 13*17^19 + O(17^20)
281
+ sage: ~R(-1) == R(-1) # indirect doctest
282
+ True
283
+ """
284
+ return ~self.parent().fraction_field()(self)
285
+
286
+ cpdef _mul_(self, _right):
287
+ """
288
+ Return the product of this element and ``_right``.
289
+
290
+ EXAMPLES::
291
+
292
+ sage: R = ZpCA(5)
293
+ sage: a = R(20,5); b = R(75, 4); a * b # indirect doctest
294
+ 2*5^3 + 2*5^4 + O(5^5)
295
+ """
296
+ cdef CAElement right = _right
297
+ cdef CAElement ans = self._new_c()
298
+ cdef long vals, valr
299
+ if self.absprec == self.prime_pow.ram_prec_cap and right.absprec == self.prime_pow.ram_prec_cap:
300
+ ans.absprec = self.absprec
301
+ else:
302
+ vals = self.valuation_c()
303
+ valr = right.valuation_c()
304
+ ans.absprec = min(vals + valr + min(self.absprec - vals, right.absprec - valr), self.prime_pow.ram_prec_cap)
305
+ cmul(ans.value, self.value, right.value, ans.absprec, ans.prime_pow)
306
+ creduce(ans.value, ans.value, ans.absprec, ans.prime_pow)
307
+ return ans
308
+
309
+ cpdef _div_(self, right):
310
+ """
311
+ Return the quotient of this element and ``right``.
312
+
313
+ .. NOTE::
314
+
315
+ The result always lives in the fraction field, even if ``right`` is
316
+ a unit.
317
+
318
+ EXAMPLES::
319
+
320
+ sage: R = ZpCA(13, 4)
321
+ sage: R(2) / R(3) # indirect doctest
322
+ 5 + 4*13 + 4*13^2 + 4*13^3 + O(13^4)
323
+ sage: a = R(169 * 2) / R(13); a
324
+ 2*13 + O(13^3)
325
+ sage: R(13) / R(169 * 2)
326
+ 7*13^-1 + 6 + O(13)
327
+ sage: ~a
328
+ 7*13^-1 + 6 + O(13)
329
+ sage: 1 / a
330
+ 7*13^-1 + 6 + O(13)
331
+ """
332
+ K = self.parent().fraction_field()
333
+ return K(self) / K(right)
334
+
335
+ def _quo_rem(self, _right):
336
+ """
337
+ Quotient with remainder.
338
+
339
+ EXAMPLES::
340
+
341
+ sage: R = ZpCA(3, 5)
342
+ sage: R(12).quo_rem(R(2)) # indirect doctest
343
+ (2*3 + O(3^5), O(3^5))
344
+ sage: R(2).quo_rem(R(12)) # indirect doctest
345
+ (O(3^4), 2 + O(3^5))
346
+ sage: q, r = R(4).quo_rem(R(12)); q, r
347
+ (1 + 2*3 + 2*3^3 + O(3^4), 1 + O(3^5))
348
+ sage: 12*q + r == 4
349
+ True
350
+
351
+ In general, the remainder is returned with maximal precision.
352
+ However, it is not the case when the valuation of the divisor
353
+ is greater than the absolute precision on the numerator::
354
+
355
+ sage: R(1,2).quo_rem(R(81))
356
+ (O(3^0), 1 + O(3^2))
357
+ """
358
+ cdef CAElement right = _right
359
+ if right._is_inexact_zero():
360
+ raise ZeroDivisionError
361
+ cdef CAElement q = self._new_c()
362
+ cdef CAElement r = self._new_c()
363
+ cdef long sval, srprec, rval, rrprec, diff, qrprec
364
+ sval = self.valuation_c()
365
+ srprec = self.absprec - sval
366
+ rval = right.valuation_c()
367
+ rrprec = right.absprec - rval
368
+ diff = sval - rval
369
+ rprec = min(srprec, rrprec)
370
+ r.absprec = r.prime_pow.ram_prec_cap
371
+ qrprec = diff + srprec
372
+ if qrprec < 0:
373
+ csetzero(q.value, q.prime_pow)
374
+ q.absprec = 0
375
+ r = self
376
+ elif qrprec == 0:
377
+ q._set_inexact_zero(0)
378
+ ccopy(r.value, self.value, r.prime_pow)
379
+ elif ciszero(self.value, self.prime_pow):
380
+ q.absprec = diff + rprec
381
+ csetzero(q.value, q.prime_pow)
382
+ csetzero(r.value, r.prime_pow)
383
+ elif diff >= 0:
384
+ q.absprec = diff + rprec
385
+ # shift right and self by the same power of the uniformizer
386
+ cshift_notrunc(r.value, right.value, -rval, q.absprec, r.prime_pow, False)
387
+ # We use shift_rem as a temp variable
388
+ cshift_notrunc(self.prime_pow.shift_rem, self.value, -rval, q.absprec, q.prime_pow, False)
389
+ # divide
390
+ cdivunit(q.value, self.prime_pow.shift_rem, r.value, q.absprec, q.prime_pow)
391
+ csetzero(r.value, r.prime_pow)
392
+ else:
393
+ q.absprec = min(qrprec, rrprec)
394
+ cshift(q.value, r.value, self.value, -rval, q.absprec, q.prime_pow, False)
395
+ cshift_notrunc(q.prime_pow.shift_rem, right.value, -rval, q.absprec, q.prime_pow, False)
396
+ cdivunit(q.value, q.value, q.prime_pow.shift_rem, q.absprec, q.prime_pow)
397
+ creduce(q.value, q.value, q.absprec, q.prime_pow)
398
+ return q, r
399
+
400
+ def __pow__(CAElement self, _right, dummy):
401
+ r"""
402
+ Exponentiation.
403
+
404
+ When ``right`` is divisible by `p` then one can get more
405
+ precision than expected. See the documentation in
406
+ :mod:`sage.rings.padics.CR_template.pxi` for more details.
407
+
408
+ For `p`-adic exponents, `a^b` is defined as `\exp(b \log(a))`.
409
+ Since the `p`-adic logarithm is defined for `a` a unit, the
410
+ same is true of exponentiation.
411
+
412
+ INPUT:
413
+
414
+ - ``_right`` -- currently integers and `p`-adic exponents are supported
415
+
416
+ - ``dummy`` -- not used (Python's ``__pow__`` signature includes it)
417
+
418
+ EXAMPLES::
419
+
420
+ sage: R = ZpCA(11, 5)
421
+ sage: R(1/2)^5
422
+ 10 + 7*11 + 11^2 + 5*11^3 + 4*11^4 + O(11^5)
423
+ sage: R(1/32)
424
+ 10 + 7*11 + 11^2 + 5*11^3 + 4*11^4 + O(11^5)
425
+ sage: R(1/2)^5 == R(1/32)
426
+ True
427
+ sage: R(3)^1000
428
+ 1 + 4*11^2 + 3*11^3 + 7*11^4 + O(11^5)
429
+
430
+ `p`-adic exponents are supported::
431
+
432
+ sage: R = ZpCA(11, 5, print_mode='terse')
433
+ sage: a = R(3/14, 3); b = R(8/9); c = R(11,2)
434
+ sage: a
435
+ 1046 + O(11^3)
436
+ sage: b
437
+ 35790 + O(11^5)
438
+ sage: a^b
439
+ 177 + O(11^3)
440
+ sage: a^35790
441
+ 177 + O(11^3)
442
+ sage: a^c
443
+ 848 + O(11^3)
444
+ sage: (a.log()*c).exp()
445
+ 848 + O(11^3)
446
+
447
+ sage: R = ZpCA(19, 5, print_mode='series')
448
+ sage: a = R(8/5,4); a
449
+ 13 + 7*19 + 11*19^2 + 7*19^3 + O(19^4)
450
+ sage: a^(R(19/7))
451
+ 1 + 14*19^2 + 11*19^3 + 13*19^4 + O(19^5)
452
+ sage: (a // R.teichmuller(13))^(R(19/7))
453
+ 1 + 14*19^2 + 11*19^3 + 13*19^4 + O(19^5)
454
+ sage: (a.log() * 19/7).exp()
455
+ 1 + 14*19^2 + 11*19^3 + 13*19^4 + O(19^5)
456
+
457
+ Check that :issue:`31875` is fixed::
458
+
459
+ sage: R(1)^R(0)
460
+ 1 + O(19^5)
461
+
462
+ sage: # needs sage.libs.flint
463
+ sage: S.<a> = ZqCA(4)
464
+ sage: S(1)^S(0)
465
+ 1 + O(2^20)
466
+ """
467
+ cdef long relprec, val, rval
468
+ cdef mpz_t tmp
469
+ cdef Integer right
470
+ cdef CAElement pright, ans
471
+ cdef bint exact_exp
472
+ if isinstance(_right, (Integer, int, Rational)):
473
+ if _right < 0:
474
+ base = ~self
475
+ return base.__pow__(-_right, dummy)
476
+ exact_exp = True
477
+ elif self.parent() is _right.parent():
478
+ # For extension elements, we need to switch to the
479
+ # fraction field sometimes in highly ramified extensions.
480
+ exact_exp = (<CAElement>_right)._is_exact_zero()
481
+ pright = _right
482
+ else:
483
+ self, _right = canonical_coercion(self, _right)
484
+ return self.__pow__(_right, dummy)
485
+ ans = self._new_c()
486
+ if exact_exp and _right == 0:
487
+ # return 1 to maximum precision
488
+ ans.absprec = self.prime_pow.ram_prec_cap
489
+ csetone(ans.value, ans.prime_pow)
490
+ elif ciszero(self.value, self.prime_pow):
491
+ # We may assume from above that right > 0 if exact.
492
+ # So we return a zero of precision right * self.ordp.
493
+ if isinstance(_right, int):
494
+ _right = Integer(_right)
495
+ if isinstance(_right, Integer):
496
+ right = <Integer>_right
497
+ if self.absprec == 0:
498
+ ans.absprec = 0
499
+ else:
500
+ mpz_init(tmp)
501
+ mpz_mul_si(tmp, right.value, self.absprec)
502
+ if mpz_cmp_si(tmp, self.prime_pow.ram_prec_cap) >= 0:
503
+ ans.absprec = self.prime_pow.ram_prec_cap
504
+ else:
505
+ ans.absprec = mpz_get_si(tmp)
506
+ mpz_clear(tmp)
507
+ csetzero(ans.value, ans.prime_pow)
508
+ else:
509
+ if not exact_exp and self.absprec > 0:
510
+ raise ValueError("in order to raise to a p-adic exponent, base must be a unit")
511
+ raise PrecisionError("need more precision")
512
+ else:
513
+ val = self.valuation_c()
514
+ if exact_exp:
515
+ # exact_pow_helper is defined in padic_template_element.pxi
516
+ right = exact_pow_helper(&relprec, self.absprec - val, _right, self.prime_pow)
517
+ mpz_init(tmp)
518
+ mpz_mul_si(tmp, right.value, val)
519
+ if mpz_cmp_si(tmp, self.prime_pow.ram_prec_cap) >= 0:
520
+ ans.absprec = self.prime_pow.ram_prec_cap
521
+ csetzero(ans.value, ans.prime_pow)
522
+ else:
523
+ ans.absprec = min(mpz_get_si(tmp) + relprec, self.prime_pow.ram_prec_cap)
524
+ cpow(ans.value, self.value, right.value, ans.absprec, ans.prime_pow)
525
+ mpz_clear(tmp)
526
+ else:
527
+ rval = pright.valuation_c()
528
+ if rval != 0:
529
+ pright = pright.unit_part()
530
+ # We may assume that val = 0 since the following will quickly raise an error otherwise.
531
+ # padic_pow_helper is defined in padic_template_element.pxi
532
+ ans.absprec = padic_pow_helper(ans.value, self.value, val, self.absprec,
533
+ pright.value, rval, pright.absprec, self.prime_pow)
534
+ return ans
535
+
536
+ cdef pAdicTemplateElement _lshift_c(self, long shift):
537
+ r"""
538
+ Multiply by `\pi^{\mbox{shift}}`.
539
+
540
+ Negative shifts may truncate the result.
541
+
542
+ TESTS::
543
+
544
+ sage: R = ZpCA(5); a = R(17); a << 2
545
+ 2*5^2 + 3*5^3 + O(5^20)
546
+ sage: a << -1
547
+ 3 + O(5^19)
548
+ sage: a << 0 == a
549
+ True
550
+ sage: a << 400
551
+ O(5^20)
552
+ sage: a << -400
553
+ O(5^0)
554
+ """
555
+ if shift < 0:
556
+ return self._rshift_c(-shift)
557
+ elif shift == 0:
558
+ return self
559
+ cdef CAElement ans = self._new_c()
560
+ if shift >= self.prime_pow.ram_prec_cap:
561
+ csetzero(ans.value, ans.prime_pow)
562
+ ans.absprec = self.prime_pow.ram_prec_cap
563
+ else:
564
+ ans.absprec = min(self.absprec + shift, self.prime_pow.ram_prec_cap)
565
+ cshift_notrunc(ans.value, self.value, shift, ans.absprec, ans.prime_pow, self.prime_pow.e > 1)
566
+ return ans
567
+
568
+ cdef pAdicTemplateElement _rshift_c(self, long shift):
569
+ r"""
570
+ Divide by ``π^{\mbox{shift}}``.
571
+
572
+ Positive shifts may truncate the result.
573
+
574
+ TESTS::
575
+
576
+ sage: R = ZpCA(5); a = R(77); a >> 1
577
+ 3*5 + O(5^19)
578
+ sage: a >> -1
579
+ 2*5 + 3*5^3 + O(5^20)
580
+ sage: a >> 0 == a
581
+ True
582
+ sage: a >> 400
583
+ O(5^0)
584
+ sage: a >> -400
585
+ O(5^20)
586
+ """
587
+ if shift < 0:
588
+ return self._lshift_c(-shift)
589
+ elif shift == 0:
590
+ return self
591
+ cdef CAElement ans = self._new_c()
592
+ if shift >= self.absprec:
593
+ csetzero(ans.value, ans.prime_pow)
594
+ ans.absprec = 0
595
+ else:
596
+ ans.absprec = self.absprec - shift
597
+ cshift(ans.value, ans.prime_pow.shift_rem, self.value, -shift, ans.absprec, ans.prime_pow, self.prime_pow.e > 1)
598
+ return ans
599
+
600
+ def add_bigoh(self, absprec):
601
+ """
602
+ Return a new element with absolute precision decreased to
603
+ ``absprec``. The precision never increases.
604
+
605
+ INPUT:
606
+
607
+ - ``absprec`` -- integer or infinity
608
+
609
+ OUTPUT: ``self`` with precision set to the minimum of ``self``'s
610
+ precision and ``prec``
611
+
612
+ EXAMPLES::
613
+
614
+ sage: R = Zp(7,4,'capped-abs','series'); a = R(8); a.add_bigoh(1)
615
+ 1 + O(7)
616
+
617
+ sage: k = ZpCA(3,5)
618
+ sage: a = k(41); a
619
+ 2 + 3 + 3^2 + 3^3 + O(3^5)
620
+ sage: a.add_bigoh(7)
621
+ 2 + 3 + 3^2 + 3^3 + O(3^5)
622
+ sage: a.add_bigoh(3)
623
+ 2 + 3 + 3^2 + O(3^3)
624
+
625
+ TESTS:
626
+
627
+ Verify that :issue:`13591` has been resolved::
628
+
629
+ sage: k(3).add_bigoh(-1)
630
+ O(3^-1)
631
+ """
632
+ cdef long aprec, newprec
633
+ if absprec is infinity:
634
+ return self
635
+ if isinstance(absprec, int):
636
+ aprec = absprec
637
+ else:
638
+ if not isinstance(absprec, Integer):
639
+ absprec = Integer(absprec)
640
+ if mpz_fits_slong_p((<Integer>absprec).value) == 0:
641
+ if mpz_sgn((<Integer>absprec).value) == -1:
642
+ raise ValueError("absprec must fit into a signed long")
643
+ else:
644
+ aprec = self.prime_pow.ram_prec_cap
645
+ else:
646
+ aprec = mpz_get_si((<Integer>absprec).value)
647
+ if aprec >= self.absprec:
648
+ return self
649
+ if aprec < 0:
650
+ return self.parent().fraction_field()(self).add_bigoh(absprec)
651
+ cdef CAElement ans = self._new_c()
652
+ ans.absprec = aprec
653
+ creduce(ans.value, self.value, ans.absprec, ans.prime_pow)
654
+ return ans
655
+
656
+ cpdef bint _is_exact_zero(self) except -1:
657
+ """
658
+ Test whether this element is an exact zero, which is always
659
+ ``False`` for capped absolute elements.
660
+
661
+ This function exists for compatibility with capped relative
662
+ elements.
663
+
664
+ EXAMPLES::
665
+
666
+ sage: ZpCA(5)(0)._is_exact_zero()
667
+ False
668
+ """
669
+ return False
670
+
671
+ cpdef bint _is_inexact_zero(self) except -1:
672
+ """
673
+ Determine whether this element is indistinguishable from
674
+ zero.
675
+
676
+ EXAMPLES::
677
+
678
+ sage: R = ZpCA(7, 5)
679
+ sage: R(7^5)._is_inexact_zero()
680
+ True
681
+ sage: R(0,4)._is_inexact_zero()
682
+ True
683
+ sage: R(0)._is_inexact_zero()
684
+ True
685
+ """
686
+ return ciszero(self.value, self.prime_pow)
687
+
688
+ def is_zero(self, absprec=None):
689
+ r"""
690
+ Determine whether this element is zero modulo
691
+ `\pi^{\mbox{absprec}}`.
692
+
693
+ If ``absprec is None``, returns ``True`` if this element is
694
+ indistinguishable from zero.
695
+
696
+ INPUT:
697
+
698
+ - ``absprec`` -- integer, infinity, or ``None``
699
+
700
+ EXAMPLES::
701
+
702
+ sage: R = ZpCA(17, 6)
703
+ sage: R(0).is_zero()
704
+ True
705
+ sage: R(17^6).is_zero()
706
+ True
707
+ sage: R(17^2).is_zero(absprec=2)
708
+ True
709
+ sage: R(17^6).is_zero(absprec=10)
710
+ Traceback (most recent call last):
711
+ ...
712
+ PrecisionError: not enough precision to determine if element is zero
713
+ """
714
+ if absprec is infinity:
715
+ raise PrecisionError("not enough precision to determine if element is zero")
716
+ cdef bint iszero = ciszero(self.value, self.prime_pow)
717
+ if absprec is None:
718
+ return iszero
719
+ cdef long val = self.valuation_c()
720
+ if isinstance(absprec, int):
721
+ if iszero and absprec > self.absprec:
722
+ raise PrecisionError("not enough precision to determine if element is zero")
723
+ return val >= absprec
724
+ if not isinstance(absprec, Integer):
725
+ absprec = Integer(absprec)
726
+ if iszero:
727
+ if mpz_cmp_si((<Integer>absprec).value, val) > 0:
728
+ raise PrecisionError("not enough precision to determine if element is zero")
729
+ else:
730
+ return True
731
+ return mpz_cmp_si((<Integer>absprec).value, val) <= 0
732
+
733
+ def __bool__(self):
734
+ """
735
+ Whether this element should be considered true in a boolean context.
736
+
737
+ For most applications, explicitly specifying the power of p
738
+ modulo which the element is supposed to be nonzero is
739
+ preferable.
740
+
741
+ EXAMPLES::
742
+
743
+ sage: R = ZpCA(5); a = R(0); b = R(0,5); c = R(75)
744
+ sage: bool(a), bool(b), bool(c)
745
+ (False, False, True)
746
+ """
747
+ return not ciszero(self.value, self.prime_pow)
748
+
749
+ def is_equal_to(self, _right, absprec=None):
750
+ r"""
751
+ Determine whether the inputs are equal modulo
752
+ `\pi^{\mbox{absprec}}`.
753
+
754
+ INPUT:
755
+
756
+ - ``right`` -- a `p`-adic element with the same parent
757
+
758
+ - ``absprec`` -- integer, infinity, or ``None``
759
+
760
+ EXAMPLES::
761
+
762
+ sage: R = ZpCA(2, 6)
763
+ sage: R(13).is_equal_to(R(13))
764
+ True
765
+ sage: R(13).is_equal_to(R(13+2^10))
766
+ True
767
+ sage: R(13).is_equal_to(R(17), 2)
768
+ True
769
+ sage: R(13).is_equal_to(R(17), 5)
770
+ False
771
+ sage: R(13).is_equal_to(R(13+2^10),absprec=10)
772
+ Traceback (most recent call last):
773
+ ...
774
+ PrecisionError: elements not known to enough precision
775
+ """
776
+ if absprec is infinity:
777
+ raise PrecisionError("elements not known to enough precision")
778
+ cdef CAElement right
779
+ cdef long aprec, rprec, sval, rval
780
+ if self.parent() is _right.parent():
781
+ right = _right
782
+ else:
783
+ right = self.parent()(_right)
784
+ if absprec is None:
785
+ aprec = min(self.absprec, right.absprec)
786
+ else:
787
+ if not isinstance(absprec, Integer):
788
+ absprec = Integer(absprec)
789
+ if mpz_fits_slong_p((<Integer>absprec).value) == 0:
790
+ if mpz_sgn((<Integer>absprec).value) < 0:
791
+ return True
792
+ else:
793
+ raise PrecisionError("elements not known to enough precision")
794
+ aprec = mpz_get_si((<Integer>absprec).value)
795
+ if aprec > self.absprec or aprec > right.absprec:
796
+ raise PrecisionError("elements not known to enough precision")
797
+ return ccmp(self.value, right.value, aprec, aprec < self.absprec, aprec < right.absprec, self.prime_pow) == 0
798
+
799
+ cdef int _cmp_units(self, pAdicGenericElement _right) except -2:
800
+ """
801
+ This function is used in comparing `p`-adic elements.
802
+
803
+ EXAMPLES::
804
+
805
+ sage: R = ZpCA(37)
806
+ sage: R(17) == R(17+37^6) # indirect doctest
807
+ False
808
+ """
809
+ cdef CAElement right = _right
810
+ cdef long aprec = min(self.absprec, right.absprec)
811
+ if aprec == 0:
812
+ return 0
813
+ return ccmp(self.value, right.value, aprec, aprec < self.absprec, aprec < right.absprec, self.prime_pow)
814
+
815
+ cdef pAdicTemplateElement lift_to_precision_c(self, long absprec):
816
+ """
817
+ Return an arbitrary lift of this element to higher precision.
818
+
819
+ If ``absprec`` is less than the absolute precision of this
820
+ element this function will return the input element.
821
+
822
+ INPUT:
823
+
824
+ - ``absprec`` -- integer; at most the precision cap of the parent
825
+
826
+ EXAMPLES::
827
+
828
+ sage: R = ZpCA(19)
829
+ sage: a = R(19, 7); a
830
+ 19 + O(19^7)
831
+ sage: a.lift_to_precision(12) # indirect doctest
832
+ 19 + O(19^12)
833
+ sage: a.lift_to_precision(4) is a
834
+ True
835
+ """
836
+ cdef CAElement ans
837
+ if absprec == maxordp:
838
+ absprec = self.prime_pow.ram_prec_cap
839
+ if absprec <= self.absprec:
840
+ return self
841
+ ans = self._new_c()
842
+ ccopy(ans.value, self.value, ans.prime_pow)
843
+ ans.absprec = absprec
844
+ return ans
845
+
846
+ def _cache_key(self):
847
+ r"""
848
+ Return a hashable key which identifies this element for caching.
849
+
850
+ TESTS::
851
+
852
+ sage: # needs sage.libs.flint
853
+ sage: R.<a> = ZqCA(9)
854
+ sage: (9*a)._cache_key()
855
+ (..., ((), (), (0, 1)), 20)
856
+
857
+ .. SEEALSO::
858
+
859
+ :meth:`sage.misc.cachefunc._cache_key`
860
+ """
861
+ def tuple_recursive(l):
862
+ return tuple(tuple_recursive(x) for x in l) if isinstance(l, Iterable) else l
863
+
864
+ return (self.parent(), tuple_recursive(trim_zeros(list(self.expansion()))), self.precision_absolute())
865
+
866
+ def _teichmuller_set_unsafe(self):
867
+ """
868
+ Set this element to the Teichmuller representative with the
869
+ same residue.
870
+
871
+ .. WARNING::
872
+
873
+ This function modifies the element, which is not safe.
874
+ Elements are supposed to be immutable.
875
+
876
+ EXAMPLES::
877
+
878
+ sage: R = ZpCA(17,5); a = R(11)
879
+ sage: a
880
+ 11 + O(17^5)
881
+ sage: a._teichmuller_set_unsafe(); a
882
+ 11 + 14*17 + 2*17^2 + 12*17^3 + 15*17^4 + O(17^5)
883
+ sage: E = a.expansion(lift_mode='teichmuller'); E
884
+ 17-adic expansion of 11 + 14*17 + 2*17^2 + 12*17^3 + 15*17^4 + O(17^5) (teichmuller)
885
+ sage: list(E)
886
+ [11 + 14*17 + 2*17^2 + 12*17^3 + 15*17^4 + O(17^5), O(17^5), O(17^5), O(17^5), O(17^5)]
887
+
888
+ Note that if you set an element which is congruent to 0 you
889
+ get 0 to maximum precision::
890
+
891
+ sage: b = R(17*5); b
892
+ 5*17 + O(17^5)
893
+ sage: b._teichmuller_set_unsafe(); b
894
+ O(17^5)
895
+ """
896
+ if self.valuation_c() > 0:
897
+ csetzero(self.value, self.prime_pow)
898
+ self.absprec = self.prime_pow.ram_prec_cap
899
+ elif self.absprec == 0:
900
+ raise ValueError("not enough precision")
901
+ else:
902
+ cteichmuller(self.value, self.value, self.absprec, self.prime_pow)
903
+
904
+ def _polynomial_list(self, pad=False):
905
+ """
906
+ Return the coefficient list for a polynomial over the base ring
907
+ yielding this element.
908
+
909
+ INPUT:
910
+
911
+ - ``pad`` -- whether to pad the result with zeros of the appropriate precision
912
+
913
+ EXAMPLES::
914
+
915
+ sage: # needs sage.libs.flint
916
+ sage: R.<x> = ZZ[]
917
+ sage: K.<a> = ZqCA(25)
918
+ sage: W.<w> = K.extension(x^3 - 5)
919
+ sage: (1 + w + O(w^11))._polynomial_list()
920
+ [1 + O(5^4), 1 + O(5^4)]
921
+ sage: (1 + w + O(w^11))._polynomial_list(pad=True)
922
+ [1 + O(5^4), 1 + O(5^4), O(5^3)]
923
+ sage: W(0)._polynomial_list()
924
+ []
925
+ sage: W(0)._polynomial_list(pad=True)
926
+ [O(5^20), O(5^20), O(5^20)]
927
+ sage: W(O(w^7))._polynomial_list()
928
+ []
929
+ sage: W(O(w^7))._polynomial_list(pad=True)
930
+ [O(5^3), O(5^2), O(5^2)]
931
+ """
932
+ R = self.base_ring()
933
+ prec = self.precision_absolute()
934
+ e = self.parent().relative_e()
935
+ L = ccoefficients(self.value, 0, self.absprec, self.prime_pow)
936
+ if pad:
937
+ n = self.parent().relative_degree()
938
+ L.extend([R.zero()] * (n - len(L)))
939
+ if e == 1:
940
+ return [R(c, prec) for c in L]
941
+ else:
942
+ return [R(c, (prec - i - 1) // e + 1) for i, c in enumerate(L)]
943
+
944
+ def polynomial(self, var='x'):
945
+ """
946
+ Return a polynomial over the base ring that yields this element
947
+ when evaluated at the generator of the parent.
948
+
949
+ INPUT:
950
+
951
+ - ``var`` -- string; the variable name for the polynomial
952
+
953
+ EXAMPLES::
954
+
955
+ sage: # needs sage.libs.flint
956
+ sage: R.<a> = ZqCA(5^3)
957
+ sage: a.polynomial()
958
+ (1 + O(5^20))*x + O(5^20)
959
+ sage: a.polynomial(var='y')
960
+ (1 + O(5^20))*y + O(5^20)
961
+ sage: (5*a^2 + R(25, 4)).polynomial()
962
+ (5 + O(5^4))*x^2 + O(5^4)*x + 5^2 + O(5^4)
963
+ """
964
+ R = self.base_ring()
965
+ S = R[var]
966
+ return S(self._polynomial_list())
967
+
968
+ def precision_absolute(self):
969
+ """
970
+ The absolute precision of this element.
971
+
972
+ This is the power of the maximal ideal modulo which this
973
+ element is defined.
974
+
975
+ EXAMPLES::
976
+
977
+ sage: R = Zp(7,4,'capped-abs'); a = R(7); a.precision_absolute()
978
+ 4
979
+ """
980
+ cdef Integer ans = Integer.__new__(Integer)
981
+ mpz_set_si(ans.value, self.absprec)
982
+ return ans
983
+
984
+ def precision_relative(self):
985
+ """
986
+ The relative precision of this element.
987
+
988
+ This is the power of the maximal ideal modulo which the unit
989
+ part of this element is defined.
990
+
991
+ EXAMPLES::
992
+
993
+ sage: R = Zp(7,4,'capped-abs'); a = R(7); a.precision_relative()
994
+ 3
995
+ """
996
+ cdef Integer ans = Integer.__new__(Integer)
997
+ mpz_set_si(ans.value, self.absprec - self.valuation_c())
998
+ return ans
999
+
1000
+ cpdef pAdicTemplateElement unit_part(CAElement self):
1001
+ r"""
1002
+ Return the unit part of this element.
1003
+
1004
+ EXAMPLES::
1005
+
1006
+ sage: R = Zp(17,4,'capped-abs', 'val-unit')
1007
+ sage: a = R(18*17)
1008
+ sage: a.unit_part()
1009
+ 18 + O(17^3)
1010
+ sage: type(a)
1011
+ <class 'sage.rings.padics.padic_capped_absolute_element.pAdicCappedAbsoluteElement'>
1012
+ sage: R(0).unit_part()
1013
+ O(17^0)
1014
+ """
1015
+ cdef CAElement ans = (<CAElement>self)._new_c()
1016
+ cdef long val = cremove(ans.value, (<CAElement>self).value, (<CAElement>self).absprec, (<CAElement>self).prime_pow, True)
1017
+ ans.absprec = (<CAElement>self).absprec - val
1018
+ return ans
1019
+
1020
+ cdef long valuation_c(self) noexcept:
1021
+ """
1022
+ Return the valuation of this element.
1023
+
1024
+ TESTS::
1025
+
1026
+ sage: R = ZpCA(5)
1027
+ sage: R(5^5*1827).valuation()
1028
+ 5
1029
+ sage: R(1).valuation()
1030
+ 0
1031
+ sage: R(2).valuation()
1032
+ 0
1033
+ sage: R(5).valuation()
1034
+ 1
1035
+ sage: R(10).valuation()
1036
+ 1
1037
+ sage: R(25).valuation()
1038
+ 2
1039
+ sage: R(50).valuation()
1040
+ 2
1041
+ sage: R(0).valuation()
1042
+ 20
1043
+ sage: R(0,6).valuation()
1044
+ 6
1045
+ """
1046
+ return cvaluation(self.value, self.absprec, self.prime_pow)
1047
+
1048
+ cpdef val_unit(self):
1049
+ r"""
1050
+ Return a 2-tuple, the first element set to the valuation of this
1051
+ element, and the second to the unit part of this element.
1052
+
1053
+ For a zero element, the unit part is ``O(p^0)``.
1054
+
1055
+ EXAMPLES::
1056
+
1057
+ sage: R = ZpCA(5)
1058
+ sage: a = R(75, 6); b = a - a
1059
+ sage: a.val_unit()
1060
+ (2, 3 + O(5^4))
1061
+ sage: b.val_unit()
1062
+ (6, O(5^0))
1063
+ """
1064
+ cdef CAElement unit = self._new_c()
1065
+ cdef Integer valuation = Integer.__new__(Integer)
1066
+ cdef long val = cremove(unit.value, self.value, self.absprec, self.prime_pow, True)
1067
+ mpz_set_si(valuation.value, val)
1068
+ unit.absprec = self.absprec - val
1069
+ return valuation, unit
1070
+
1071
+ def __hash__(self):
1072
+ """
1073
+ Hashing.
1074
+
1075
+ .. WARNING::
1076
+
1077
+ Hashing of `p`-adic elements will likely be deprecated soon. See :issue:`11895`.
1078
+
1079
+ EXAMPLES::
1080
+
1081
+ sage: R = ZpCA(11, 5)
1082
+ sage: hash(R(3)) == hash(3)
1083
+ True
1084
+ """
1085
+ return chash(self.value, 0, self.absprec, self.prime_pow)
1086
+
1087
+ cdef class pAdicCoercion_ZZ_CA(RingHomomorphism):
1088
+ """
1089
+ The canonical inclusion from the ring of integers to a capped absolute
1090
+ ring.
1091
+
1092
+ EXAMPLES::
1093
+
1094
+ sage: f = ZpCA(5).coerce_map_from(ZZ); f
1095
+ Ring morphism:
1096
+ From: Integer Ring
1097
+ To: 5-adic Ring with capped absolute precision 20
1098
+
1099
+ TESTS::
1100
+
1101
+ sage: TestSuite(f).run()
1102
+ """
1103
+ def __init__(self, R):
1104
+ """
1105
+ Initialization.
1106
+
1107
+ EXAMPLES::
1108
+
1109
+ sage: f = ZpCA(5).coerce_map_from(ZZ); type(f)
1110
+ <class 'sage.rings.padics.padic_capped_absolute_element.pAdicCoercion_ZZ_CA'>
1111
+ """
1112
+ RingHomomorphism.__init__(self, ZZ.Hom(R))
1113
+ self._zero = R.element_class(R, 0)
1114
+ self._section = pAdicConvert_CA_ZZ(R)
1115
+
1116
+ cdef dict _extra_slots(self):
1117
+ """
1118
+ Helper for copying and pickling.
1119
+
1120
+ EXAMPLES::
1121
+
1122
+ sage: f = ZpCA(5).coerce_map_from(ZZ)
1123
+ sage: g = copy(f) # indirect doctest
1124
+ sage: g == f
1125
+ True
1126
+ sage: g(6)
1127
+ 1 + 5 + O(5^20)
1128
+ sage: f(6) == g(6)
1129
+ True
1130
+ """
1131
+ _slots = RingHomomorphism._extra_slots(self)
1132
+ _slots['_zero'] = self._zero
1133
+ _slots['_section'] = self.section() # use method since it copies coercion-internal sections.
1134
+ return _slots
1135
+
1136
+ cdef _update_slots(self, dict _slots):
1137
+ """
1138
+ Helper for copying and pickling.
1139
+
1140
+ EXAMPLES::
1141
+
1142
+ sage: f = ZpCA(5).coerce_map_from(ZZ)
1143
+ sage: g = copy(f) # indirect doctest
1144
+ sage: g == f
1145
+ True
1146
+ sage: g(6)
1147
+ 1 + 5 + O(5^20)
1148
+ sage: f(6) == g(6)
1149
+ True
1150
+ """
1151
+ self._zero = _slots['_zero']
1152
+ self._section = _slots['_section']
1153
+ RingHomomorphism._update_slots(self, _slots)
1154
+
1155
+ cpdef Element _call_(self, x):
1156
+ """
1157
+ Evaluation.
1158
+
1159
+ EXAMPLES::
1160
+
1161
+ sage: f = ZpCA(5).coerce_map_from(ZZ)
1162
+ sage: f(0).parent()
1163
+ 5-adic Ring with capped absolute precision 20
1164
+ sage: f(5)
1165
+ 5 + O(5^20)
1166
+ """
1167
+ if mpz_sgn((<Integer>x).value) == 0:
1168
+ return self._zero
1169
+ cdef CAElement ans = self._zero._new_c()
1170
+ ans.absprec = ans.prime_pow.ram_prec_cap
1171
+ cconv_mpz_t(ans.value, (<Integer>x).value, ans.absprec, True, ans.prime_pow)
1172
+ return ans
1173
+
1174
+ cpdef Element _call_with_args(self, x, args=(), kwds={}):
1175
+ """
1176
+ This function is used when some precision cap is passed in
1177
+ (relative or absolute or both).
1178
+
1179
+ See the documentation for
1180
+ :meth:`pAdicCappedAbsoluteElement.__init__` for more details.
1181
+
1182
+ EXAMPLES::
1183
+
1184
+ sage: R = ZpCA(5,4)
1185
+ sage: type(R(10,2))
1186
+ <class 'sage.rings.padics.padic_capped_absolute_element.pAdicCappedAbsoluteElement'>
1187
+ sage: R(10,2) # indirect doctest
1188
+ 2*5 + O(5^2)
1189
+ sage: R(10,3,1)
1190
+ 2*5 + O(5^2)
1191
+ sage: R(10,absprec=2)
1192
+ 2*5 + O(5^2)
1193
+ sage: R(10,relprec=2)
1194
+ 2*5 + O(5^3)
1195
+ sage: R(10,absprec=1)
1196
+ O(5)
1197
+ sage: R(10,empty=True)
1198
+ O(5^0)
1199
+ """
1200
+ cdef long val, aprec, rprec
1201
+ cdef CAElement ans
1202
+ _process_args_and_kwds(&aprec, &rprec, args, kwds, True, self._zero.prime_pow)
1203
+ if mpz_sgn((<Integer>x).value) == 0:
1204
+ if aprec >= self._zero.prime_pow.ram_prec_cap:
1205
+ return self._zero
1206
+ ans = self._zero._new_c()
1207
+ csetzero(ans.value, ans.prime_pow)
1208
+ ans.absprec = aprec
1209
+ else:
1210
+ val = get_ordp(x, self._zero.prime_pow)
1211
+ ans = self._zero._new_c()
1212
+ if aprec <= val:
1213
+ csetzero(ans.value, ans.prime_pow)
1214
+ ans.absprec = aprec
1215
+ else:
1216
+ ans.absprec = min(aprec, val + rprec)
1217
+ cconv_mpz_t(ans.value, (<Integer>x).value, ans.absprec, True, self._zero.prime_pow)
1218
+ return ans
1219
+
1220
+ def section(self):
1221
+ """
1222
+ Return a map back to the ring of integers that approximates an element
1223
+ by an integer.
1224
+
1225
+ EXAMPLES::
1226
+
1227
+ sage: f = ZpCA(5).coerce_map_from(ZZ).section()
1228
+ sage: f(ZpCA(5)(-1)) - 5^20
1229
+ -1
1230
+ """
1231
+ from sage.misc.constant_function import ConstantFunction
1232
+ if not isinstance(self._section.domain, ConstantFunction):
1233
+ import copy
1234
+ self._section = copy.copy(self._section)
1235
+ return self._section
1236
+
1237
+ cdef class pAdicConvert_CA_ZZ(RingMap):
1238
+ """
1239
+ The map from a capped absolute ring back to the ring of integers that
1240
+ returns the smallest nonnegative integer approximation to its input
1241
+ which is accurate up to the precision.
1242
+
1243
+ Raises a :exc:`ValueError` if the input is not in the closure of the image
1244
+ of the ring of integers.
1245
+
1246
+ EXAMPLES::
1247
+
1248
+ sage: f = ZpCA(5).coerce_map_from(ZZ).section(); f
1249
+ Set-theoretic ring morphism:
1250
+ From: 5-adic Ring with capped absolute precision 20
1251
+ To: Integer Ring
1252
+ """
1253
+ def __init__(self, R):
1254
+ """
1255
+ Initialization.
1256
+
1257
+ EXAMPLES::
1258
+
1259
+ sage: f = ZpCA(5).coerce_map_from(ZZ).section(); type(f)
1260
+ <class 'sage.rings.padics.padic_capped_absolute_element.pAdicConvert_CA_ZZ'>
1261
+ sage: f.category()
1262
+ Category of homsets of sets
1263
+ """
1264
+ if R.absolute_degree() > 1 or R.characteristic() != 0 or R.residue_characteristic() == 0:
1265
+ RingMap.__init__(self, Hom(R, ZZ, SetsWithPartialMaps()))
1266
+ else:
1267
+ RingMap.__init__(self, Hom(R, ZZ, Sets()))
1268
+
1269
+ cpdef Element _call_(self, _x):
1270
+ """
1271
+ Evaluation.
1272
+
1273
+ EXAMPLES::
1274
+
1275
+ sage: f = ZpCA(5).coerce_map_from(ZZ).section()
1276
+ sage: f(ZpCA(5)(-1)) - 5^20
1277
+ -1
1278
+ sage: f(ZpCA(5)(0))
1279
+ 0
1280
+ """
1281
+ cdef Integer ans = Integer.__new__(Integer)
1282
+ cdef CAElement x = _x
1283
+ cconv_mpz_t_out(ans.value, x.value, 0, x.absprec, x.prime_pow)
1284
+ return ans
1285
+
1286
+ cdef class pAdicConvert_QQ_CA(Morphism):
1287
+ """
1288
+ The inclusion map from the rationals to a capped absolute ring that is
1289
+ defined on all elements with nonnegative `p`-adic valuation.
1290
+
1291
+ EXAMPLES::
1292
+
1293
+ sage: f = ZpCA(5).convert_map_from(QQ); f
1294
+ Generic morphism:
1295
+ From: Rational Field
1296
+ To: 5-adic Ring with capped absolute precision 20
1297
+ """
1298
+ def __init__(self, R):
1299
+ """
1300
+ Initialization.
1301
+
1302
+ EXAMPLES::
1303
+
1304
+ sage: f = ZpCA(5).convert_map_from(QQ); type(f)
1305
+ <class 'sage.rings.padics.padic_capped_absolute_element.pAdicConvert_QQ_CA'>
1306
+ """
1307
+ Morphism.__init__(self, Hom(QQ, R, SetsWithPartialMaps()))
1308
+ self._zero = R.element_class(R, 0)
1309
+
1310
+ cdef dict _extra_slots(self):
1311
+ """
1312
+ Helper for copying and pickling.
1313
+
1314
+ EXAMPLES::
1315
+
1316
+ sage: f = ZpCA(5).convert_map_from(QQ)
1317
+ sage: g = copy(f) # indirect doctest
1318
+ sage: g == f # todo: comparison not implemented
1319
+ True
1320
+ sage: g(1/6)
1321
+ 1 + 4*5 + 4*5^3 + 4*5^5 + 4*5^7 + 4*5^9 + 4*5^11 + 4*5^13 + 4*5^15 + 4*5^17 + 4*5^19 + O(5^20)
1322
+ sage: g(1/6) == f(1/6)
1323
+ True
1324
+ """
1325
+ _slots = Morphism._extra_slots(self)
1326
+ _slots['_zero'] = self._zero
1327
+ return _slots
1328
+
1329
+ cdef _update_slots(self, dict _slots):
1330
+ """
1331
+ Helper for copying and pickling.
1332
+
1333
+ EXAMPLES::
1334
+
1335
+ sage: f = ZpCA(5).convert_map_from(QQ)
1336
+ sage: g = copy(f) # indirect doctest
1337
+ sage: g == f # todo: comparison not implemented
1338
+ True
1339
+ sage: g(1/6)
1340
+ 1 + 4*5 + 4*5^3 + 4*5^5 + 4*5^7 + 4*5^9 + 4*5^11 + 4*5^13 + 4*5^15 + 4*5^17 + 4*5^19 + O(5^20)
1341
+ sage: g(1/6) == f(1/6)
1342
+ True
1343
+ """
1344
+ self._zero = _slots['_zero']
1345
+ Morphism._update_slots(self, _slots)
1346
+
1347
+ cpdef Element _call_(self, x):
1348
+ """
1349
+ Evaluation.
1350
+
1351
+ EXAMPLES::
1352
+
1353
+ sage: f = ZpCA(5,4).convert_map_from(QQ)
1354
+ sage: f(1/7)
1355
+ 3 + 3*5 + 2*5^3 + O(5^4)
1356
+ sage: f(0)
1357
+ O(5^4)
1358
+ """
1359
+ if mpq_sgn((<Rational>x).value) == 0:
1360
+ return self._zero
1361
+ cdef CAElement ans = self._zero._new_c()
1362
+ cconv_mpq_t(ans.value, (<Rational>x).value, ans.prime_pow.ram_prec_cap, True, ans.prime_pow)
1363
+ ans.absprec = ans.prime_pow.ram_prec_cap
1364
+ return ans
1365
+
1366
+ cpdef Element _call_with_args(self, x, args=(), kwds={}):
1367
+ """
1368
+ This function is used when some precision cap is passed in (relative or absolute or both).
1369
+
1370
+ See the documentation for :meth:`pAdicCappedAbsoluteElement.__init__` for more details.
1371
+
1372
+ EXAMPLES::
1373
+
1374
+ sage: R = ZpCA(5,4)
1375
+ sage: type(R(10/3,2))
1376
+ <class 'sage.rings.padics.padic_capped_absolute_element.pAdicCappedAbsoluteElement'>
1377
+ sage: R(10/3,2) # indirect doctest
1378
+ 4*5 + O(5^2)
1379
+ sage: R(10/3,3,1)
1380
+ 4*5 + O(5^2)
1381
+ sage: R(10/3,absprec=2)
1382
+ 4*5 + O(5^2)
1383
+ sage: R(10/3,relprec=2)
1384
+ 4*5 + 5^2 + O(5^3)
1385
+ sage: R(10/3,absprec=1)
1386
+ O(5)
1387
+ sage: R(10/3,empty=True)
1388
+ O(5^0)
1389
+ sage: R(3/100,relprec=3)
1390
+ Traceback (most recent call last):
1391
+ ...
1392
+ ValueError: p divides denominator
1393
+ """
1394
+ cdef long val, aprec, rprec
1395
+ cdef CAElement ans
1396
+ _process_args_and_kwds(&aprec, &rprec, args, kwds, True, self._zero.prime_pow)
1397
+ if mpq_sgn((<Rational>x).value) == 0:
1398
+ if aprec >= self._zero.prime_pow.ram_prec_cap:
1399
+ return self._zero
1400
+ ans = self._zero._new_c()
1401
+ csetzero(ans.value, ans.prime_pow)
1402
+ ans.absprec = aprec
1403
+ else:
1404
+ val = get_ordp(x, self._zero.prime_pow)
1405
+ ans = self._zero._new_c()
1406
+ if aprec <= val:
1407
+ csetzero(ans.value, ans.prime_pow)
1408
+ ans.absprec = aprec
1409
+ else:
1410
+ ans.absprec = min(aprec, val + rprec)
1411
+ cconv_mpq_t(ans.value, (<Rational>x).value, ans.absprec, True, self._zero.prime_pow)
1412
+ return ans
1413
+
1414
+ cdef class pAdicCoercion_CA_frac_field(RingHomomorphism):
1415
+ """
1416
+ The canonical inclusion of Zq into its fraction field.
1417
+
1418
+ EXAMPLES::
1419
+
1420
+ sage: # needs sage.libs.flint
1421
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1422
+ sage: K = R.fraction_field()
1423
+ sage: f = K.coerce_map_from(R); f
1424
+ Ring morphism:
1425
+ From: 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1
1426
+ To: 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1
1427
+
1428
+ TESTS::
1429
+
1430
+ sage: TestSuite(f).run() # needs sage.libs.flint
1431
+ """
1432
+ def __init__(self, R, K):
1433
+ """
1434
+ Initialization.
1435
+
1436
+ EXAMPLES::
1437
+
1438
+ sage: # needs sage.libs.flint
1439
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1440
+ sage: K = R.fraction_field()
1441
+ sage: f = K.coerce_map_from(R); type(f)
1442
+ <class 'sage.rings.padics.qadic_flint_CA.pAdicCoercion_CA_frac_field'>
1443
+ """
1444
+ RingHomomorphism.__init__(self, R.Hom(K))
1445
+ self._zero = K(0)
1446
+ self._section = pAdicConvert_CA_frac_field(K, R)
1447
+
1448
+ cpdef Element _call_(self, _x):
1449
+ """
1450
+ Evaluation.
1451
+
1452
+ EXAMPLES::
1453
+
1454
+ sage: # needs sage.libs.flint
1455
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1456
+ sage: K = R.fraction_field()
1457
+ sage: f = K.coerce_map_from(R)
1458
+ sage: f(a)
1459
+ a + O(3^20)
1460
+ """
1461
+ cdef CAElement x = _x
1462
+ cdef CRElement ans = self._zero._new_c()
1463
+ ans.ordp = 0
1464
+ ans.relprec = x.absprec
1465
+ ccopy(ans.unit, x.value, x.prime_pow)
1466
+ IF CELEMENT_IS_PY_OBJECT:
1467
+ # The base ring is wrong, so we fix it.
1468
+ K = ans.unit.base_ring()
1469
+ ans.unit._coeffs = [K(c) for c in ans.unit._coeffs]
1470
+ ans._normalize()
1471
+ return ans
1472
+
1473
+ cpdef Element _call_with_args(self, _x, args=(), kwds={}):
1474
+ """
1475
+ This function is used when some precision cap is passed in
1476
+ (relative or absolute or both).
1477
+
1478
+ See the documentation for
1479
+ :meth:`pAdicCappedAbsoluteElement.__init__` for more details.
1480
+
1481
+ EXAMPLES::
1482
+
1483
+ sage: # needs sage.libs.flint
1484
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1485
+ sage: K = R.fraction_field()
1486
+ sage: f = K.coerce_map_from(R)
1487
+ sage: f(a, 3) # indirect doctest
1488
+ a + O(3^3)
1489
+ sage: b = 9*a
1490
+ sage: f(b, 3)
1491
+ a*3^2 + O(3^3)
1492
+ sage: f(b, 4, 1)
1493
+ a*3^2 + O(3^3)
1494
+ sage: f(b, 4, 3)
1495
+ a*3^2 + O(3^4)
1496
+ sage: f(b, absprec=4)
1497
+ a*3^2 + O(3^4)
1498
+ sage: f(b, relprec=3)
1499
+ a*3^2 + O(3^5)
1500
+ sage: f(b, absprec=1)
1501
+ O(3)
1502
+ sage: f(R(0))
1503
+ O(3^20)
1504
+ """
1505
+ cdef long aprec, rprec
1506
+ cdef CAElement x = _x
1507
+ cdef CRElement ans = self._zero._new_c()
1508
+ _process_args_and_kwds(&aprec, &rprec, args, kwds, False, ans.prime_pow)
1509
+ if x.absprec < aprec:
1510
+ aprec = x.absprec
1511
+ ans.ordp = cremove(ans.unit, x.value, aprec, x.prime_pow, True)
1512
+ ans.relprec = aprec - ans.ordp
1513
+ if rprec < ans.relprec:
1514
+ ans.relprec = rprec
1515
+ if ans.relprec < 0:
1516
+ ans.relprec = 0
1517
+ ans.ordp = aprec
1518
+ csetzero(ans.unit, x.prime_pow)
1519
+ else:
1520
+ IF CELEMENT_IS_PY_OBJECT:
1521
+ # The base ring is wrong, so we fix it.
1522
+ K = ans.unit.base_ring()
1523
+ ans.unit._coeffs = [K(c) for c in ans.unit._coeffs]
1524
+ pass
1525
+ return ans
1526
+
1527
+ def section(self):
1528
+ """
1529
+ Return a map back to the ring that converts elements of
1530
+ nonnegative valuation.
1531
+
1532
+ EXAMPLES::
1533
+
1534
+ sage: # needs sage.libs.flint
1535
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1536
+ sage: K = R.fraction_field()
1537
+ sage: f = K.coerce_map_from(R)
1538
+ sage: f(K.gen())
1539
+ a + O(3^20)
1540
+ sage: f.section()
1541
+ Generic morphism:
1542
+ From: 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1
1543
+ To: 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1
1544
+ """
1545
+ from sage.misc.constant_function import ConstantFunction
1546
+ if not isinstance(self._section.domain, ConstantFunction):
1547
+ import copy
1548
+ self._section = copy.copy(self._section)
1549
+ return self._section
1550
+
1551
+ cdef dict _extra_slots(self):
1552
+ """
1553
+ Helper for copying and pickling.
1554
+
1555
+ TESTS::
1556
+
1557
+ sage: # needs sage.libs.flint
1558
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1559
+ sage: K = R.fraction_field()
1560
+ sage: f = K.coerce_map_from(R)
1561
+ sage: g = copy(f) # indirect doctest
1562
+ sage: g
1563
+ Ring morphism:
1564
+ From: 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1
1565
+ To: 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1
1566
+ sage: g == f
1567
+ True
1568
+ sage: g is f
1569
+ False
1570
+ sage: g(a)
1571
+ a + O(3^20)
1572
+ sage: g(a) == f(a)
1573
+ True
1574
+ """
1575
+ _slots = RingHomomorphism._extra_slots(self)
1576
+ _slots['_zero'] = self._zero
1577
+ _slots['_section'] = self.section() # use method since it copies coercion-internal sections.
1578
+ return _slots
1579
+
1580
+ cdef _update_slots(self, dict _slots):
1581
+ """
1582
+ Helper for copying and pickling.
1583
+
1584
+ TESTS::
1585
+
1586
+ sage: # needs sage.libs.flint
1587
+ sage: R.<a> = ZqCA(9, implementation='FLINT')
1588
+ sage: K = R.fraction_field()
1589
+ sage: f = K.coerce_map_from(R)
1590
+ sage: g = copy(f) # indirect doctest
1591
+ sage: g
1592
+ Ring morphism:
1593
+ From: 3-adic Unramified Extension Ring in a defined by x^2 + 2*x + 2
1594
+ To: 3-adic Unramified Extension Field in a defined by x^2 + 2*x + 2
1595
+ sage: g == f
1596
+ True
1597
+ sage: g is f
1598
+ False
1599
+ sage: g(a)
1600
+ a + O(3^20)
1601
+ sage: g(a) == f(a)
1602
+ True
1603
+ """
1604
+ self._zero = _slots['_zero']
1605
+ self._section = _slots['_section']
1606
+ RingHomomorphism._update_slots(self, _slots)
1607
+
1608
+ def is_injective(self):
1609
+ r"""
1610
+ Return whether this map is injective.
1611
+
1612
+ EXAMPLES::
1613
+
1614
+ sage: # needs sage.libs.flint
1615
+ sage: R.<a> = ZqCA(9, implementation='FLINT')
1616
+ sage: K = R.fraction_field()
1617
+ sage: f = K.coerce_map_from(R)
1618
+ sage: f.is_injective()
1619
+ True
1620
+ """
1621
+ return True
1622
+
1623
+ def is_surjective(self):
1624
+ r"""
1625
+ Return whether this map is surjective.
1626
+
1627
+ EXAMPLES::
1628
+
1629
+ sage: # needs sage.libs.flint
1630
+ sage: R.<a> = ZqCA(9, implementation='FLINT')
1631
+ sage: K = R.fraction_field()
1632
+ sage: f = K.coerce_map_from(R)
1633
+ sage: f.is_surjective()
1634
+ False
1635
+ """
1636
+ return False
1637
+
1638
+
1639
+ cdef class pAdicConvert_CA_frac_field(Morphism):
1640
+ r"""
1641
+ The section of the inclusion from `\ZZ_q` to its fraction field.
1642
+
1643
+ EXAMPLES::
1644
+
1645
+ sage: # needs sage.libs.flint
1646
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1647
+ sage: K = R.fraction_field()
1648
+ sage: f = R.convert_map_from(K); f
1649
+ Generic morphism:
1650
+ From: 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1
1651
+ To: 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1
1652
+ """
1653
+ def __init__(self, K, R):
1654
+ """
1655
+ Initialization.
1656
+
1657
+ EXAMPLES::
1658
+
1659
+ sage: # needs sage.libs.flint
1660
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1661
+ sage: K = R.fraction_field()
1662
+ sage: f = R.convert_map_from(K); type(f)
1663
+ <class 'sage.rings.padics.qadic_flint_CA.pAdicConvert_CA_frac_field'>
1664
+ """
1665
+ Morphism.__init__(self, Hom(K, R, SetsWithPartialMaps()))
1666
+ self._zero = R(0)
1667
+
1668
+ cpdef Element _call_(self, _x):
1669
+ """
1670
+ Evaluation.
1671
+
1672
+ EXAMPLES::
1673
+
1674
+ sage: # needs sage.libs.flint
1675
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1676
+ sage: K = R.fraction_field()
1677
+ sage: f = R.convert_map_from(K)
1678
+ sage: f(K.gen()) # indirect doctest
1679
+ a + O(3^20)
1680
+ """
1681
+ cdef CRElement x = _x
1682
+ if x.ordp < 0:
1683
+ raise ValueError("negative valuation")
1684
+ cdef CAElement ans = self._zero._new_c()
1685
+ cdef bint reduce = (x.prime_pow.e > 1)
1686
+ ans.absprec = x.relprec + x.ordp
1687
+ if ans.absprec > ans.prime_pow.ram_prec_cap:
1688
+ ans.absprec = ans.prime_pow.ram_prec_cap
1689
+ reduce = True
1690
+ if x.ordp >= ans.absprec:
1691
+ csetzero(ans.value, ans.prime_pow)
1692
+ else:
1693
+ cshift_notrunc(ans.value, x.unit, x.ordp, ans.absprec, ans.prime_pow, reduce)
1694
+ IF CELEMENT_IS_PY_OBJECT:
1695
+ # The base ring is wrong, so we fix it.
1696
+ R = ans.value.base_ring()
1697
+ ans.value._coeffs = [R(c) for c in ans.value._coeffs]
1698
+ return ans
1699
+
1700
+ cpdef Element _call_with_args(self, _x, args=(), kwds={}):
1701
+ """
1702
+ This function is used when some precision cap is passed in
1703
+ (relative or absolute or both).
1704
+
1705
+ See the documentation for
1706
+ :meth:`pAdicCappedAbsoluteElement.__init__` for more details.
1707
+
1708
+ EXAMPLES::
1709
+
1710
+ sage: # needs sage.libs.flint
1711
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1712
+ sage: K = R.fraction_field()
1713
+ sage: f = R.convert_map_from(K); a = K(a)
1714
+ sage: f(a, 3) # indirect doctest
1715
+ a + O(3^3)
1716
+ sage: b = 9*a
1717
+ sage: f(b, 3)
1718
+ a*3^2 + O(3^3)
1719
+ sage: f(b, 4, 1)
1720
+ a*3^2 + O(3^3)
1721
+ sage: f(b, 4, 3)
1722
+ a*3^2 + O(3^4)
1723
+ sage: f(b, absprec=4)
1724
+ a*3^2 + O(3^4)
1725
+ sage: f(b, relprec=3)
1726
+ a*3^2 + O(3^5)
1727
+ sage: f(b, absprec=1)
1728
+ O(3)
1729
+ sage: f(K(0))
1730
+ O(3^20)
1731
+ """
1732
+ cdef long aprec, rprec
1733
+ cdef CRElement x = _x
1734
+ if x.ordp < 0:
1735
+ raise ValueError("negative valuation")
1736
+ cdef CAElement ans = self._zero._new_c()
1737
+ cdef bint reduce = False
1738
+ _process_args_and_kwds(&aprec, &rprec, args, kwds, True, ans.prime_pow)
1739
+ if x.relprec < rprec:
1740
+ rprec = x.relprec
1741
+ reduce = True
1742
+ ans.absprec = rprec + x.ordp
1743
+ if aprec < ans.absprec:
1744
+ ans.absprec = aprec
1745
+ reduce = True
1746
+ if x.ordp >= ans.absprec:
1747
+ csetzero(ans.value, ans.prime_pow)
1748
+ else:
1749
+ cshift_notrunc(ans.value, x.unit, x.ordp, ans.absprec, ans.prime_pow, reduce)
1750
+ IF CELEMENT_IS_PY_OBJECT:
1751
+ # The base ring is wrong, so we fix it.
1752
+ R = ans.value.base_ring()
1753
+ ans.value._coeffs = [R(c) for c in ans.value._coeffs]
1754
+ return ans
1755
+
1756
+ cdef dict _extra_slots(self):
1757
+ """
1758
+ Helper for copying and pickling.
1759
+
1760
+ TESTS::
1761
+
1762
+ sage: # needs sage.libs.flint
1763
+ sage: R.<a> = ZqCA(27, implementation='FLINT')
1764
+ sage: K = R.fraction_field()
1765
+ sage: f = R.convert_map_from(K)
1766
+ sage: a = K(a)
1767
+ sage: g = copy(f) # indirect doctest
1768
+ sage: g
1769
+ Generic morphism:
1770
+ From: 3-adic Unramified Extension Field in a defined by x^3 + 2*x + 1
1771
+ To: 3-adic Unramified Extension Ring in a defined by x^3 + 2*x + 1
1772
+ sage: g == f
1773
+ True
1774
+ sage: g is f
1775
+ False
1776
+ sage: g(a)
1777
+ a + O(3^20)
1778
+ sage: g(a) == f(a)
1779
+ True
1780
+ """
1781
+ _slots = Morphism._extra_slots(self)
1782
+ _slots['_zero'] = self._zero
1783
+ return _slots
1784
+
1785
+ cdef _update_slots(self, dict _slots):
1786
+ """
1787
+ Helper for copying and pickling.
1788
+
1789
+ TESTS::
1790
+
1791
+ sage: # needs sage.libs.flint
1792
+ sage: R.<a> = ZqCA(9, implementation='FLINT')
1793
+ sage: K = R.fraction_field()
1794
+ sage: f = R.convert_map_from(K)
1795
+ sage: a = f(a)
1796
+ sage: g = copy(f) # indirect doctest
1797
+ sage: g
1798
+ Generic morphism:
1799
+ From: 3-adic Unramified Extension Field in a defined by x^2 + 2*x + 2
1800
+ To: 3-adic Unramified Extension Ring in a defined by x^2 + 2*x + 2
1801
+ sage: g == f
1802
+ True
1803
+ sage: g is f
1804
+ False
1805
+ sage: g(a)
1806
+ a + O(3^20)
1807
+ sage: g(a) == f(a)
1808
+ True
1809
+ """
1810
+ self._zero = _slots['_zero']
1811
+ Morphism._update_slots(self, _slots)
1812
+
1813
+
1814
+ def unpickle_cae_v2(cls, parent, value, absprec):
1815
+ r"""
1816
+ Unpickle capped absolute elements.
1817
+
1818
+ INPUT:
1819
+
1820
+ - ``cls`` -- the class of the capped absolute element
1821
+
1822
+ - ``parent`` -- a `p`-adic ring
1823
+
1824
+ - ``value`` -- a Python object wrapping a celement, of the kind
1825
+ accepted by the cunpickle function
1826
+
1827
+ - ``absprec`` -- a Python int or Sage integer
1828
+
1829
+ EXAMPLES::
1830
+
1831
+ sage: from sage.rings.padics.padic_capped_absolute_element import unpickle_cae_v2, pAdicCappedAbsoluteElement
1832
+ sage: R = ZpCA(5,8)
1833
+ sage: a = unpickle_cae_v2(pAdicCappedAbsoluteElement, R, 42, int(6)); a
1834
+ 2 + 3*5 + 5^2 + O(5^6)
1835
+ sage: a.parent() is R
1836
+ True
1837
+ """
1838
+ cdef CAElement ans = cls.__new__(cls)
1839
+ ans._parent = parent
1840
+ ans.prime_pow = <PowComputer_?>parent.prime_pow
1841
+ IF CELEMENT_IS_PY_OBJECT:
1842
+ polyt = type(ans.prime_pow.modulus)
1843
+ ans.value = <celement>polyt.__new__(polyt)
1844
+ cconstruct(ans.value, ans.prime_pow)
1845
+ cunpickle(ans.value, value, ans.prime_pow)
1846
+ ans.absprec = absprec
1847
+ return ans