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
sage/interfaces/gp.py ADDED
@@ -0,0 +1,1114 @@
1
+ # sage_setup: distribution = sagemath-pari
2
+ # sage.doctest: needs sage.libs.pari
3
+ r"""
4
+ Interface to the GP calculator of PARI/GP
5
+
6
+ Type ``gp.[tab]`` for a list of all the functions
7
+ available from your Gp install. Type ``gp.[tab]?`` for
8
+ Gp's help about a given function. Type ``gp(...)`` to
9
+ create a new Gp object, and ``gp.eval(...)`` to evaluate a
10
+ string using Gp (and get the result back as a string).
11
+
12
+ EXAMPLES: We illustrate objects that wrap GP objects (gp is the
13
+ PARI interpreter)::
14
+
15
+ sage: M = gp('[1,2;3,4]')
16
+ sage: M
17
+ [1, 2; 3, 4]
18
+ sage: M * M
19
+ [7, 10; 15, 22]
20
+ sage: M + M
21
+ [2, 4; 6, 8]
22
+ sage: M.matdet()
23
+ -2
24
+
25
+ ::
26
+
27
+ sage: E = gp.ellinit([1,2,3,4,5])
28
+ sage: E.ellglobalred()
29
+ [10351, [1, -1, 0, -1], 1, [11, 1; 941, 1], [[1, 5, 0, 1], [1, 5, 0, 1]]]
30
+ sage: E.ellan(20)
31
+ [1, 1, 0, -1, -3, 0, -1, -3, -3, -3, -1, 0, 1, -1, 0, -1, 5, -3, 4, 3]
32
+
33
+ ::
34
+
35
+ sage: primitive_root(7)
36
+ 3
37
+ sage: x = gp("znlog( Mod(2,7), Mod(3,7))")
38
+ sage: 3^x % 7
39
+ 2
40
+
41
+ ::
42
+
43
+ sage: print(gp("taylor(sin(x),x)"))
44
+ x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 - 1/39916800*x^11 + 1/6227020800*x^13 - 1/1307674368000*x^15 + O(x^16)
45
+
46
+ GP has a powerful very efficient algorithm for numerical
47
+ computation of integrals.
48
+
49
+ ::
50
+
51
+ sage: gp("a = intnum(x=0,6,sin(x))")
52
+ 0.039829713349633979454347702077075594548
53
+ sage: gp("a")
54
+ 0.039829713349633979454347702077075594548
55
+ sage: gp.kill("a")
56
+ sage: gp("a")
57
+ a
58
+
59
+ Note that gp ASCII plots *do* work in Sage, as follows::
60
+
61
+ sage: print(gp.eval("plot(x=0,6,sin(x))"))
62
+ <BLANKLINE>
63
+ 0.9988963 |''''''''''''_x...x_''''''''''''''''''''''''''''''''''''''''''|
64
+ | x" "x |
65
+ | _" "_ |
66
+ | x x |
67
+ | " " |
68
+ | " " |
69
+ | _" "_ |
70
+ | _ _ |
71
+ | _ _ |
72
+ |_ _ |
73
+ _ |
74
+ `````````````````````````````````"``````````````````````````````
75
+ | " |
76
+ | " |
77
+ | " "
78
+ | "_ _"|
79
+ | _ _ |
80
+ | _ _ |
81
+ | x x |
82
+ | "_ _" |
83
+ | x_ _x |
84
+ -0.998955 |............................................."x____x".........|
85
+ 0 6
86
+
87
+ The GP interface reads in even very long input (using files) in a
88
+ robust manner, as long as you are creating a new object.
89
+
90
+ ::
91
+
92
+ sage: t = '"%s"'%10^10000 # ten thousand character string.
93
+ sage: a = gp.eval(t)
94
+ sage: a = gp(t)
95
+
96
+ In Sage, the PARI large Galois groups datafiles should be installed
97
+ by default::
98
+
99
+ sage: f = gp('x^9 - x - 2')
100
+ sage: f.polgalois() # needs pari_galdata
101
+ [362880, -1, 34, "S9"]
102
+
103
+ TESTS:
104
+
105
+ Test error recovery::
106
+
107
+ sage: x = gp('1/0')
108
+ Traceback (most recent call last):
109
+ ...
110
+ TypeError: Error executing code in GP:
111
+ CODE:
112
+ sage[...]=1/0;
113
+ PARI/GP ERROR:
114
+ *** at top-level: sage[...]=1/0
115
+ *** ^--
116
+ *** _/_: impossible inverse in gdiv: 0.
117
+
118
+ AUTHORS:
119
+
120
+ - William Stein
121
+
122
+ - David Joyner: some examples
123
+
124
+ - William Stein (2006-03-01): added tab completion for methods:
125
+ gp.[tab] and x = gp(blah); x.[tab]
126
+
127
+ - William Stein (2006-03-01): updated to work with PARI 2.2.12-beta
128
+
129
+ - William Stein (2006-05-17): updated to work with PARI 2.2.13-beta
130
+ """
131
+
132
+ ##########################################################################
133
+ #
134
+ # Copyright (C) 2005 William Stein <wstein@gmail.com>
135
+ #
136
+ # Distributed under the terms of the GNU General Public License (GPL)
137
+ #
138
+ # https://www.gnu.org/licenses/
139
+ #
140
+ ##########################################################################
141
+ import os
142
+ import shlex
143
+
144
+ import sage.interfaces.abc
145
+
146
+ from sage.env import DOT_SAGE
147
+ from sage.features.pari import Gp as gp_executable
148
+ from sage.interfaces.tab_completion import ExtraTabCompletion
149
+ from sage.libs.pari import pari
150
+ from sage.misc.instancedoc import instancedoc
151
+ from sage.misc.lazy_import import lazy_import
152
+ from sage.misc.verbose import verbose
153
+
154
+ lazy_import('sage.rings.cc', 'CC')
155
+
156
+ from .expect import Expect, ExpectElement, ExpectFunction, FunctionElement
157
+
158
+
159
+ class Gp(ExtraTabCompletion, Expect):
160
+ """
161
+ Interface to the PARI gp interpreter.
162
+
163
+ Type ``gp.[tab]`` for a list of all the functions
164
+ available from your Gp install. Type ``gp.[tab]?`` for
165
+ Gp's help about a given function. Type ``gp(...)`` to
166
+ create a new Gp object, and ``gp.eval(...)`` to evaluate a
167
+ string using Gp (and get the result back as a string).
168
+
169
+ INPUT:
170
+
171
+ - ``stacksize`` -- integer (default: 10000000); the initial PARI
172
+ stacksize in bytes (default: 10MB)
173
+ - ``script_subdirectory`` -- string (default: ``None``); name of the
174
+ subdirectory of ``SAGE_EXTCODE/pari`` from which to read scripts
175
+ - ``logfile`` -- string (default: ``None``); log file for the pexpect
176
+ interface
177
+ - ``server`` -- name of remote server
178
+ - ``server_tmpdir`` -- name of temporary directory on remote server
179
+ - ``init_list_length`` -- integer (default: 1024); length of initial
180
+ list of local variables
181
+ - ``seed`` -- integer (default: random); random number generator seed
182
+ for pari
183
+
184
+ EXAMPLES::
185
+
186
+ sage: Gp()
187
+ PARI/GP interpreter
188
+ """
189
+ def __init__(self, stacksize=10000000, # 10MB
190
+ maxread=None, script_subdirectory=None,
191
+ logfile=None,
192
+ server=None,
193
+ server_tmpdir=None,
194
+ init_list_length=1024,
195
+ seed=None):
196
+ """
197
+ Initialization of this PARI gp interpreter.
198
+
199
+ INPUT:
200
+
201
+ - ``stacksize`` -- integer (default: 10000000); the initial PARI
202
+ stacksize in bytes (default: 10MB)
203
+ - ``script_subdirectory`` -- string (default: ``None``); name of the
204
+ subdirectory of SAGE_EXTCODE/pari from which to read scripts
205
+ - ``logfile`` -- string (default: ``None``); log file for the pexpect
206
+ interface
207
+ - ``server`` -- name of remote server
208
+ - ``server_tmpdir`` -- name of temporary directory on remote server
209
+ - ``init_list_length`` -- integer (default: 1024); length of initial
210
+ list of local variables.
211
+ - ``seed`` -- integer (default random nonzero 31 bit integer); value of
212
+ random seed
213
+
214
+ EXAMPLES::
215
+
216
+ sage: gp == loads(dumps(gp))
217
+ True
218
+ """
219
+ Expect.__init__(self,
220
+ name='pari',
221
+ prompt='\\? ',
222
+ # --fast so the system gprc isn't read (we configure below)
223
+ command=f"{shlex.quote(gp_executable().absolute_filename())} --fast --emacs --quiet --stacksize {stacksize}",
224
+ maxread=maxread,
225
+ server=server,
226
+ server_tmpdir=server_tmpdir,
227
+ script_subdirectory=script_subdirectory,
228
+ restart_on_ctrlc=False,
229
+ verbose_start=False,
230
+ logfile=logfile,
231
+ eval_using_file_cutoff=1024)
232
+ self.__seq = 0
233
+ self.__var_store_len = 0
234
+ self.__init_list_length = init_list_length
235
+ self._seed = seed
236
+
237
+ def set_seed(self, seed=None):
238
+ """
239
+ Set the seed for gp interpreter.
240
+
241
+ The seed should be an integer.
242
+
243
+ EXAMPLES::
244
+
245
+ sage: g = Gp()
246
+ sage: g.set_seed(1)
247
+ 1
248
+ sage: [g.random() for i in range(5)]
249
+ [1546275796, 879788114, 1745191708, 771966234, 1247963869]
250
+ """
251
+ if seed is None:
252
+ seed = self.rand_seed()
253
+ self.eval("setrand(%d)" % seed)
254
+ self._seed = seed
255
+ return seed
256
+
257
+ def _start(self, alt_message=None, block_during_init=True):
258
+ Expect._start(self, alt_message, block_during_init)
259
+ # disable memory debugging: those warnings can only confuse our
260
+ # interface
261
+ self._eval_line('default(debugmem,0);')
262
+ # disable timer
263
+ self._eval_line('default(timer,0);')
264
+ # disable the break loop, otherwise gp will seem to hang on errors
265
+ self._eval_line('default(breakloop,0);')
266
+ # list of directories where gp will look for scripts (only current working directory)
267
+ self._eval_line('default(path,".");')
268
+ # executable for gp ?? help
269
+ self._eval_line('default(help, "gphelp -detex");')
270
+ # logfile disabled since Expect already logs
271
+ self._eval_line('default(log,0);')
272
+ self._eval_line("default(nbthreads,1);")
273
+ # set random seed
274
+ self.set_seed(self._seed)
275
+
276
+ def _repr_(self):
277
+ """
278
+ String representation of this PARI gp interpreter.
279
+
280
+ EXAMPLES::
281
+
282
+ sage: gp # indirect doctest
283
+ PARI/GP interpreter
284
+ """
285
+ return 'PARI/GP interpreter'
286
+
287
+ def __reduce__(self):
288
+ """
289
+ EXAMPLES::
290
+
291
+ sage: from sage.interfaces.gp import gp
292
+ sage: gp.__reduce__()
293
+ (<function reduce_load_GP at 0x...>, ())
294
+ sage: f, args = _
295
+ sage: f(*args)
296
+ PARI/GP interpreter
297
+ """
298
+ return reduce_load_GP, tuple([])
299
+
300
+ def _function_class(self):
301
+ """
302
+ Return the GpFunction class.
303
+
304
+ EXAMPLES::
305
+
306
+ sage: gp._function_class()
307
+ <class 'sage.interfaces.expect.ExpectFunction'>
308
+ sage: type(gp.gcd)
309
+ <class 'sage.interfaces.expect.ExpectFunction'>
310
+ """
311
+ return GpFunction
312
+
313
+ def _quit_string(self):
314
+ """
315
+ Return the string used to quit the GP interpreter.
316
+
317
+ EXAMPLES::
318
+
319
+ sage: gp._quit_string()
320
+ '\\q'
321
+
322
+ ::
323
+
324
+ sage: g = Gp()
325
+ sage: a = g(2)
326
+ sage: g.is_running()
327
+ True
328
+ sage: g.quit()
329
+ sage: g.is_running()
330
+ False
331
+ """
332
+ return r"\q"
333
+
334
+ def _read_in_file_command(self, filename):
335
+ r"""
336
+ Return the string used to read filename into GP.
337
+
338
+ EXAMPLES::
339
+
340
+ sage: gp._read_in_file_command('test')
341
+ 'read("test")'
342
+
343
+ ::
344
+
345
+ sage: filename = tmp_filename()
346
+ sage: f = open(filename, 'w')
347
+ sage: _ = f.write('x = 22;\n')
348
+ sage: f.close()
349
+ sage: gp.read(filename)
350
+ sage: gp.get('x').strip()
351
+ '22'
352
+ """
353
+ return 'read("%s")' % filename
354
+
355
+ def _tab_completion(self):
356
+ """
357
+ EXAMPLES::
358
+
359
+ sage: c = gp._tab_completion()
360
+ sage: len(c) > 100
361
+ True
362
+ sage: 'gcd' in c
363
+ True
364
+ """
365
+ try:
366
+ b = self.__builtin
367
+ except AttributeError:
368
+ b = self.eval('?*').split()
369
+ self.__builtin = b
370
+ return b + self.eval('?0').split()
371
+
372
+ def get_precision(self):
373
+ """
374
+ Return the current PARI precision for real number computations.
375
+
376
+ EXAMPLES::
377
+
378
+ sage: gp.get_precision()
379
+ 38
380
+ """
381
+ return self.get_default('realprecision')
382
+
383
+ get_real_precision = get_precision
384
+
385
+ def set_precision(self, prec):
386
+ """
387
+ Set the PARI precision (in decimal digits) for real
388
+ computations, and returns the old value.
389
+
390
+ .. NOTE::
391
+
392
+ PARI/GP rounds up precisions to the nearest machine word,
393
+ so the result of :meth:`get_precision` is not always the
394
+ same as the last value inputted to :meth:`set_precision`.
395
+
396
+ EXAMPLES::
397
+
398
+ sage: old_prec = gp.set_precision(53); old_prec
399
+ 38
400
+ sage: gp.get_precision()
401
+ 57
402
+ sage: gp.set_precision(old_prec)
403
+ 57
404
+ sage: gp.get_precision()
405
+ 38
406
+ """
407
+ return self.set_default('realprecision', prec)
408
+
409
+ set_real_precision = set_precision
410
+
411
+ def get_series_precision(self):
412
+ """
413
+ Return the current PARI power series precision.
414
+
415
+ EXAMPLES::
416
+
417
+ sage: gp.get_series_precision()
418
+ 16
419
+ """
420
+ return self.get_default('seriesprecision')
421
+
422
+ def set_series_precision(self, prec=None):
423
+ """
424
+ Set the PARI power series precision, and returns the old precision.
425
+
426
+ EXAMPLES::
427
+
428
+ sage: old_prec = gp.set_series_precision(50); old_prec
429
+ 16
430
+ sage: gp.get_series_precision()
431
+ 50
432
+ sage: gp.set_series_precision(old_prec)
433
+ 50
434
+ sage: gp.get_series_precision()
435
+ 16
436
+ """
437
+ return self.set_default('seriesprecision', prec)
438
+
439
+ def _eval_line(self, line, allow_use_file=True, wait_for_prompt=True, restart_if_needed=False):
440
+ """
441
+ EXAMPLES::
442
+
443
+ sage: gp._eval_line('2+2')
444
+ '4'
445
+
446
+ TESTS:
447
+
448
+ We verify that :issue:`11617` is fixed::
449
+
450
+ sage: gp._eval_line('a='+str(list(range(2*10^5))))[:70]
451
+ '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,'
452
+ """
453
+ line = line.strip()
454
+ if len(line) == 0:
455
+ return ''
456
+ a = Expect._eval_line(self, line,
457
+ allow_use_file=allow_use_file,
458
+ wait_for_prompt=wait_for_prompt)
459
+ if a.find("the PARI stack overflows") != -1:
460
+ verbose("automatically doubling the PARI stack and re-executing current input line")
461
+ b = self.eval("allocatemem()")
462
+ if b.find("Warning: not enough memory") != -1:
463
+ raise RuntimeError(a)
464
+ return self._eval_line(line, allow_use_file=allow_use_file,
465
+ wait_for_prompt=wait_for_prompt)
466
+ else:
467
+ return a
468
+
469
+ def cputime(self, t=None):
470
+ """
471
+ cputime for pari - cputime since the pari process was started.
472
+
473
+ INPUT:
474
+
475
+ - ``t`` -- (default: ``None``) if not None, then returns
476
+ time since t
477
+
478
+
479
+ .. warning::
480
+
481
+ If you call gettime explicitly, e.g., gp.eval('gettime'),
482
+ you will throw off this clock.
483
+
484
+ EXAMPLES::
485
+
486
+ sage: gp.cputime() # random output
487
+ 0.0080000000000000002
488
+ sage: gp.factor('2^157-1')
489
+ [852133201, 1; 60726444167, 1; 1654058017289, 1; 2134387368610417, 1]
490
+ sage: gp.cputime() # random output
491
+ 0.26900000000000002
492
+ """
493
+ try:
494
+ tm = self._last
495
+ except AttributeError:
496
+ tm = 0.0
497
+ m = eval(self.eval('gettime()/1000.0')) + tm
498
+ self._last = m
499
+ if t:
500
+ return m - t
501
+ return m
502
+
503
+ def set_default(self, var, value):
504
+ """
505
+ Set a PARI gp configuration variable, and return the old value.
506
+
507
+ INPUT:
508
+
509
+ - ``var`` -- string; the name of a PARI gp
510
+ configuration variable (see ``gp.default()`` for a list)
511
+ - ``value`` -- the value to set the variable to
512
+
513
+ EXAMPLES::
514
+
515
+ sage: old_prec = gp.set_default('realprecision', 110)
516
+ sage: gp.get_default('realprecision')
517
+ 115
518
+ sage: gp.set_default('realprecision', old_prec)
519
+ 115
520
+ sage: gp.get_default('realprecision')
521
+ 38
522
+ """
523
+ old = self.get_default(var)
524
+ self._eval_line('default(%s,%s)' % (var, value))
525
+ return old
526
+
527
+ def get_default(self, var):
528
+ """
529
+ Return the current value of a PARI gp configuration variable.
530
+
531
+ INPUT:
532
+
533
+ - ``var`` -- string; the name of a PARI gp
534
+ configuration variable (see ``gp.default()`` for a list)
535
+
536
+ OUTPUT: string; the value of the variable
537
+
538
+ EXAMPLES::
539
+
540
+ sage: gp.get_default('log')
541
+ 0
542
+ sage: gp.get_default('datadir')
543
+ '.../share/pari'
544
+ sage: gp.get_default('seriesprecision')
545
+ 16
546
+ sage: gp.get_default('realprecision')
547
+ 38
548
+ """
549
+ return eval(self._eval_line('default(%s)' % var))
550
+
551
+ def set(self, var, value):
552
+ """
553
+ Set the GP variable var to the given value.
554
+
555
+ INPUT:
556
+
557
+ - ``var`` -- string; a valid GP variable identifier
558
+ - ``value`` -- a value for the variable
559
+
560
+ EXAMPLES::
561
+
562
+ sage: gp.set('x', '2')
563
+ sage: gp.get('x')
564
+ '2'
565
+ """
566
+ cmd = '%s=%s;' % (var, value)
567
+ out = self.eval(cmd)
568
+ if out.find('***') != -1:
569
+ raise TypeError("Error executing code in GP:\nCODE:\n\t%s\nPARI/GP ERROR:\n%s" % (cmd, out))
570
+
571
+ def get(self, var):
572
+ """
573
+ Get the value of the GP variable var.
574
+
575
+ INPUT:
576
+
577
+ - ``var`` -- string; a valid GP variable identifier
578
+
579
+ EXAMPLES::
580
+
581
+ sage: gp.set('x', '2')
582
+ sage: gp.get('x')
583
+ '2'
584
+ """
585
+ return self.eval('print(%s)' % var)
586
+
587
+ def kill(self, var):
588
+ """
589
+ Kill the value of the GP variable var.
590
+
591
+ INPUT:
592
+
593
+ - ``var`` -- string; a valid GP variable identifier
594
+
595
+ EXAMPLES::
596
+
597
+ sage: gp.set('xx', '22')
598
+ sage: gp.get('xx')
599
+ '22'
600
+ sage: gp.kill('xx')
601
+ sage: gp.get('xx')
602
+ 'xx'
603
+ """
604
+ self.eval('kill(%s)' % var)
605
+
606
+ def _next_var_name(self):
607
+ """
608
+ Return the name of the next unused interface variable name.
609
+
610
+ EXAMPLES::
611
+
612
+ sage: g = Gp()
613
+ sage: g._next_var_name()
614
+ 'sage[1]'
615
+ sage: g(2)^2
616
+ 4
617
+ sage: g._next_var_name()
618
+ 'sage[5]'
619
+
620
+ TESTS:
621
+
622
+ The vector of results is correctly resized when the stack has
623
+ to be enlarged during this operation::
624
+
625
+ sage: g = Gp(stacksize=3*10^6,init_list_length=12000) # long time
626
+ sage: for n in [1..13000]: # long time
627
+ ....: a = g(n)
628
+ sage: g('length(sage)') # long time
629
+ 24000
630
+ """
631
+ self.__seq += 1
632
+ if self.__seq >= self.__var_store_len:
633
+ if self.__var_store_len == 0:
634
+ self.eval('sage=vector(%s,k,0);' % self.__init_list_length)
635
+ self.__var_store_len = self.__init_list_length
636
+ else:
637
+ self.eval('sage0=concat(sage, vector(%s,k,0));' % self.__var_store_len)
638
+ self.eval('sage=sage0;')
639
+ self.eval('kill(sage0);')
640
+ self.__var_store_len *= 2
641
+ verbose("doubling PARI/sage object vector: %s" % self.__var_store_len)
642
+ return 'sage[%s]' % self.__seq
643
+
644
+ def _reset_expect(self):
645
+ """
646
+ Reset state of the GP interface.
647
+
648
+ EXAMPLES::
649
+
650
+ sage: a = gp('10'); a
651
+ 10
652
+ sage: gp.quit() # indirect doctest
653
+ sage: a
654
+ (invalid PARI/GP interpreter object -- The pari session in which this object was defined is no longer running.)
655
+ sage: gp("30!")
656
+ 265252859812191058636308480000000
657
+ """
658
+ self.__var_store_len = 0
659
+ Expect._reset_expect(self)
660
+
661
+ def console(self):
662
+ """
663
+ Spawn a new GP command-line session.
664
+
665
+ EXAMPLES::
666
+
667
+ sage: gp.console() # not tested
668
+ GP/PARI CALCULATOR Version 2.4.3 (development svn-12577)
669
+ amd64 running linux (x86-64/GMP-4.2.1 kernel) 64-bit version
670
+ compiled: Jul 21 2010, gcc-4.6.0 20100705 (experimental) (GCC)
671
+ (readline v6.0 enabled, extended help enabled)
672
+ """
673
+ gp_console()
674
+
675
+ def version(self):
676
+ """
677
+ Return the version of GP being used.
678
+
679
+ EXAMPLES::
680
+
681
+ sage: gp.version() # not tested
682
+ ((2, 4, 3), 'GP/PARI CALCULATOR Version 2.4.3 (development svn-12577)')
683
+ """
684
+ return gp_version()
685
+
686
+ def _object_class(self):
687
+ """
688
+ Return the GpElement class.
689
+
690
+ EXAMPLES::
691
+
692
+ sage: gp._object_class()
693
+ <class 'sage.interfaces.gp.GpElement'>
694
+ sage: type(gp(2))
695
+ <class 'sage.interfaces.gp.GpElement'>
696
+ """
697
+ return GpElement
698
+
699
+ def _function_element_class(self):
700
+ """
701
+ Return the GpFunctionElement class.
702
+
703
+ EXAMPLES::
704
+
705
+ sage: gp._function_element_class()
706
+ <class 'sage.interfaces.expect.FunctionElement'>
707
+ sage: type(gp(2).gcd)
708
+ <class 'sage.interfaces.expect.FunctionElement'>
709
+ """
710
+ return GpFunctionElement
711
+
712
+ def _true_symbol(self):
713
+ """
714
+ Return the symbol used for truth in GP.
715
+
716
+ EXAMPLES::
717
+
718
+ sage: gp._true_symbol()
719
+ '1'
720
+
721
+ ::
722
+
723
+ sage: gp(2) == gp(2)
724
+ True
725
+ """
726
+ return '1'
727
+
728
+ def _false_symbol(self):
729
+ """
730
+ Return the symbol used for falsity in GP.
731
+
732
+ EXAMPLES::
733
+
734
+ sage: gp._false_symbol()
735
+ '0'
736
+
737
+ ::
738
+
739
+ sage: gp(2) == gp(3)
740
+ False
741
+ """
742
+ return '0'
743
+
744
+ def _equality_symbol(self):
745
+ """
746
+ Return the symbol used for equality in GP.
747
+
748
+ EXAMPLES::
749
+
750
+ sage: gp._equality_symbol()
751
+ '=='
752
+
753
+ ::
754
+
755
+ sage: gp(2) == gp(2)
756
+ True
757
+ """
758
+ return '=='
759
+
760
+ def _exponent_symbol(self):
761
+ """
762
+ Return the symbol to denote the exponent of a number in GP.
763
+
764
+ EXAMPLES::
765
+
766
+ sage: gp._exponent_symbol()
767
+ ' E'
768
+
769
+ ::
770
+
771
+ sage: repr(gp(10.^80)).replace(gp._exponent_symbol(), 'e')
772
+ '1.0000000000000000000000000000000000000e80'
773
+ """
774
+ return ' E'
775
+
776
+ def help(self, command):
777
+ r"""
778
+ Return GP's help for ``command``.
779
+
780
+ EXAMPLES::
781
+
782
+ sage: gp.help('gcd')
783
+ 'gcd(x,{y}): greatest common divisor of x and y.'
784
+ """
785
+ return self.eval('?%s' % command).strip()
786
+
787
+ def new_with_bits_prec(self, s, precision=0):
788
+ r"""
789
+ Create a GP object from s with ``precision`` bits of
790
+ precision. GP actually automatically increases this precision to
791
+ the nearest word (i.e. the next multiple of 32 on a 32-bit machine,
792
+ or the next multiple of 64 on a 64-bit machine).
793
+
794
+ EXAMPLES::
795
+
796
+ sage: # needs sage.symbolic
797
+ sage: pi_def = gp(pi); pi_def
798
+ 3.1415926535897932384626433832795028842
799
+ sage: pi_def.precision()
800
+ 38
801
+ sage: pi_150 = gp.new_with_bits_prec(pi, 150)
802
+ sage: new_prec = pi_150.precision(); new_prec
803
+ 48 # 32-bit
804
+ 57 # 64-bit
805
+ sage: old_prec = gp.set_precision(new_prec); old_prec
806
+ 38
807
+ sage: pi_150
808
+ 3.14159265358979323846264338327950288419716939938 # 32-bit
809
+ 3.14159265358979323846264338327950288419716939937510582098 # 64-bit
810
+ sage: gp.set_precision(old_prec)
811
+ 48 # 32-bit
812
+ 57 # 64-bit
813
+ sage: gp.get_precision()
814
+ 38
815
+ """
816
+ if precision:
817
+ old_prec = self.get_real_precision()
818
+ prec = int(precision / 3.321928095)
819
+ self.set_real_precision(prec)
820
+ x = self(s)
821
+ self.set_real_precision(old_prec)
822
+ else:
823
+ x = self(s)
824
+ return x
825
+
826
+
827
+ @instancedoc
828
+ class GpElement(ExpectElement, sage.interfaces.abc.GpElement):
829
+ """
830
+ EXAMPLES: This example illustrates dumping and loading GP elements
831
+ to compressed strings.
832
+
833
+ ::
834
+
835
+ sage: a = gp(39393)
836
+ sage: loads(a.dumps()) == a
837
+ True
838
+
839
+ Since dumping and loading uses the string representation of the
840
+ object, it need not result in an identical object from the point of
841
+ view of PARI::
842
+
843
+ sage: E = gp('ellinit([1,2,3,4,5])')
844
+ sage: loads(dumps(E)) == E
845
+ True
846
+ sage: x = gp.Pi()/3
847
+ sage: loads(dumps(x)) == x
848
+ False
849
+ sage: x
850
+ 1.0471975511965977461542144610931676281
851
+ sage: loads(dumps(x))
852
+ 1.0471975511965977461542144610931676281
853
+
854
+ The two elliptic curves look the same, but internally the floating
855
+ point numbers are slightly different.
856
+ """
857
+ def _reduce(self):
858
+ """
859
+ Return the string representation of self, for pickling.
860
+
861
+ Because the internal representation of a gp element is richer
862
+ than the corresponding sage object, we use the string representation
863
+ for pickling.
864
+
865
+ EXAMPLES::
866
+
867
+ sage: E = gp('ellinit([1,2,3,4,5])')
868
+ sage: loads(dumps(E)) == E # indirect doctest
869
+ True
870
+ sage: gp(E.sage()) == E
871
+ False
872
+ """
873
+ return repr(self)
874
+
875
+ def _sage_(self):
876
+ """
877
+ Convert this GpElement into a Sage object, if possible.
878
+
879
+ EXAMPLES::
880
+
881
+ sage: gp(SR(I)).sage() # needs sage.symbolic
882
+ i
883
+ sage: gp(SR(I)).sage().parent() # needs sage.symbolic
884
+ Number Field in i with defining polynomial x^2 + 1 with i = 1*I
885
+
886
+ ::
887
+
888
+ sage: # needs sage.modules
889
+ sage: M = Matrix(ZZ,2,2,[1,2,3,4]); M
890
+ [1 2]
891
+ [3 4]
892
+ sage: gp(M)
893
+ [1, 2; 3, 4]
894
+ sage: gp(M).sage()
895
+ [1 2]
896
+ [3 4]
897
+ sage: gp(M).sage() == M
898
+ True
899
+
900
+ Conversion of strings::
901
+
902
+ sage: s = gp('"foo"')
903
+ sage: s.sage()
904
+ 'foo'
905
+ sage: type(s.sage())
906
+ <class 'str'>
907
+ """
908
+ if self.is_string():
909
+ return str(self)
910
+ return pari(str(self)).sage()
911
+
912
+ def is_string(self):
913
+ """
914
+ Tell whether this element is a string.
915
+
916
+ EXAMPLES::
917
+
918
+ sage: gp('"abc"').is_string()
919
+ True
920
+ sage: gp('[1,2,3]').is_string()
921
+ False
922
+ """
923
+ return repr(self.type()) == 't_STR'
924
+
925
+ def __float__(self):
926
+ """
927
+ Return Python float.
928
+
929
+ EXAMPLES::
930
+
931
+ sage: float(gp(10))
932
+ 10.0
933
+ """
934
+ return float(pari(str(self)))
935
+
936
+ def __bool__(self):
937
+ """
938
+ EXAMPLES::
939
+
940
+ sage: gp(2).bool()
941
+ True
942
+ sage: bool(gp(2))
943
+ True
944
+ sage: bool(gp(0))
945
+ False
946
+ """
947
+ P = self._check_valid()
948
+ return P.eval('%s != 0' % (self.name())) == '1'
949
+
950
+ def _complex_mpfr_field_(self, CC):
951
+ """
952
+ Return ComplexField element of ``self``.
953
+
954
+ INPUT:
955
+
956
+ - ``CC`` -- a Complex or Real Field
957
+
958
+ EXAMPLES::
959
+
960
+ sage: # needs sage.symbolic
961
+ sage: z = gp(SR(1+15*I)); z
962
+ 1 + 15*I
963
+ sage: z._complex_mpfr_field_(CC)
964
+ 1.00000000000000 + 15.0000000000000*I
965
+ sage: CC(z) # CC(gp(1+15*I))
966
+ 1.00000000000000 + 15.0000000000000*I
967
+ sage: CC(gp(11243.9812+15*I))
968
+ 11243.9812000000 + 15.0000000000000*I
969
+ sage: ComplexField(10)(gp(11243.9812+15*I))
970
+ 11000. + 15.*I
971
+ """
972
+ # Multiplying by CC(1) is necessary here since
973
+ # sage: pari(gp(1+I)).sage().parent()
974
+ # Maximal Order in Number Field in i with defining polynomial x^2 + 1
975
+ return CC((CC.one() * pari(self)).sage())
976
+
977
+ def _complex_double_(self, CDF):
978
+ """
979
+ Return this value as a CDF element.
980
+
981
+ EXAMPLES::
982
+
983
+ sage: CDF(gp(pi+I*e)) # needs sage.symbolic
984
+ 3.141592653589793 + 2.718281828459045*I
985
+ """
986
+ # Retrieving values from another computer algebra system is
987
+ # slow anyway, right?
988
+ cc_val = self._complex_mpfr_field_(CC)
989
+ return CDF(cc_val)
990
+
991
+ def __len__(self):
992
+ """
993
+ EXAMPLES::
994
+
995
+ sage: len(gp([1,2,3]))
996
+ 3
997
+ """
998
+ return int(self.length())
999
+
1000
+ def __del__(self):
1001
+ """
1002
+ Note that clearing object is pointless since it wastes time and
1003
+ PARI/GP doesn't really free used memory.
1004
+
1005
+ EXAMPLES::
1006
+
1007
+ sage: a = gp(2)
1008
+ sage: a.__del__()
1009
+ sage: a
1010
+ 2
1011
+ sage: del a
1012
+ sage: a
1013
+ Traceback (most recent call last):
1014
+ ...
1015
+ NameError: name 'a' is not defined
1016
+ """
1017
+ return
1018
+
1019
+ # This is tempting -- but the (la)tex output is very very
1020
+ # out of date, e.g., for matrices it uses \pmatrix (which
1021
+ # causes an error if amsmath is loaded) and for rationals
1022
+ # it does nothing, etc.
1023
+ # def _latex_(self):
1024
+ # P = self._check_valid()
1025
+ # return P.eval('printtex(%s)'%self.name())
1026
+
1027
+ def _tab_completion(self):
1028
+ """
1029
+ EXAMPLES::
1030
+
1031
+ sage: 'gcd' in gp(2)._tab_completion()
1032
+ True
1033
+ """
1034
+ return self.parent()._tab_completion()
1035
+
1036
+
1037
+ GpFunctionElement = FunctionElement
1038
+ GpFunction = ExpectFunction
1039
+
1040
+
1041
+ def is_GpElement(x):
1042
+ """
1043
+ Return ``True`` if ``x`` is of type :class:`GpElement`.
1044
+
1045
+ This function is deprecated; use :func:`isinstance`
1046
+ (of :class:`sage.interfaces.abc.GpElement`) instead.
1047
+
1048
+ EXAMPLES::
1049
+
1050
+ sage: from sage.interfaces.gp import is_GpElement
1051
+ sage: is_GpElement(gp(2))
1052
+ doctest:...: DeprecationWarning: the function is_GpElement is deprecated; use isinstance(x, sage.interfaces.abc.GpElement) instead
1053
+ See https://github.com/sagemath/sage/issues/34804 for details.
1054
+ True
1055
+ sage: is_GpElement(2)
1056
+ False
1057
+ """
1058
+ from sage.misc.superseded import deprecation
1059
+ deprecation(34804, "the function is_GpElement is deprecated; use isinstance(x, sage.interfaces.abc.GpElement) instead")
1060
+
1061
+ return isinstance(x, GpElement)
1062
+
1063
+
1064
+ # An instance
1065
+ gp = Gp(logfile=os.path.join(DOT_SAGE, 'gp-expect.log'))
1066
+ # useful for debugging!
1067
+
1068
+
1069
+ def reduce_load_GP():
1070
+ """
1071
+ Return the GP interface object defined in ``sage.interfaces.gp``.
1072
+
1073
+ EXAMPLES::
1074
+
1075
+ sage: from sage.interfaces.gp import reduce_load_GP
1076
+ sage: reduce_load_GP()
1077
+ PARI/GP interpreter
1078
+ """
1079
+ return gp
1080
+
1081
+
1082
+ def gp_console():
1083
+ """
1084
+ Spawn a new GP command-line session.
1085
+
1086
+ EXAMPLES::
1087
+
1088
+ sage: gp.console() # not tested
1089
+ GP/PARI CALCULATOR Version 2.4.3 (development svn-12577)
1090
+ amd64 running linux (x86-64/GMP-4.2.1 kernel) 64-bit version
1091
+ compiled: Jul 21 2010, gcc-4.6.0 20100705 (experimental) (GCC)
1092
+ (readline v6.0 enabled, extended help enabled)
1093
+ """
1094
+ from sage.repl.rich_output.display_manager import get_display_manager
1095
+ if not get_display_manager().is_in_terminal():
1096
+ raise RuntimeError('Can use the console only in the terminal. Try %%gp magics instead.')
1097
+ os.system(shlex.quote(gp_executable().absolute_filename()))
1098
+
1099
+
1100
+ def gp_version():
1101
+ """
1102
+ EXAMPLES::
1103
+
1104
+ sage: gp.version() # not tested
1105
+ ((2, 4, 3), 'GP/PARI CALCULATOR Version 2.4.3 (development svn-12577)')
1106
+ """
1107
+ v = gp.eval(r'\v')
1108
+ i = v.find("Version ")
1109
+ w = v[i + len("Version "):]
1110
+ i = w.find(' ')
1111
+ w = w[:i]
1112
+ t = tuple([int(n) for n in w.split('.')])
1113
+ k = v.find('\n')
1114
+ return t, v[:k].strip()