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.
- PARIKernel/__init__.py +2 -0
- PARIKernel/__main__.py +5 -0
- PARIKernel/io.cpython-314-x86_64-linux-musl.so +0 -0
- PARIKernel/io.pxd +7 -0
- PARIKernel/io.pyx +84 -0
- PARIKernel/kernel.cpython-314-x86_64-linux-musl.so +0 -0
- PARIKernel/kernel.pyx +260 -0
- PARIKernel/paridecl.pxd +95 -0
- PARIKernel/svg.cpython-314-x86_64-linux-musl.so +0 -0
- PARIKernel/svg.pyx +52 -0
- cypari2/__init__.py +8 -0
- cypari2/auto_paridecl.pxd +1070 -0
- cypari2/closure.cpython-314-x86_64-linux-musl.so +0 -0
- cypari2/closure.pxd +5 -0
- cypari2/closure.pyx +246 -0
- cypari2/convert.cpython-314-x86_64-linux-musl.so +0 -0
- cypari2/convert.pxd +80 -0
- cypari2/convert.pyx +613 -0
- cypari2/custom_block.cpython-314-x86_64-linux-musl.so +0 -0
- cypari2/custom_block.pyx +30 -0
- cypari2/cypari.h +13 -0
- cypari2/gen.cpython-314-x86_64-linux-musl.so +0 -0
- cypari2/gen.pxd +69 -0
- cypari2/gen.pyx +4819 -0
- cypari2/handle_error.cpython-314-x86_64-linux-musl.so +0 -0
- cypari2/handle_error.pxd +7 -0
- cypari2/handle_error.pyx +232 -0
- cypari2/pari_instance.cpython-314-x86_64-linux-musl.so +0 -0
- cypari2/pari_instance.pxd +27 -0
- cypari2/pari_instance.pyx +1438 -0
- cypari2/paridecl.pxd +5353 -0
- cypari2/paripriv.pxd +34 -0
- cypari2/pycore_long.h +98 -0
- cypari2/pycore_long.pxd +9 -0
- cypari2/stack.cpython-314-x86_64-linux-musl.so +0 -0
- cypari2/stack.pxd +27 -0
- cypari2/stack.pyx +278 -0
- cypari2/string_utils.cpython-314-x86_64-linux-musl.so +0 -0
- cypari2/string_utils.pxd +29 -0
- cypari2/string_utils.pyx +65 -0
- cypari2/types.pxd +147 -0
- passagemath_pari-10.6.32.data/data/etc/jupyter/nbconfig/notebook.d/gp-mode.json +5 -0
- passagemath_pari-10.6.32.data/data/share/jupyter/kernels/pari_jupyter/kernel.js +28 -0
- passagemath_pari-10.6.32.data/data/share/jupyter/kernels/pari_jupyter/kernel.json +6 -0
- passagemath_pari-10.6.32.data/data/share/jupyter/kernels/pari_jupyter/logo-64x64.png +0 -0
- passagemath_pari-10.6.32.data/data/share/jupyter/kernels/xeus-gp/kernel.json +13 -0
- passagemath_pari-10.6.32.data/data/share/jupyter/kernels/xeus-gp/logo-32x32.png +0 -0
- passagemath_pari-10.6.32.data/data/share/jupyter/kernels/xeus-gp/logo-64x64.png +0 -0
- passagemath_pari-10.6.32.data/data/share/jupyter/kernels/xeus-gp/logo-svg.svg +75 -0
- passagemath_pari-10.6.32.data/data/share/jupyter/nbextensions/gp-mode/gp.js +284 -0
- passagemath_pari-10.6.32.data/data/share/jupyter/nbextensions/gp-mode/main.js +15 -0
- passagemath_pari-10.6.32.dist-info/METADATA +209 -0
- passagemath_pari-10.6.32.dist-info/RECORD +331 -0
- passagemath_pari-10.6.32.dist-info/WHEEL +5 -0
- passagemath_pari-10.6.32.dist-info/top_level.txt +4 -0
- passagemath_pari.libs/libcrypto-f04afe95.so.3 +0 -0
- passagemath_pari.libs/libflint-fd6f12fc.so.21.0.0 +0 -0
- passagemath_pari.libs/libgcc_s-0cd532bd.so.1 +0 -0
- passagemath_pari.libs/libgf2x-9e30c3e3.so.3.0.0 +0 -0
- passagemath_pari.libs/libgfortran-2c33b284.so.5.0.0 +0 -0
- passagemath_pari.libs/libgivaro-9a94c711.so.9.2.1 +0 -0
- passagemath_pari.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
- passagemath_pari.libs/libgmpxx-9e08595c.so.4.7.0 +0 -0
- passagemath_pari.libs/libgsl-42cda06f.so.28.0.0 +0 -0
- passagemath_pari.libs/libmpfr-aaecbfc0.so.6.2.1 +0 -0
- passagemath_pari.libs/libncursesw-9c9e32c3.so.6.5 +0 -0
- passagemath_pari.libs/libntl-26885ca2.so.44.0.1 +0 -0
- passagemath_pari.libs/libopenblasp-r0-905cb27d.3.29.so +0 -0
- passagemath_pari.libs/libpari-gmp-tls-f31f908f.so.2.17.2 +0 -0
- passagemath_pari.libs/libquadmath-bb76a5fc.so.0.0.0 +0 -0
- passagemath_pari.libs/libreadline-06542304.so.8.2 +0 -0
- passagemath_pari.libs/libstdc++-5d72f927.so.6.0.33 +0 -0
- passagemath_pari.libs/libuuid-f3770415.so.1.3.0 +0 -0
- passagemath_pari.libs/libxeus-735780ff.so.13.1.0 +0 -0
- passagemath_pari.libs/libxeus-zmq-c68577b4.so.6.0.1 +0 -0
- passagemath_pari.libs/libzmq-1ba9a3da.so.5.2.5 +0 -0
- sage/all__sagemath_pari.py +26 -0
- sage/databases/all__sagemath_pari.py +7 -0
- sage/databases/conway.py +274 -0
- sage/ext/all__sagemath_pari.py +1 -0
- sage/ext/memory.cpython-314-x86_64-linux-musl.so +0 -0
- sage/ext/memory.pyx +98 -0
- sage/ext_data/pari/buzzard/DimensionSk.g +286 -0
- sage/ext_data/pari/buzzard/Tpprog.g +179 -0
- sage/ext_data/pari/buzzard/genusn.g +129 -0
- sage/ext_data/pari/dokchitser/computel.gp +740 -0
- sage/ext_data/pari/dokchitser/computel.gp.template +740 -0
- sage/ext_data/pari/dokchitser/ex-bsw +43 -0
- sage/ext_data/pari/dokchitser/ex-chgen +48 -0
- sage/ext_data/pari/dokchitser/ex-chqua +37 -0
- sage/ext_data/pari/dokchitser/ex-delta +35 -0
- sage/ext_data/pari/dokchitser/ex-eisen +30 -0
- sage/ext_data/pari/dokchitser/ex-gen2 +38 -0
- sage/ext_data/pari/dokchitser/ex-gen3 +49 -0
- sage/ext_data/pari/dokchitser/ex-gen4 +54 -0
- sage/ext_data/pari/dokchitser/ex-nf +48 -0
- sage/ext_data/pari/dokchitser/ex-shin +50 -0
- sage/ext_data/pari/dokchitser/ex-tau2 +30 -0
- sage/ext_data/pari/dokchitser/ex-zeta +27 -0
- sage/ext_data/pari/dokchitser/ex-zeta2 +47 -0
- sage/ext_data/pari/dokchitser/testall +13 -0
- sage/ext_data/pari/simon/ell.gp +2129 -0
- sage/ext_data/pari/simon/ellQ.gp +2151 -0
- sage/ext_data/pari/simon/ellcommon.gp +126 -0
- sage/ext_data/pari/simon/qfsolve.gp +722 -0
- sage/ext_data/pari/simon/resultant3.gp +306 -0
- sage/groups/all__sagemath_pari.py +3 -0
- sage/groups/pari_group.py +175 -0
- sage/interfaces/all__sagemath_pari.py +1 -0
- sage/interfaces/genus2reduction.py +464 -0
- sage/interfaces/gp.py +1114 -0
- sage/libs/all__sagemath_pari.py +2 -0
- sage/libs/linkages/__init__.py +1 -0
- sage/libs/linkages/padics/API.pxi +617 -0
- sage/libs/linkages/padics/Polynomial_ram.pxi +388 -0
- sage/libs/linkages/padics/Polynomial_shared.pxi +554 -0
- sage/libs/linkages/padics/__init__.py +1 -0
- sage/libs/linkages/padics/fmpz_poly_unram.pxi +869 -0
- sage/libs/linkages/padics/mpz.pxi +691 -0
- sage/libs/linkages/padics/relaxed/API.pxi +518 -0
- sage/libs/linkages/padics/relaxed/__init__.py +1 -0
- sage/libs/linkages/padics/relaxed/flint.pxi +543 -0
- sage/libs/linkages/padics/unram_shared.pxi +247 -0
- sage/libs/pari/__init__.py +210 -0
- sage/libs/pari/all.py +5 -0
- sage/libs/pari/convert_flint.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/pari/convert_flint.pxd +14 -0
- sage/libs/pari/convert_flint.pyx +159 -0
- sage/libs/pari/convert_gmp.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/pari/convert_gmp.pxd +14 -0
- sage/libs/pari/convert_gmp.pyx +210 -0
- sage/libs/pari/convert_sage.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/pari/convert_sage.pxd +16 -0
- sage/libs/pari/convert_sage.pyx +588 -0
- sage/libs/pari/convert_sage_complex_double.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/pari/convert_sage_complex_double.pxd +14 -0
- sage/libs/pari/convert_sage_complex_double.pyx +132 -0
- sage/libs/pari/convert_sage_matrix.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/pari/convert_sage_matrix.pyx +106 -0
- sage/libs/pari/convert_sage_real_double.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/pari/convert_sage_real_double.pxd +5 -0
- sage/libs/pari/convert_sage_real_double.pyx +14 -0
- sage/libs/pari/convert_sage_real_mpfr.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/pari/convert_sage_real_mpfr.pxd +7 -0
- sage/libs/pari/convert_sage_real_mpfr.pyx +108 -0
- sage/libs/pari/misc.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/pari/misc.pxd +4 -0
- sage/libs/pari/misc.pyx +26 -0
- sage/libs/pari/tests.py +1848 -0
- sage/matrix/all__sagemath_pari.py +1 -0
- sage/matrix/matrix_integer_pari.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matrix/matrix_integer_pari.pyx +187 -0
- sage/matrix/matrix_rational_pari.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matrix/matrix_rational_pari.pyx +160 -0
- sage/quadratic_forms/all__sagemath_pari.py +10 -0
- sage/quadratic_forms/genera/all.py +9 -0
- sage/quadratic_forms/genera/genus.py +3506 -0
- sage/quadratic_forms/genera/normal_form.py +1519 -0
- sage/quadratic_forms/genera/spinor_genus.py +243 -0
- sage/quadratic_forms/qfsolve.py +255 -0
- sage/quadratic_forms/quadratic_form__automorphisms.py +427 -0
- sage/quadratic_forms/quadratic_form__genus.py +141 -0
- sage/quadratic_forms/quadratic_form__local_density_interfaces.py +140 -0
- sage/quadratic_forms/quadratic_form__local_normal_form.py +421 -0
- sage/quadratic_forms/quadratic_form__local_representation_conditions.py +889 -0
- sage/quadratic_forms/quadratic_form__mass.py +69 -0
- sage/quadratic_forms/quadratic_form__mass__Conway_Sloane_masses.py +663 -0
- sage/quadratic_forms/quadratic_form__mass__Siegel_densities.py +373 -0
- sage/quadratic_forms/quadratic_form__siegel_product.py +198 -0
- sage/quadratic_forms/special_values.py +323 -0
- sage/rings/all__sagemath_pari.py +15 -0
- sage/rings/factorint_pari.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/factorint_pari.pyx +80 -0
- sage/rings/finite_rings/all__sagemath_pari.py +1 -0
- sage/rings/finite_rings/element_givaro.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/finite_rings/element_givaro.pxd +91 -0
- sage/rings/finite_rings/element_givaro.pyx +1769 -0
- sage/rings/finite_rings/element_ntl_gf2e.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/finite_rings/element_ntl_gf2e.pxd +22 -0
- sage/rings/finite_rings/element_ntl_gf2e.pyx +1333 -0
- sage/rings/finite_rings/element_pari_ffelt.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/finite_rings/element_pari_ffelt.pxd +13 -0
- sage/rings/finite_rings/element_pari_ffelt.pyx +1441 -0
- sage/rings/finite_rings/finite_field_givaro.py +612 -0
- sage/rings/finite_rings/finite_field_pari_ffelt.py +238 -0
- sage/rings/finite_rings/hom_finite_field_givaro.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/finite_rings/hom_finite_field_givaro.pxd +28 -0
- sage/rings/finite_rings/hom_finite_field_givaro.pyx +280 -0
- sage/rings/finite_rings/residue_field_givaro.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/finite_rings/residue_field_givaro.pyx +133 -0
- sage/rings/finite_rings/residue_field_pari_ffelt.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/finite_rings/residue_field_pari_ffelt.pyx +128 -0
- sage/rings/function_field/all__sagemath_pari.py +1 -0
- sage/rings/function_field/valuation.py +1450 -0
- sage/rings/function_field/valuation_ring.py +212 -0
- sage/rings/number_field/all__sagemath_pari.py +14 -0
- sage/rings/number_field/totallyreal.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/number_field/totallyreal.pyx +509 -0
- sage/rings/number_field/totallyreal_data.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/number_field/totallyreal_data.pxd +26 -0
- sage/rings/number_field/totallyreal_data.pyx +928 -0
- sage/rings/number_field/totallyreal_phc.py +144 -0
- sage/rings/number_field/totallyreal_rel.py +1018 -0
- sage/rings/padics/CA_template.pxi +1847 -0
- sage/rings/padics/CA_template_header.pxi +50 -0
- sage/rings/padics/CR_template.pxi +2563 -0
- sage/rings/padics/CR_template_header.pxi +57 -0
- sage/rings/padics/FM_template.pxi +1575 -0
- sage/rings/padics/FM_template_header.pxi +50 -0
- sage/rings/padics/FP_template.pxi +2176 -0
- sage/rings/padics/FP_template_header.pxi +57 -0
- sage/rings/padics/all.py +3 -0
- sage/rings/padics/all__sagemath_pari.py +11 -0
- sage/rings/padics/common_conversion.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/common_conversion.pxd +15 -0
- sage/rings/padics/common_conversion.pyx +508 -0
- sage/rings/padics/eisenstein_extension_generic.py +232 -0
- sage/rings/padics/factory.py +3623 -0
- sage/rings/padics/generic_nodes.py +1615 -0
- sage/rings/padics/lattice_precision.py +2889 -0
- sage/rings/padics/morphism.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/morphism.pxd +11 -0
- sage/rings/padics/morphism.pyx +366 -0
- sage/rings/padics/padic_base_generic.py +467 -0
- sage/rings/padics/padic_base_leaves.py +1235 -0
- sage/rings/padics/padic_capped_absolute_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/padic_capped_absolute_element.pxd +15 -0
- sage/rings/padics/padic_capped_absolute_element.pyx +520 -0
- sage/rings/padics/padic_capped_relative_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/padic_capped_relative_element.pxd +14 -0
- sage/rings/padics/padic_capped_relative_element.pyx +614 -0
- sage/rings/padics/padic_extension_generic.py +990 -0
- sage/rings/padics/padic_extension_leaves.py +738 -0
- sage/rings/padics/padic_fixed_mod_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/padic_fixed_mod_element.pxd +15 -0
- sage/rings/padics/padic_fixed_mod_element.pyx +584 -0
- sage/rings/padics/padic_floating_point_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/padic_floating_point_element.pxd +14 -0
- sage/rings/padics/padic_floating_point_element.pyx +447 -0
- sage/rings/padics/padic_generic_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/padic_generic_element.pxd +48 -0
- sage/rings/padics/padic_generic_element.pyx +4642 -0
- sage/rings/padics/padic_lattice_element.py +1342 -0
- sage/rings/padics/padic_printing.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/padic_printing.pxd +38 -0
- sage/rings/padics/padic_printing.pyx +1505 -0
- sage/rings/padics/padic_relaxed_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/padic_relaxed_element.pxd +56 -0
- sage/rings/padics/padic_relaxed_element.pyx +18 -0
- sage/rings/padics/padic_relaxed_errors.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/padic_relaxed_errors.pxd +11 -0
- sage/rings/padics/padic_relaxed_errors.pyx +71 -0
- sage/rings/padics/padic_template_element.pxi +1212 -0
- sage/rings/padics/padic_template_element_header.pxi +50 -0
- sage/rings/padics/padic_valuation.py +1423 -0
- sage/rings/padics/pow_computer_flint.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/pow_computer_flint.pxd +38 -0
- sage/rings/padics/pow_computer_flint.pyx +641 -0
- sage/rings/padics/pow_computer_relative.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/pow_computer_relative.pxd +29 -0
- sage/rings/padics/pow_computer_relative.pyx +415 -0
- sage/rings/padics/qadic_flint_CA.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/qadic_flint_CA.pxd +21 -0
- sage/rings/padics/qadic_flint_CA.pyx +130 -0
- sage/rings/padics/qadic_flint_CR.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/qadic_flint_CR.pxd +13 -0
- sage/rings/padics/qadic_flint_CR.pyx +172 -0
- sage/rings/padics/qadic_flint_FM.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/qadic_flint_FM.pxd +14 -0
- sage/rings/padics/qadic_flint_FM.pyx +111 -0
- sage/rings/padics/qadic_flint_FP.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/qadic_flint_FP.pxd +12 -0
- sage/rings/padics/qadic_flint_FP.pyx +165 -0
- sage/rings/padics/relative_extension_leaves.py +429 -0
- sage/rings/padics/relative_ramified_CA.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/relative_ramified_CA.pxd +9 -0
- sage/rings/padics/relative_ramified_CA.pyx +33 -0
- sage/rings/padics/relative_ramified_CR.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/relative_ramified_CR.pxd +8 -0
- sage/rings/padics/relative_ramified_CR.pyx +33 -0
- sage/rings/padics/relative_ramified_FM.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/relative_ramified_FM.pxd +9 -0
- sage/rings/padics/relative_ramified_FM.pyx +33 -0
- sage/rings/padics/relative_ramified_FP.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/padics/relative_ramified_FP.pxd +8 -0
- sage/rings/padics/relative_ramified_FP.pyx +33 -0
- sage/rings/padics/relaxed_template.pxi +4229 -0
- sage/rings/padics/relaxed_template_header.pxi +160 -0
- sage/rings/padics/tests.py +35 -0
- sage/rings/padics/tutorial.py +341 -0
- sage/rings/padics/unramified_extension_generic.py +335 -0
- sage/rings/padics/witt_vector.py +917 -0
- sage/rings/padics/witt_vector_ring.py +934 -0
- sage/rings/pari_ring.py +235 -0
- sage/rings/polynomial/all__sagemath_pari.py +1 -0
- sage/rings/polynomial/padics/all.py +1 -0
- sage/rings/polynomial/padics/polynomial_padic.py +360 -0
- sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py +1324 -0
- sage/rings/polynomial/padics/polynomial_padic_flat.py +72 -0
- sage/rings/power_series_pari.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/power_series_pari.pxd +6 -0
- sage/rings/power_series_pari.pyx +934 -0
- sage/rings/tate_algebra.py +1282 -0
- sage/rings/tate_algebra_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/tate_algebra_element.pxd +49 -0
- sage/rings/tate_algebra_element.pyx +3464 -0
- sage/rings/tate_algebra_ideal.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/tate_algebra_ideal.pxd +7 -0
- sage/rings/tate_algebra_ideal.pyx +1307 -0
- sage/rings/valuation/all.py +7 -0
- sage/rings/valuation/augmented_valuation.py +2118 -0
- sage/rings/valuation/developing_valuation.py +362 -0
- sage/rings/valuation/gauss_valuation.py +812 -0
- sage/rings/valuation/inductive_valuation.py +1686 -0
- sage/rings/valuation/limit_valuation.py +946 -0
- sage/rings/valuation/mapped_valuation.py +656 -0
- sage/rings/valuation/scaled_valuation.py +322 -0
- sage/rings/valuation/trivial_valuation.py +382 -0
- sage/rings/valuation/valuation.py +1119 -0
- sage/rings/valuation/valuation_space.py +1615 -0
- sage/rings/valuation/valuations_catalog.py +10 -0
- sage/rings/valuation/value_group.py +697 -0
- sage/schemes/all__sagemath_pari.py +1 -0
- sage/schemes/elliptic_curves/all__sagemath_pari.py +1 -0
- sage/schemes/elliptic_curves/descent_two_isogeny_pari.cpython-314-x86_64-linux-musl.so +0 -0
- sage/schemes/elliptic_curves/descent_two_isogeny_pari.pyx +46 -0
- sage_wheels/bin/gp +0 -0
- sage_wheels/bin/gp2c +0 -0
- sage_wheels/bin/gp2c-run +57 -0
- sage_wheels/bin/xeus-gp +0 -0
- sage_wheels/share/gp2c/func.dsc +18414 -0
|
@@ -0,0 +1,1438 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-pari
|
|
2
|
+
r"""
|
|
3
|
+
Interface to the PARI library
|
|
4
|
+
*****************************
|
|
5
|
+
|
|
6
|
+
AUTHORS:
|
|
7
|
+
|
|
8
|
+
- William Stein (2006-03-01): updated to work with PARI 2.2.12-beta
|
|
9
|
+
|
|
10
|
+
- William Stein (2006-03-06): added newtonpoly
|
|
11
|
+
|
|
12
|
+
- Justin Walker: contributed some of the function definitions
|
|
13
|
+
|
|
14
|
+
- Gonzalo Tornaria: improvements to conversions; much better error
|
|
15
|
+
handling.
|
|
16
|
+
|
|
17
|
+
- Robert Bradshaw, Jeroen Demeyer, William Stein (2010-08-15):
|
|
18
|
+
Upgrade to PARI 2.4.3 (:trac:`9343`)
|
|
19
|
+
|
|
20
|
+
- Jeroen Demeyer (2011-11-12): rewrite various conversion routines
|
|
21
|
+
(:trac:`11611`, :trac:`11854`, :trac:`11952`)
|
|
22
|
+
|
|
23
|
+
- Peter Bruin (2013-11-17): split off this file from gen.pyx
|
|
24
|
+
(:trac:`15185`)
|
|
25
|
+
|
|
26
|
+
- Jeroen Demeyer (2014-02-09): upgrade to PARI 2.7 (:trac:`15767`)
|
|
27
|
+
|
|
28
|
+
- Jeroen Demeyer (2014-09-19): upgrade to PARI 2.8 (:trac:`16997`)
|
|
29
|
+
|
|
30
|
+
- Jeroen Demeyer (2015-03-17): automatically generate methods from
|
|
31
|
+
``pari.desc`` (:trac:`17631` and :trac:`17860`)
|
|
32
|
+
|
|
33
|
+
- Luca De Feo (2016-09-06): Separate Sage-specific components from
|
|
34
|
+
generic C-interface in ``Pari`` (:trac:`20241`)
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
|
|
38
|
+
>>> import cypari2
|
|
39
|
+
>>> pari = cypari2.Pari()
|
|
40
|
+
>>> pari('5! + 10/x')
|
|
41
|
+
(120*x + 10)/x
|
|
42
|
+
>>> pari('intnum(x=0,13,sin(x)+sin(x^2) + x)')
|
|
43
|
+
85.6215190762676
|
|
44
|
+
>>> f = pari('x^3 - 1')
|
|
45
|
+
>>> v = f.factor(); v
|
|
46
|
+
[x - 1, 1; x^2 + x + 1, 1]
|
|
47
|
+
>>> v[0] # indexing is 0-based unlike in GP.
|
|
48
|
+
[x - 1, x^2 + x + 1]~
|
|
49
|
+
>>> v[1]
|
|
50
|
+
[1, 1]~
|
|
51
|
+
|
|
52
|
+
For most functions, you can call the function as method of ``pari``
|
|
53
|
+
or you can first create a :class:`Gen` object and then call the
|
|
54
|
+
function as method of that. In other words, the following two commands
|
|
55
|
+
do the same:
|
|
56
|
+
|
|
57
|
+
>>> pari('x^3 - 1').factor()
|
|
58
|
+
[x - 1, 1; x^2 + x + 1, 1]
|
|
59
|
+
>>> pari.factor('x^3 - 1')
|
|
60
|
+
[x - 1, 1; x^2 + x + 1, 1]
|
|
61
|
+
|
|
62
|
+
Arithmetic operations cause all arguments to be converted to PARI:
|
|
63
|
+
|
|
64
|
+
>>> type(pari(1) + 1)
|
|
65
|
+
<... 'cypari2.gen.Gen'>
|
|
66
|
+
>>> type(1 + pari(1))
|
|
67
|
+
<... 'cypari2.gen.Gen'>
|
|
68
|
+
|
|
69
|
+
Guide to real precision in the PARI interface
|
|
70
|
+
=============================================
|
|
71
|
+
|
|
72
|
+
In the PARI interface, "real precision" refers to the precision of real
|
|
73
|
+
numbers, so it is the floating-point precision. This is a non-trivial
|
|
74
|
+
issue, since there are various interfaces for different things.
|
|
75
|
+
|
|
76
|
+
Internal representation of floating-point numbers in PARI
|
|
77
|
+
---------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
Real numbers in PARI have a precision associated to them, which is
|
|
80
|
+
always a multiple of the CPU wordsize. So, it is a multiple of 32
|
|
81
|
+
of 64 bits. When converting a ``float`` from Python to PARI, the
|
|
82
|
+
``float`` has 53 bits of precision which is rounded up to 64 bits
|
|
83
|
+
in PARI:
|
|
84
|
+
|
|
85
|
+
>>> x = 1.0
|
|
86
|
+
>>> pari(x)
|
|
87
|
+
1.00000000000000
|
|
88
|
+
>>> pari(x).bitprecision()
|
|
89
|
+
64
|
|
90
|
+
|
|
91
|
+
It is possible to change the precision of a PARI object with the
|
|
92
|
+
:meth:`Gen.bitprecision` method:
|
|
93
|
+
|
|
94
|
+
>>> p = pari(1.0)
|
|
95
|
+
>>> p.bitprecision()
|
|
96
|
+
64
|
|
97
|
+
>>> p = p.bitprecision(100)
|
|
98
|
+
>>> p.bitprecision() # Rounded up to a multiple of the wordsize
|
|
99
|
+
128
|
|
100
|
+
|
|
101
|
+
Beware that these extra bits are just bogus. For example, this will not
|
|
102
|
+
magically give a more precise approximation of ``math.pi``:
|
|
103
|
+
|
|
104
|
+
>>> import math
|
|
105
|
+
>>> p = pari(math.pi)
|
|
106
|
+
>>> pari("Pi") - p
|
|
107
|
+
1.225148... E-16
|
|
108
|
+
>>> p = p.bitprecision(1000)
|
|
109
|
+
>>> pari("Pi") - p
|
|
110
|
+
1.225148... E-16
|
|
111
|
+
|
|
112
|
+
Another way to create numbers with many bits is to use a string with
|
|
113
|
+
many digits:
|
|
114
|
+
|
|
115
|
+
>>> p = pari("3.1415926535897932384626433832795028842")
|
|
116
|
+
>>> p.bitprecision()
|
|
117
|
+
128
|
|
118
|
+
|
|
119
|
+
.. _pari_output_precision:
|
|
120
|
+
|
|
121
|
+
Output precision for printing
|
|
122
|
+
-----------------------------
|
|
123
|
+
|
|
124
|
+
Even though PARI reals have a precision, not all significant bits are
|
|
125
|
+
printed by default. The maximum number of digits when printing a PARI
|
|
126
|
+
real can be set using the methods
|
|
127
|
+
:meth:`Pari.set_real_precision_bits` or
|
|
128
|
+
:meth:`Pari.set_real_precision`.
|
|
129
|
+
Note that this will also change the input precision for strings,
|
|
130
|
+
see :ref:`pari_input_precision`.
|
|
131
|
+
|
|
132
|
+
We create a very precise approximation of pi and see how it is printed
|
|
133
|
+
in PARI:
|
|
134
|
+
|
|
135
|
+
>>> pi = pari.pi(precision=1024)
|
|
136
|
+
|
|
137
|
+
The default precision is 15 digits:
|
|
138
|
+
|
|
139
|
+
>>> pi
|
|
140
|
+
3.14159265358979
|
|
141
|
+
|
|
142
|
+
With a different precision, we see more digits. Note that this does not
|
|
143
|
+
affect the object ``pi`` at all, it only affects how it is printed:
|
|
144
|
+
|
|
145
|
+
>>> _ = pari.set_real_precision(50)
|
|
146
|
+
>>> pi
|
|
147
|
+
3.1415926535897932384626433832795028841971693993751
|
|
148
|
+
|
|
149
|
+
Back to the default:
|
|
150
|
+
|
|
151
|
+
>>> _ = pari.set_real_precision(15)
|
|
152
|
+
>>> pi
|
|
153
|
+
3.14159265358979
|
|
154
|
+
|
|
155
|
+
.. _pari_input_precision:
|
|
156
|
+
|
|
157
|
+
Input precision for function calls
|
|
158
|
+
----------------------------------
|
|
159
|
+
|
|
160
|
+
When we talk about precision for PARI functions, we need to distinguish
|
|
161
|
+
three kinds of calls:
|
|
162
|
+
|
|
163
|
+
1. Using the string interface, for example ``pari("sin(1)")``.
|
|
164
|
+
|
|
165
|
+
2. Using the library interface with *exact* inputs, for example
|
|
166
|
+
``pari.sin(1)``.
|
|
167
|
+
|
|
168
|
+
3. Using the library interface with *inexact* inputs, for example
|
|
169
|
+
``pari.sin(1.0)``.
|
|
170
|
+
|
|
171
|
+
In the first case, the relevant precision is the one set by the methods
|
|
172
|
+
:meth:`Pari.set_real_precision_bits` or
|
|
173
|
+
:meth:`Pari.set_real_precision`:
|
|
174
|
+
|
|
175
|
+
>>> pari.set_real_precision_bits(150)
|
|
176
|
+
>>> pari("sin(1)")
|
|
177
|
+
0.841470984807896506652502321630298999622563061
|
|
178
|
+
>>> pari.set_real_precision_bits(53)
|
|
179
|
+
>>> pari("sin(1)")
|
|
180
|
+
0.841470984807897
|
|
181
|
+
|
|
182
|
+
In the second case, the precision can be given as the argument
|
|
183
|
+
``precision`` in the function call, with a default of 53 bits.
|
|
184
|
+
The real precision set by
|
|
185
|
+
:meth:`Pari.set_real_precision_bits` or
|
|
186
|
+
:meth:`Pari.set_real_precision` does not affect the call
|
|
187
|
+
(but it still affects printing).
|
|
188
|
+
|
|
189
|
+
As explained before, the precision increases to a multiple of the
|
|
190
|
+
wordsize (and you should not assume that the extra bits are meaningful):
|
|
191
|
+
|
|
192
|
+
>>> a = pari.sin(1, precision=180); a
|
|
193
|
+
0.841470984807897
|
|
194
|
+
>>> a.bitprecision()
|
|
195
|
+
192
|
|
196
|
+
>>> b = pari.sin(1, precision=40); b
|
|
197
|
+
0.841470984807897
|
|
198
|
+
>>> b.bitprecision()
|
|
199
|
+
64
|
|
200
|
+
>>> c = pari.sin(1); c
|
|
201
|
+
0.841470984807897
|
|
202
|
+
>>> c.bitprecision()
|
|
203
|
+
64
|
|
204
|
+
>>> pari.set_real_precision_bits(90)
|
|
205
|
+
>>> print(a); print(b); print(c)
|
|
206
|
+
0.841470984807896506652502322
|
|
207
|
+
0.8414709848078965067
|
|
208
|
+
0.8414709848078965067
|
|
209
|
+
|
|
210
|
+
In the third case, the precision is determined only by the inexact
|
|
211
|
+
inputs and the ``precision`` argument is ignored:
|
|
212
|
+
|
|
213
|
+
>>> pari.sin(1.0, precision=180).bitprecision()
|
|
214
|
+
64
|
|
215
|
+
>>> pari.sin(1.0, precision=40).bitprecision()
|
|
216
|
+
64
|
|
217
|
+
>>> pari.sin("1.0000000000000000000000000000000000000").bitprecision()
|
|
218
|
+
128
|
|
219
|
+
|
|
220
|
+
Tests:
|
|
221
|
+
|
|
222
|
+
Check that the documentation is generated correctly:
|
|
223
|
+
|
|
224
|
+
>>> from inspect import getdoc
|
|
225
|
+
>>> getdoc(pari.Pi)
|
|
226
|
+
'The constant :math:`\\pi` ...'
|
|
227
|
+
|
|
228
|
+
Check that output from PARI's print command is actually seen by
|
|
229
|
+
Python (:trac:`9636`):
|
|
230
|
+
|
|
231
|
+
>>> pari('print("test")')
|
|
232
|
+
test
|
|
233
|
+
|
|
234
|
+
Verify that ``nfroots()`` (which has an unusual signature with a
|
|
235
|
+
non-default argument following a default argument) works:
|
|
236
|
+
|
|
237
|
+
>>> pari.nfroots(x='x^4 - 1')
|
|
238
|
+
[-1, 1]...
|
|
239
|
+
>>> pari.nfroots(pari.nfinit('t^2 + 1'), "x^4 - 1")
|
|
240
|
+
[-1, 1, Mod(-t, t^2 + 1), Mod(t, t^2 + 1)]...
|
|
241
|
+
|
|
242
|
+
Reset default precision for the following tests:
|
|
243
|
+
|
|
244
|
+
>>> pari.set_real_precision_bits(53)
|
|
245
|
+
|
|
246
|
+
Test the trashcan mechanism (without the trashcan, this would cause
|
|
247
|
+
a stack overflow):
|
|
248
|
+
|
|
249
|
+
>>> pari.allocatemem(2**27, silent=True)
|
|
250
|
+
>>> L = [pari(i) for i in range(2**20)]
|
|
251
|
+
>>> x = pari.Pi()
|
|
252
|
+
>>> del L
|
|
253
|
+
>>> del x
|
|
254
|
+
|
|
255
|
+
Test that interrupts work properly:
|
|
256
|
+
|
|
257
|
+
>>> pari.allocatemem(8000000, 2**29)
|
|
258
|
+
PARI stack size set to 8000000 bytes, maximum size set to ...
|
|
259
|
+
>>> from cysignals.alarm import alarm, AlarmInterrupt
|
|
260
|
+
>>> for i in range(1, 11):
|
|
261
|
+
... try:
|
|
262
|
+
... alarm(i/11.0)
|
|
263
|
+
... pari.binomial(2**100, 2**22)
|
|
264
|
+
... except AlarmInterrupt:
|
|
265
|
+
... pass
|
|
266
|
+
|
|
267
|
+
Test that changing the stack size using ``default`` works properly:
|
|
268
|
+
|
|
269
|
+
>>> pari.default("parisizemax", 2**23)
|
|
270
|
+
>>> pari = cypari2.Pari() # clear stack
|
|
271
|
+
>>> a = pari(1)
|
|
272
|
+
>>> pari.default("parisizemax", 2**29)
|
|
273
|
+
>>> a + a
|
|
274
|
+
2
|
|
275
|
+
>>> pari.default("parisizemax")
|
|
276
|
+
536870912
|
|
277
|
+
"""
|
|
278
|
+
|
|
279
|
+
# ****************************************************************************
|
|
280
|
+
# This program is free software: you can redistribute it and/or modify
|
|
281
|
+
# it under the terms of the GNU General Public License as published by
|
|
282
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
283
|
+
# (at your option) any later version.
|
|
284
|
+
# https://www.gnu.org/licenses/
|
|
285
|
+
# ****************************************************************************
|
|
286
|
+
|
|
287
|
+
import sys
|
|
288
|
+
from libc.stdio cimport *
|
|
289
|
+
cimport cython
|
|
290
|
+
|
|
291
|
+
from cysignals.signals cimport sig_check, sig_on, sig_off, sig_error
|
|
292
|
+
|
|
293
|
+
from .string_utils cimport to_string, to_bytes
|
|
294
|
+
from .paridecl cimport *
|
|
295
|
+
from .paripriv cimport *
|
|
296
|
+
from .gen cimport Gen, objtogen
|
|
297
|
+
from .stack cimport (new_gen, new_gen_noclear, clear_stack,
|
|
298
|
+
set_pari_stack_size, before_resize, after_resize)
|
|
299
|
+
from .handle_error cimport _pari_init_error_handling
|
|
300
|
+
from .closure cimport _pari_init_closure
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
#################################################################
|
|
304
|
+
# conversions between various real precision models
|
|
305
|
+
#################################################################
|
|
306
|
+
|
|
307
|
+
def prec_bits_to_dec(long prec_in_bits):
|
|
308
|
+
r"""
|
|
309
|
+
Convert from precision expressed in bits to precision expressed in
|
|
310
|
+
decimal.
|
|
311
|
+
|
|
312
|
+
Examples:
|
|
313
|
+
|
|
314
|
+
>>> from cypari2.pari_instance import prec_bits_to_dec
|
|
315
|
+
>>> prec_bits_to_dec(53)
|
|
316
|
+
15
|
|
317
|
+
>>> [(32*n, prec_bits_to_dec(32*n)) for n in range(1, 9)]
|
|
318
|
+
[(32, 9), (64, 19), (96, 28), (128, 38), (160, 48), (192, 57), (224, 67), (256, 77)]
|
|
319
|
+
"""
|
|
320
|
+
return nbits2ndec(prec_in_bits)
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def prec_dec_to_bits(long prec_in_dec):
|
|
324
|
+
r"""
|
|
325
|
+
Convert from precision expressed in decimal to precision expressed
|
|
326
|
+
in bits.
|
|
327
|
+
|
|
328
|
+
Examples:
|
|
329
|
+
|
|
330
|
+
>>> from cypari2.pari_instance import prec_dec_to_bits
|
|
331
|
+
>>> prec_dec_to_bits(15)
|
|
332
|
+
50
|
|
333
|
+
>>> [(n, prec_dec_to_bits(n)) for n in range(10, 100, 10)]
|
|
334
|
+
[(10, 34), (20, 67), (30, 100), (40, 133), (50, 167), (60, 200), (70, 233), (80, 266), (90, 299)]
|
|
335
|
+
"""
|
|
336
|
+
cdef double log_10 = 3.32192809488736
|
|
337
|
+
return int(prec_in_dec*log_10 + 1.0) # Add one to round up
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
cpdef long prec_words_to_bits(long prec_in_words) noexcept:
|
|
341
|
+
r"""
|
|
342
|
+
Deprecated internal function. Used (incorrectly) in sagemath < 10.5.
|
|
343
|
+
|
|
344
|
+
Convert from pari real precision expressed in words to precision
|
|
345
|
+
expressed in bits. Note: this adjusts for the two codewords of a
|
|
346
|
+
pari real, and is architecture-dependent.
|
|
347
|
+
|
|
348
|
+
Examples:
|
|
349
|
+
|
|
350
|
+
>>> from cypari2.pari_instance import prec_words_to_bits
|
|
351
|
+
>>> import sys
|
|
352
|
+
>>> import warnings
|
|
353
|
+
>>> warnings.simplefilter("ignore")
|
|
354
|
+
>>> bitness = '64' if sys.maxsize > (1 << 32) else '32'
|
|
355
|
+
>>> prec_words_to_bits(10) == (256 if bitness == '32' else 512)
|
|
356
|
+
True
|
|
357
|
+
|
|
358
|
+
>>> ans32 = [(3, 32), (4, 64), (5, 96), (6, 128), (7, 160), (8, 192), (9, 224)]
|
|
359
|
+
>>> ans64 = [(3, 64), (4, 128), (5, 192), (6, 256), (7, 320), (8, 384), (9, 448)] # 64-bit
|
|
360
|
+
>>> [(n, prec_words_to_bits(n)) for n in range(3, 10)] == (ans32 if bitness == '32' else ans64)
|
|
361
|
+
True
|
|
362
|
+
"""
|
|
363
|
+
from warnings import warn
|
|
364
|
+
warn("'prec_words_to_bits` in cypari2 is internal and deprecated",
|
|
365
|
+
DeprecationWarning)
|
|
366
|
+
# see user's guide to the pari library, page 10
|
|
367
|
+
return (prec_in_words - 2) * BITS_IN_LONG
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
cpdef long default_bitprec() noexcept:
|
|
371
|
+
r"""
|
|
372
|
+
Return the default precision in bits.
|
|
373
|
+
|
|
374
|
+
Examples:
|
|
375
|
+
|
|
376
|
+
>>> from cypari2.pari_instance import default_bitprec
|
|
377
|
+
>>> default_bitprec()
|
|
378
|
+
64
|
|
379
|
+
"""
|
|
380
|
+
return DEFAULT_BITPREC
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def prec_words_to_dec(long prec_in_words):
|
|
384
|
+
r"""
|
|
385
|
+
Deprecated internal function.
|
|
386
|
+
|
|
387
|
+
Convert from precision expressed in words to precision expressed in
|
|
388
|
+
decimal. Note: this adjusts for the two codewords of a pari real,
|
|
389
|
+
and is architecture-dependent.
|
|
390
|
+
|
|
391
|
+
Examples:
|
|
392
|
+
|
|
393
|
+
>>> from cypari2.pari_instance import prec_words_to_dec
|
|
394
|
+
>>> import sys
|
|
395
|
+
>>> import warnings
|
|
396
|
+
>>> warnings.simplefilter("ignore")
|
|
397
|
+
>>> bitness = '64' if sys.maxsize > (1 << 32) else '32'
|
|
398
|
+
>>> prec_words_to_dec(5) == (28 if bitness == '32' else 57)
|
|
399
|
+
True
|
|
400
|
+
|
|
401
|
+
>>> ans32 = [(3, 9), (4, 19), (5, 28), (6, 38), (7, 48), (8, 57), (9, 67)]
|
|
402
|
+
>>> ans64 = [(3, 19), (4, 38), (5, 57), (6, 77), (7, 96), (8, 115), (9, 134)]
|
|
403
|
+
>>> [(n, prec_words_to_dec(n)) for n in range(3, 10)] == (ans32 if bitness == '32' else ans64)
|
|
404
|
+
True
|
|
405
|
+
"""
|
|
406
|
+
from warnings import warn
|
|
407
|
+
warn("'prec_words_to_dec` in cypari2 is internal and deprecated",
|
|
408
|
+
DeprecationWarning)
|
|
409
|
+
return prec_bits_to_dec(prec_words_to_bits(prec_in_words))
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
# Callbacks from PARI to print stuff using sys.stdout.write() instead
|
|
413
|
+
# of C library functions like puts().
|
|
414
|
+
cdef PariOUT python_pariOut
|
|
415
|
+
|
|
416
|
+
cdef void python_putchar(char c) noexcept:
|
|
417
|
+
cdef char s[2]
|
|
418
|
+
s[0] = c
|
|
419
|
+
s[1] = 0
|
|
420
|
+
try:
|
|
421
|
+
# avoid string conversion if possible
|
|
422
|
+
sys.stdout.buffer.write(s)
|
|
423
|
+
except AttributeError:
|
|
424
|
+
sys.stdout.write(to_string(s))
|
|
425
|
+
# Let PARI think the last character was a newline,
|
|
426
|
+
# so it doesn't print one when an error occurs.
|
|
427
|
+
pari_set_last_newline(1)
|
|
428
|
+
|
|
429
|
+
cdef void python_puts(const char* s) noexcept:
|
|
430
|
+
try:
|
|
431
|
+
# avoid string conversion if possible
|
|
432
|
+
sys.stdout.buffer.write(s)
|
|
433
|
+
except AttributeError:
|
|
434
|
+
sys.stdout.write(to_string(s))
|
|
435
|
+
pari_set_last_newline(1)
|
|
436
|
+
|
|
437
|
+
cdef void python_flush() noexcept:
|
|
438
|
+
sys.stdout.flush()
|
|
439
|
+
|
|
440
|
+
include 'auto_instance.pxi'
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
cdef class Pari(Pari_auto):
|
|
444
|
+
def __cinit__(self):
|
|
445
|
+
r"""
|
|
446
|
+
(Re)-initialize the PARI library.
|
|
447
|
+
|
|
448
|
+
Tests:
|
|
449
|
+
|
|
450
|
+
>>> from cypari2.pari_instance import Pari
|
|
451
|
+
>>> Pari.__new__(Pari)
|
|
452
|
+
Interface to the PARI C library
|
|
453
|
+
>>> pari = Pari()
|
|
454
|
+
>>> pari("print('hello')")
|
|
455
|
+
"""
|
|
456
|
+
# PARI is already initialized, nothing to do...
|
|
457
|
+
if avma:
|
|
458
|
+
return
|
|
459
|
+
|
|
460
|
+
# Take 1MB as minimal stack. Use maxprime=0, which PARI will
|
|
461
|
+
# internally increase to some small value like 65537.
|
|
462
|
+
# (see function initprimes in src/language/forprime.c)
|
|
463
|
+
pari_init_opts(1000000 * sizeof(long), 0, INIT_DFTm)
|
|
464
|
+
after_resize()
|
|
465
|
+
|
|
466
|
+
# Disable PARI's stack overflow checking which is incompatible
|
|
467
|
+
# with multi-threading.
|
|
468
|
+
pari_stackcheck_init(NULL)
|
|
469
|
+
|
|
470
|
+
_pari_init_error_handling()
|
|
471
|
+
_pari_init_closure()
|
|
472
|
+
|
|
473
|
+
# Set printing functions
|
|
474
|
+
global pariOut, pariErr
|
|
475
|
+
|
|
476
|
+
pariOut = &python_pariOut
|
|
477
|
+
pariOut.putch = python_putchar
|
|
478
|
+
pariOut.puts = python_puts
|
|
479
|
+
pariOut.flush = python_flush
|
|
480
|
+
|
|
481
|
+
# Use 53 bits as default precision
|
|
482
|
+
self.set_real_precision_bits(53)
|
|
483
|
+
|
|
484
|
+
# Disable pretty-printing
|
|
485
|
+
GP_DATA.fmt.prettyp = 0
|
|
486
|
+
|
|
487
|
+
# This causes PARI/GP to use output independent of the terminal
|
|
488
|
+
# (which is what we want for the PARI library interface).
|
|
489
|
+
GP_DATA.flags = gpd_TEST
|
|
490
|
+
|
|
491
|
+
# Ensure that Galois groups are represented in a sane way,
|
|
492
|
+
# see the polgalois section of the PARI users manual.
|
|
493
|
+
global new_galois_format
|
|
494
|
+
new_galois_format = 1
|
|
495
|
+
|
|
496
|
+
# By default, factor() should prove primality of returned
|
|
497
|
+
# factors. This not only influences the factor() function, but
|
|
498
|
+
# also many functions indirectly using factoring.
|
|
499
|
+
global factor_proven
|
|
500
|
+
factor_proven = 1
|
|
501
|
+
|
|
502
|
+
# Monkey-patch default(parisize) and default(parisizemax)
|
|
503
|
+
ep = pari_is_default("parisize")
|
|
504
|
+
if ep:
|
|
505
|
+
ep.value = <void*>patched_parisize
|
|
506
|
+
ep = pari_is_default("parisizemax")
|
|
507
|
+
if ep:
|
|
508
|
+
ep.value = <void*>patched_parisizemax
|
|
509
|
+
|
|
510
|
+
def __init__(self, size_t size=8000000, size_t sizemax=0, unsigned long maxprime=500000):
|
|
511
|
+
"""
|
|
512
|
+
(Re)-Initialize the PARI system.
|
|
513
|
+
|
|
514
|
+
INPUT:
|
|
515
|
+
|
|
516
|
+
- ``size`` -- (default: 8000000) the number of bytes for the
|
|
517
|
+
initial PARI stack (see notes below)
|
|
518
|
+
|
|
519
|
+
- ``sizemax`` -- the maximal number of bytes for the
|
|
520
|
+
dynamically increasing PARI stack. The default ``0`` means
|
|
521
|
+
to use the same value as ``size`` (see notes below)
|
|
522
|
+
|
|
523
|
+
- ``maxprime`` -- (default: 500000) limit on the primes in the
|
|
524
|
+
precomputed prime number table which is used for sieving
|
|
525
|
+
algorithms
|
|
526
|
+
|
|
527
|
+
When the PARI system is already initialized, the PARI stack is only
|
|
528
|
+
grown if ``size`` is greater than the current stack, and the table
|
|
529
|
+
of primes is only computed if ``maxprime`` is larger than the current
|
|
530
|
+
bound.
|
|
531
|
+
|
|
532
|
+
Examples:
|
|
533
|
+
|
|
534
|
+
>>> from cypari2.pari_instance import Pari
|
|
535
|
+
>>> pari = Pari()
|
|
536
|
+
>>> pari2 = Pari(10**7)
|
|
537
|
+
>>> pari2
|
|
538
|
+
Interface to the PARI C library
|
|
539
|
+
>>> pari2 is pari
|
|
540
|
+
False
|
|
541
|
+
>>> pari2.PARI_ZERO == pari.PARI_ZERO
|
|
542
|
+
True
|
|
543
|
+
>>> pari2 = Pari(10**6)
|
|
544
|
+
>>> pari.stacksize(), pari2.stacksize()
|
|
545
|
+
(10000000, 10000000)
|
|
546
|
+
|
|
547
|
+
>>> Pari().default("primelimit")
|
|
548
|
+
500000
|
|
549
|
+
>>> Pari(maxprime=20000).default("primelimit")
|
|
550
|
+
20000
|
|
551
|
+
|
|
552
|
+
For more information about how precision works in the PARI
|
|
553
|
+
interface, see :mod:`cypari2.pari_instance`.
|
|
554
|
+
|
|
555
|
+
.. NOTE::
|
|
556
|
+
|
|
557
|
+
PARI has a "real" stack size (``size``) and a "virtual"
|
|
558
|
+
stack size (``sizemax``). The idea is that the real stack
|
|
559
|
+
will be used if possible, but that the stack might be
|
|
560
|
+
increased up to ``sizemax`` bytes. Therefore, it is not a
|
|
561
|
+
problem to set ``sizemax`` to a large value. On the other
|
|
562
|
+
hand, it also makes no sense to set this to a value larger
|
|
563
|
+
than what your system can handle.
|
|
564
|
+
|
|
565
|
+
.. NOTE::
|
|
566
|
+
|
|
567
|
+
Normally, all results from PARI computations end up on the
|
|
568
|
+
PARI stack. CyPari2 tries to keep everything on the PARI
|
|
569
|
+
stack. However, if over half of the PARI stack space is used,
|
|
570
|
+
all live objects on the PARI stack are copied to the PARI
|
|
571
|
+
heap (they become so-called clones).
|
|
572
|
+
"""
|
|
573
|
+
# Increase (but don't decrease) size and sizemax to the
|
|
574
|
+
# requested value
|
|
575
|
+
size = max(size, pari_mainstack.rsize)
|
|
576
|
+
sizemax = max(max(size, pari_mainstack.vsize), sizemax)
|
|
577
|
+
set_pari_stack_size(size, sizemax)
|
|
578
|
+
|
|
579
|
+
# Increase the table of primes if needed
|
|
580
|
+
GP_DATA.primelimit = maxprime
|
|
581
|
+
self.init_primes(maxprime)
|
|
582
|
+
|
|
583
|
+
# Initialize some constants
|
|
584
|
+
self.PARI_ZERO = new_gen_noclear(gen_0)
|
|
585
|
+
self.PARI_ONE = new_gen_noclear(gen_1)
|
|
586
|
+
self.PARI_TWO = new_gen_noclear(gen_2)
|
|
587
|
+
|
|
588
|
+
IF HAVE_PLOT_SVG:
|
|
589
|
+
# If we are running under IPython, setup for displaying SVG plots.
|
|
590
|
+
if "IPython" in sys.modules:
|
|
591
|
+
pari_set_plot_engine(get_plot_ipython)
|
|
592
|
+
|
|
593
|
+
def debugstack(self):
|
|
594
|
+
r"""
|
|
595
|
+
Print the internal PARI variables ``top`` (top of stack), ``avma``
|
|
596
|
+
(available memory address, think of this as the stack pointer),
|
|
597
|
+
``bot`` (bottom of stack).
|
|
598
|
+
"""
|
|
599
|
+
# We deliberately use low-level functions to minimize the
|
|
600
|
+
# chances that something goes wrong here (for example, if we
|
|
601
|
+
# are out of memory).
|
|
602
|
+
printf("top = %p\navma = %p\nbot = %p\nsize = %lu\n",
|
|
603
|
+
<void*>pari_mainstack.top,
|
|
604
|
+
<void*>avma,
|
|
605
|
+
<void*>pari_mainstack.bot,
|
|
606
|
+
<unsigned long>pari_mainstack.rsize)
|
|
607
|
+
fflush(stdout)
|
|
608
|
+
|
|
609
|
+
def __repr__(self):
|
|
610
|
+
return "Interface to the PARI C library"
|
|
611
|
+
|
|
612
|
+
def __hash__(self):
|
|
613
|
+
return 907629390
|
|
614
|
+
|
|
615
|
+
def set_debug_level(self, level):
|
|
616
|
+
"""
|
|
617
|
+
Set the debug PARI C library variable.
|
|
618
|
+
"""
|
|
619
|
+
self.default('debug', int(level))
|
|
620
|
+
|
|
621
|
+
def get_debug_level(self):
|
|
622
|
+
"""
|
|
623
|
+
Set the debug PARI C library variable.
|
|
624
|
+
"""
|
|
625
|
+
return int(self.default('debug'))
|
|
626
|
+
|
|
627
|
+
def set_real_precision_bits(self, n):
|
|
628
|
+
"""
|
|
629
|
+
Sets the PARI default real precision in bits.
|
|
630
|
+
|
|
631
|
+
This is used both for creation of new objects from strings and
|
|
632
|
+
for printing. It determines the number of digits in which real
|
|
633
|
+
numbers numbers are printed. It also determines the precision
|
|
634
|
+
of objects created by parsing strings (e.g. pari('1.2')), which
|
|
635
|
+
is *not* the normal way of creating new PARI objects using
|
|
636
|
+
cypari. It has *no* effect on the precision of computations
|
|
637
|
+
within the PARI library.
|
|
638
|
+
|
|
639
|
+
.. seealso:: :meth:`set_real_precision` to set the
|
|
640
|
+
precision in decimal digits.
|
|
641
|
+
|
|
642
|
+
Examples:
|
|
643
|
+
|
|
644
|
+
>>> import cypari2
|
|
645
|
+
>>> pari = cypari2.Pari()
|
|
646
|
+
>>> pari.set_real_precision_bits(200)
|
|
647
|
+
>>> pari('1.2')
|
|
648
|
+
1.20000000000000000000000000000000000000000000000000000000000
|
|
649
|
+
>>> pari.set_real_precision_bits(53)
|
|
650
|
+
"""
|
|
651
|
+
cdef bytes strn = to_bytes(n)
|
|
652
|
+
sig_on()
|
|
653
|
+
sd_realbitprecision(strn, d_SILENT)
|
|
654
|
+
clear_stack()
|
|
655
|
+
|
|
656
|
+
def get_real_precision_bits(self):
|
|
657
|
+
"""
|
|
658
|
+
Return the current PARI default real precision in bits.
|
|
659
|
+
|
|
660
|
+
This is used both for creation of new objects from strings and
|
|
661
|
+
for printing. It determines the number of digits in which real
|
|
662
|
+
numbers numbers are printed. It also determines the precision
|
|
663
|
+
of objects created by parsing strings (e.g. pari('1.2')), which
|
|
664
|
+
is *not* the normal way of creating new PARI objects using
|
|
665
|
+
cypari. It has *no* effect on the precision of computations
|
|
666
|
+
within the PARI library.
|
|
667
|
+
|
|
668
|
+
.. seealso:: :meth:`get_real_precision` to get the
|
|
669
|
+
precision in decimal digits.
|
|
670
|
+
|
|
671
|
+
Examples:
|
|
672
|
+
|
|
673
|
+
>>> import cypari2
|
|
674
|
+
>>> pari = cypari2.Pari()
|
|
675
|
+
>>> pari.get_real_precision_bits()
|
|
676
|
+
53
|
|
677
|
+
"""
|
|
678
|
+
sig_on()
|
|
679
|
+
r = itos(sd_realbitprecision(NULL, d_RETURN))
|
|
680
|
+
clear_stack()
|
|
681
|
+
return r
|
|
682
|
+
|
|
683
|
+
def set_real_precision(self, long n):
|
|
684
|
+
"""
|
|
685
|
+
Sets the PARI default real precision in decimal digits.
|
|
686
|
+
|
|
687
|
+
This is used both for creation of new objects from strings and for
|
|
688
|
+
printing. It is the number of digits *IN DECIMAL* in which real
|
|
689
|
+
numbers are printed. It also determines the precision of objects
|
|
690
|
+
created by parsing strings (e.g. pari('1.2')), which is *not* the
|
|
691
|
+
normal way of creating new PARI objects in CyPari2. It has *no*
|
|
692
|
+
effect on the precision of computations within the pari library.
|
|
693
|
+
|
|
694
|
+
Returns the previous PARI real precision.
|
|
695
|
+
|
|
696
|
+
.. seealso:: :meth:`set_real_precision_bits` to set the
|
|
697
|
+
precision in bits.
|
|
698
|
+
|
|
699
|
+
Examples:
|
|
700
|
+
|
|
701
|
+
>>> import cypari2
|
|
702
|
+
>>> pari = cypari2.Pari()
|
|
703
|
+
>>> pari.set_real_precision(60)
|
|
704
|
+
15
|
|
705
|
+
>>> pari('1.2')
|
|
706
|
+
1.20000000000000000000000000000000000000000000000000000000000
|
|
707
|
+
>>> pari.set_real_precision(15)
|
|
708
|
+
60
|
|
709
|
+
"""
|
|
710
|
+
old = self.get_real_precision()
|
|
711
|
+
self.set_real_precision_bits(prec_dec_to_bits(n))
|
|
712
|
+
return old
|
|
713
|
+
|
|
714
|
+
def get_real_precision(self):
|
|
715
|
+
"""
|
|
716
|
+
Returns the current PARI default real precision.
|
|
717
|
+
|
|
718
|
+
This is used both for creation of new objects from strings and for
|
|
719
|
+
printing. It is the number of digits *IN DECIMAL* in which real
|
|
720
|
+
numbers are printed. It also determines the precision of objects
|
|
721
|
+
created by parsing strings (e.g. pari('1.2')), which is *not* the
|
|
722
|
+
normal way of creating new PARI objects in CyPari2. It has *no*
|
|
723
|
+
effect on the precision of computations within the pari library.
|
|
724
|
+
|
|
725
|
+
.. seealso:: :meth:`get_real_precision_bits` to get the
|
|
726
|
+
precision in bits.
|
|
727
|
+
|
|
728
|
+
Examples:
|
|
729
|
+
|
|
730
|
+
>>> import cypari2
|
|
731
|
+
>>> pari = cypari2.Pari()
|
|
732
|
+
>>> pari.get_real_precision()
|
|
733
|
+
15
|
|
734
|
+
"""
|
|
735
|
+
cdef long r
|
|
736
|
+
sig_on()
|
|
737
|
+
r = itos(sd_realprecision(NULL, d_RETURN))
|
|
738
|
+
sig_off()
|
|
739
|
+
return r
|
|
740
|
+
|
|
741
|
+
def set_series_precision(self, long n):
|
|
742
|
+
global precdl
|
|
743
|
+
precdl = n
|
|
744
|
+
|
|
745
|
+
def get_series_precision(self):
|
|
746
|
+
return precdl
|
|
747
|
+
|
|
748
|
+
def version(self):
|
|
749
|
+
"""
|
|
750
|
+
Return the PARI version as tuple with 3 or 4 components:
|
|
751
|
+
(major, minor, patch) or (major, minor, patch, VCSversion).
|
|
752
|
+
|
|
753
|
+
Examples:
|
|
754
|
+
|
|
755
|
+
>>> from cypari2 import Pari
|
|
756
|
+
>>> Pari().version() >= (2, 9, 0)
|
|
757
|
+
True
|
|
758
|
+
"""
|
|
759
|
+
return tuple(Pari_auto.version(self))
|
|
760
|
+
|
|
761
|
+
def complex(self, re, im):
|
|
762
|
+
"""
|
|
763
|
+
Create a new complex number, initialized from re and im.
|
|
764
|
+
"""
|
|
765
|
+
cdef Gen t0 = objtogen(re)
|
|
766
|
+
cdef Gen t1 = objtogen(im)
|
|
767
|
+
sig_on()
|
|
768
|
+
return new_gen(mkcomplex(t0.g, t1.g))
|
|
769
|
+
|
|
770
|
+
def __call__(self, s):
|
|
771
|
+
"""
|
|
772
|
+
Create the PARI object obtained by evaluating s using PARI.
|
|
773
|
+
|
|
774
|
+
Examples:
|
|
775
|
+
|
|
776
|
+
>>> import cypari2
|
|
777
|
+
>>> pari = cypari2.Pari()
|
|
778
|
+
>>> pari(0)
|
|
779
|
+
0
|
|
780
|
+
>>> pari([2,3,5])
|
|
781
|
+
[2, 3, 5]
|
|
782
|
+
|
|
783
|
+
>>> a = pari(1); a, a.type()
|
|
784
|
+
(1, 't_INT')
|
|
785
|
+
>>> a = pari('1/2'); a, a.type()
|
|
786
|
+
(1/2, 't_FRAC')
|
|
787
|
+
|
|
788
|
+
>>> s = pari(u'"éàèç"')
|
|
789
|
+
>>> s.type()
|
|
790
|
+
't_STR'
|
|
791
|
+
|
|
792
|
+
Some commands are just executed without returning a value:
|
|
793
|
+
|
|
794
|
+
>>> pari("dummy = 0; kill(dummy)")
|
|
795
|
+
>>> print(pari("dummy = 0; kill(dummy)"))
|
|
796
|
+
None
|
|
797
|
+
|
|
798
|
+
See :func:`objtogen` for more examples.
|
|
799
|
+
"""
|
|
800
|
+
cdef Gen g = objtogen(s)
|
|
801
|
+
if g.g is gnil:
|
|
802
|
+
return None
|
|
803
|
+
return g
|
|
804
|
+
|
|
805
|
+
cpdef Gen zero(self):
|
|
806
|
+
"""
|
|
807
|
+
Examples:
|
|
808
|
+
|
|
809
|
+
>>> import cypari2
|
|
810
|
+
>>> pari = cypari2.Pari()
|
|
811
|
+
>>> pari.zero()
|
|
812
|
+
0
|
|
813
|
+
"""
|
|
814
|
+
return self.PARI_ZERO
|
|
815
|
+
|
|
816
|
+
cpdef Gen one(self):
|
|
817
|
+
"""
|
|
818
|
+
Examples:
|
|
819
|
+
|
|
820
|
+
>>> import cypari2
|
|
821
|
+
>>> pari = cypari2.Pari()
|
|
822
|
+
>>> pari.one()
|
|
823
|
+
1
|
|
824
|
+
"""
|
|
825
|
+
return self.PARI_ONE
|
|
826
|
+
|
|
827
|
+
def new_with_bits_prec(self, s, long precision):
|
|
828
|
+
r"""
|
|
829
|
+
pari.new_with_bits_prec(self, s, precision) creates s as a PARI
|
|
830
|
+
Gen with (at most) precision *bits* of precision.
|
|
831
|
+
"""
|
|
832
|
+
# TODO: deprecate
|
|
833
|
+
cdef unsigned long old_prec
|
|
834
|
+
old_prec = GP_DATA.fmt.sigd
|
|
835
|
+
precision = prec_bits_to_dec(precision)
|
|
836
|
+
if not precision:
|
|
837
|
+
precision = old_prec
|
|
838
|
+
self.set_real_precision(precision)
|
|
839
|
+
x = objtogen(s)
|
|
840
|
+
self.set_real_precision(old_prec)
|
|
841
|
+
return x
|
|
842
|
+
|
|
843
|
+
############################################################
|
|
844
|
+
# Initialization
|
|
845
|
+
############################################################
|
|
846
|
+
|
|
847
|
+
def stacksize(self):
|
|
848
|
+
r"""
|
|
849
|
+
Return the current size of the PARI stack, which is `10^6`
|
|
850
|
+
by default. However, the stack size is automatically
|
|
851
|
+
increased when needed up to the given maximum stack size.
|
|
852
|
+
|
|
853
|
+
.. SEEALSO::
|
|
854
|
+
|
|
855
|
+
- :meth:`stacksizemax` to get the maximum stack size
|
|
856
|
+
- :meth:`allocatemem` to change the current or maximum
|
|
857
|
+
stack size
|
|
858
|
+
|
|
859
|
+
Examples:
|
|
860
|
+
|
|
861
|
+
>>> import cypari2
|
|
862
|
+
>>> pari = cypari2.Pari()
|
|
863
|
+
>>> pari.stacksize()
|
|
864
|
+
8000000
|
|
865
|
+
>>> pari.allocatemem(2**18, silent=True)
|
|
866
|
+
>>> pari.stacksize()
|
|
867
|
+
262144
|
|
868
|
+
"""
|
|
869
|
+
return pari_mainstack.size
|
|
870
|
+
|
|
871
|
+
def stacksizemax(self):
|
|
872
|
+
r"""
|
|
873
|
+
Return the maximum size of the PARI stack, which is determined
|
|
874
|
+
at startup in terms of available memory. Usually, the PARI
|
|
875
|
+
stack size is (much) smaller than this maximum but the stack
|
|
876
|
+
will be increased up to this maximum if needed.
|
|
877
|
+
|
|
878
|
+
.. SEEALSO::
|
|
879
|
+
|
|
880
|
+
- :meth:`stacksize` to get the current stack size
|
|
881
|
+
- :meth:`allocatemem` to change the current or maximum
|
|
882
|
+
stack size
|
|
883
|
+
|
|
884
|
+
Examples:
|
|
885
|
+
|
|
886
|
+
>>> import cypari2
|
|
887
|
+
>>> pari = cypari2.Pari()
|
|
888
|
+
>>> pari.allocatemem(2**18, 2**26, silent=True)
|
|
889
|
+
>>> pari.stacksizemax()
|
|
890
|
+
67108864
|
|
891
|
+
"""
|
|
892
|
+
return pari_mainstack.vsize
|
|
893
|
+
|
|
894
|
+
def allocatemem(self, size_t s=0, size_t sizemax=0, *, silent=False):
|
|
895
|
+
r"""
|
|
896
|
+
Change the PARI stack space to the given size ``s`` (or double
|
|
897
|
+
the current size if ``s`` is `0`) and change the maximum stack
|
|
898
|
+
size to ``sizemax``.
|
|
899
|
+
|
|
900
|
+
PARI tries to use only its current stack (the size which is set
|
|
901
|
+
by ``s``), but it will increase its stack if needed up to the
|
|
902
|
+
maximum size which is set by ``sizemax``.
|
|
903
|
+
|
|
904
|
+
The PARI stack is never automatically shrunk. You can use the
|
|
905
|
+
command ``pari.allocatemem(10^6)`` to reset the size to `10^6`,
|
|
906
|
+
which is the default size at startup. Note that the results of
|
|
907
|
+
computations using cypari are copied to the Python heap, so they
|
|
908
|
+
take up no space in the PARI stack. The PARI stack is cleared
|
|
909
|
+
after every computation.
|
|
910
|
+
|
|
911
|
+
It does no real harm to set this to a small value as the PARI
|
|
912
|
+
stack will be automatically enlarged when we run out of memory.
|
|
913
|
+
|
|
914
|
+
INPUT:
|
|
915
|
+
|
|
916
|
+
- ``s`` - an integer (default: 0). A non-zero argument is the
|
|
917
|
+
size in bytes of the new PARI stack. If `s` is zero, double
|
|
918
|
+
the current stack size.
|
|
919
|
+
|
|
920
|
+
- ``sizemax`` - an integer (default: 0). A non-zero argument
|
|
921
|
+
is the maximum size in bytes of the PARI stack. If
|
|
922
|
+
``sizemax`` is 0, the maximum of the current maximum and
|
|
923
|
+
``s`` is taken.
|
|
924
|
+
|
|
925
|
+
Examples:
|
|
926
|
+
|
|
927
|
+
>>> import cypari2
|
|
928
|
+
>>> pari = cypari2.Pari()
|
|
929
|
+
>>> pari.allocatemem(10**7, 10**7)
|
|
930
|
+
PARI stack size set to 10000000 bytes, maximum size set to 100...
|
|
931
|
+
>>> pari.allocatemem() # Double the current size
|
|
932
|
+
PARI stack size set to 20000000 bytes, maximum size set to 200...
|
|
933
|
+
>>> pari.stacksize()
|
|
934
|
+
20000000
|
|
935
|
+
>>> pari.allocatemem(10**6)
|
|
936
|
+
PARI stack size set to 1000000 bytes, maximum size set to 200...
|
|
937
|
+
|
|
938
|
+
The following computation will automatically increase the PARI
|
|
939
|
+
stack size:
|
|
940
|
+
|
|
941
|
+
>>> a = pari('2^100000000')
|
|
942
|
+
|
|
943
|
+
``a`` is now a Python variable on the Python heap and does not
|
|
944
|
+
take up any space on the PARI stack. The PARI stack is still
|
|
945
|
+
large because of the computation of ``a``:
|
|
946
|
+
|
|
947
|
+
>>> pari.stacksize() > 10**6
|
|
948
|
+
True
|
|
949
|
+
|
|
950
|
+
Setting a small maximum size makes this fail:
|
|
951
|
+
|
|
952
|
+
>>> pari.allocatemem(10**6, 2**22)
|
|
953
|
+
PARI stack size set to 1000000 bytes, maximum size set to 4194304
|
|
954
|
+
>>> a = pari('2^100000000')
|
|
955
|
+
Traceback (most recent call last):
|
|
956
|
+
...
|
|
957
|
+
PariError: _^s: the PARI stack overflows (current size: 1000000; maximum size: 4194304)
|
|
958
|
+
You can use pari.allocatemem() to change the stack size and try again
|
|
959
|
+
|
|
960
|
+
Tests:
|
|
961
|
+
|
|
962
|
+
Do the same without using the string interface and starting
|
|
963
|
+
from a very small stack size:
|
|
964
|
+
|
|
965
|
+
>>> pari.allocatemem(1, 2**26)
|
|
966
|
+
PARI stack size set to 1024 bytes, maximum size set to 67108864
|
|
967
|
+
>>> a = pari(2)**100000000
|
|
968
|
+
>>> pari.stacksize() > 10**6
|
|
969
|
+
True
|
|
970
|
+
|
|
971
|
+
We do not allow ``sizemax`` less than ``s``:
|
|
972
|
+
|
|
973
|
+
>>> pari.allocatemem(10**7, 10**6)
|
|
974
|
+
Traceback (most recent call last):
|
|
975
|
+
...
|
|
976
|
+
ValueError: the maximum size (10000000) should be at least the stack size (1000000)
|
|
977
|
+
"""
|
|
978
|
+
if s == 0:
|
|
979
|
+
s = pari_mainstack.size * 2
|
|
980
|
+
if s < pari_mainstack.size:
|
|
981
|
+
raise OverflowError("cannot double stack size")
|
|
982
|
+
elif s < 1024:
|
|
983
|
+
s = 1024 # arbitrary minimum size
|
|
984
|
+
if sizemax == 0:
|
|
985
|
+
# For the default sizemax, use the maximum of current
|
|
986
|
+
# sizemax and the given size s.
|
|
987
|
+
if pari_mainstack.vsize > s:
|
|
988
|
+
sizemax = pari_mainstack.vsize
|
|
989
|
+
else:
|
|
990
|
+
sizemax = s
|
|
991
|
+
elif sizemax < s:
|
|
992
|
+
raise ValueError("the maximum size ({}) should be at least the stack size ({})".format(s, sizemax))
|
|
993
|
+
set_pari_stack_size(s, sizemax)
|
|
994
|
+
if not silent:
|
|
995
|
+
print("PARI stack size set to {} bytes, maximum size set to {}".
|
|
996
|
+
format(self.stacksize(), self.stacksizemax()))
|
|
997
|
+
|
|
998
|
+
@staticmethod
|
|
999
|
+
def pari_version():
|
|
1000
|
+
"""
|
|
1001
|
+
Return a string describing the version of PARI/GP.
|
|
1002
|
+
|
|
1003
|
+
>>> from cypari2 import Pari
|
|
1004
|
+
>>> Pari.pari_version()
|
|
1005
|
+
'GP/PARI CALCULATOR Version ...'
|
|
1006
|
+
"""
|
|
1007
|
+
return to_string(PARIVERSION)
|
|
1008
|
+
|
|
1009
|
+
def init_primes(self, unsigned long M):
|
|
1010
|
+
"""
|
|
1011
|
+
Recompute the primes table including at least all primes up to M
|
|
1012
|
+
(but possibly more).
|
|
1013
|
+
|
|
1014
|
+
Examples:
|
|
1015
|
+
|
|
1016
|
+
>>> import cypari2
|
|
1017
|
+
>>> pari = cypari2.Pari()
|
|
1018
|
+
>>> pari.init_primes(200000)
|
|
1019
|
+
|
|
1020
|
+
We make sure that ticket :trac:`11741` has been fixed:
|
|
1021
|
+
|
|
1022
|
+
>>> pari.init_primes(2**30)
|
|
1023
|
+
Traceback (most recent call last):
|
|
1024
|
+
...
|
|
1025
|
+
ValueError: Cannot compute primes beyond 436273290
|
|
1026
|
+
"""
|
|
1027
|
+
# Hardcoded bound in PARI sources (language/forprime.c)
|
|
1028
|
+
if M > 436273289:
|
|
1029
|
+
raise ValueError("Cannot compute primes beyond 436273290")
|
|
1030
|
+
|
|
1031
|
+
if M <= maxprime():
|
|
1032
|
+
return
|
|
1033
|
+
sig_on()
|
|
1034
|
+
initprimetable(M)
|
|
1035
|
+
sig_off()
|
|
1036
|
+
|
|
1037
|
+
def primes(self, n=None, end=None):
|
|
1038
|
+
"""
|
|
1039
|
+
Return a pari vector containing the first `n` primes, the primes
|
|
1040
|
+
in the interval `[n, end]`, or the primes up to `end`.
|
|
1041
|
+
|
|
1042
|
+
INPUT:
|
|
1043
|
+
|
|
1044
|
+
Either
|
|
1045
|
+
|
|
1046
|
+
- ``n`` -- integer
|
|
1047
|
+
|
|
1048
|
+
or
|
|
1049
|
+
|
|
1050
|
+
- ``n`` -- list or tuple `[a, b]` defining an interval of primes
|
|
1051
|
+
|
|
1052
|
+
or
|
|
1053
|
+
|
|
1054
|
+
- ``n, end`` -- start and end point of an interval of primes
|
|
1055
|
+
|
|
1056
|
+
or
|
|
1057
|
+
|
|
1058
|
+
- ``end`` -- end point for the list of primes
|
|
1059
|
+
|
|
1060
|
+
OUTPUT: a PARI list of prime numbers
|
|
1061
|
+
|
|
1062
|
+
Examples:
|
|
1063
|
+
|
|
1064
|
+
>>> import cypari2
|
|
1065
|
+
>>> pari = cypari2.Pari()
|
|
1066
|
+
>>> pari.primes(3)
|
|
1067
|
+
[2, 3, 5]
|
|
1068
|
+
>>> pari.primes(10)
|
|
1069
|
+
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
|
|
1070
|
+
>>> pari.primes(20)
|
|
1071
|
+
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
|
|
1072
|
+
>>> len(pari.primes(1000))
|
|
1073
|
+
1000
|
|
1074
|
+
>>> pari.primes(11,29)
|
|
1075
|
+
[11, 13, 17, 19, 23, 29]
|
|
1076
|
+
>>> pari.primes((11,29))
|
|
1077
|
+
[11, 13, 17, 19, 23, 29]
|
|
1078
|
+
>>> pari.primes(end=29)
|
|
1079
|
+
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
|
|
1080
|
+
>>> pari.primes(10**30, 10**30 + 100)
|
|
1081
|
+
[1000000000000000000000000000057, 1000000000000000000000000000099]
|
|
1082
|
+
|
|
1083
|
+
Tests:
|
|
1084
|
+
|
|
1085
|
+
>>> pari.primes(0)
|
|
1086
|
+
[]
|
|
1087
|
+
>>> pari.primes(-1)
|
|
1088
|
+
[]
|
|
1089
|
+
>>> pari.primes(end=1)
|
|
1090
|
+
[]
|
|
1091
|
+
>>> pari.primes(end=-1)
|
|
1092
|
+
[]
|
|
1093
|
+
>>> pari.primes(3,2)
|
|
1094
|
+
[]
|
|
1095
|
+
"""
|
|
1096
|
+
cdef Gen t0, t1
|
|
1097
|
+
if end is None:
|
|
1098
|
+
t0 = objtogen(n)
|
|
1099
|
+
sig_on()
|
|
1100
|
+
return new_gen(primes0(t0.g))
|
|
1101
|
+
elif n is None:
|
|
1102
|
+
t0 = self.PARI_TWO # First prime
|
|
1103
|
+
else:
|
|
1104
|
+
t0 = objtogen(n)
|
|
1105
|
+
t1 = objtogen(end)
|
|
1106
|
+
sig_on()
|
|
1107
|
+
return new_gen(primes_interval(t0.g, t1.g))
|
|
1108
|
+
|
|
1109
|
+
euler = Pari_auto.Euler
|
|
1110
|
+
pi = Pari_auto.Pi
|
|
1111
|
+
|
|
1112
|
+
def polchebyshev(self, long n, v=None):
|
|
1113
|
+
"""
|
|
1114
|
+
Chebyshev polynomial of the first kind of degree `n`,
|
|
1115
|
+
in the variable `v`.
|
|
1116
|
+
|
|
1117
|
+
Examples:
|
|
1118
|
+
|
|
1119
|
+
>>> import cypari2
|
|
1120
|
+
>>> pari = cypari2.Pari()
|
|
1121
|
+
>>> pari.polchebyshev(7)
|
|
1122
|
+
64*x^7 - 112*x^5 + 56*x^3 - 7*x
|
|
1123
|
+
>>> pari.polchebyshev(7, 'z')
|
|
1124
|
+
64*z^7 - 112*z^5 + 56*z^3 - 7*z
|
|
1125
|
+
>>> pari.polchebyshev(0)
|
|
1126
|
+
1
|
|
1127
|
+
"""
|
|
1128
|
+
sig_on()
|
|
1129
|
+
return new_gen(polchebyshev1(n, get_var(v)))
|
|
1130
|
+
|
|
1131
|
+
def factorial_int(self, long n):
|
|
1132
|
+
"""
|
|
1133
|
+
Return the factorial of the integer n as a PARI gen.
|
|
1134
|
+
Give result as an integer.
|
|
1135
|
+
|
|
1136
|
+
Examples:
|
|
1137
|
+
|
|
1138
|
+
>>> import cypari2
|
|
1139
|
+
>>> pari = cypari2.Pari()
|
|
1140
|
+
>>> pari.factorial_int(0)
|
|
1141
|
+
1
|
|
1142
|
+
>>> pari.factorial_int(1)
|
|
1143
|
+
1
|
|
1144
|
+
>>> pari.factorial_int(5)
|
|
1145
|
+
120
|
|
1146
|
+
>>> pari.factorial_int(25)
|
|
1147
|
+
15511210043330985984000000
|
|
1148
|
+
"""
|
|
1149
|
+
sig_on()
|
|
1150
|
+
return new_gen(mpfact(n))
|
|
1151
|
+
|
|
1152
|
+
def polsubcyclo(self, long n, long d, v=None):
|
|
1153
|
+
r"""
|
|
1154
|
+
polsubcyclo(n, d, v=x): return the pari list of polynomial(s)
|
|
1155
|
+
defining the sub-abelian extensions of degree `d` of the
|
|
1156
|
+
cyclotomic field `\QQ(\zeta_n)`, where `d`
|
|
1157
|
+
divides `\phi(n)`.
|
|
1158
|
+
|
|
1159
|
+
Examples::
|
|
1160
|
+
|
|
1161
|
+
>>> import cypari2
|
|
1162
|
+
>>> pari = cypari2.Pari()
|
|
1163
|
+
|
|
1164
|
+
>>> pari.polsubcyclo(8, 4)
|
|
1165
|
+
[x^4 + 1]
|
|
1166
|
+
>>> pari.polsubcyclo(8, 2, 'z')
|
|
1167
|
+
[z^2 + 2, z^2 - 2, z^2 + 1]
|
|
1168
|
+
>>> pari.polsubcyclo(8, 1)
|
|
1169
|
+
[x - 1]
|
|
1170
|
+
>>> pari.polsubcyclo(8, 3)
|
|
1171
|
+
[]
|
|
1172
|
+
"""
|
|
1173
|
+
cdef Gen plist
|
|
1174
|
+
sig_on()
|
|
1175
|
+
plist = new_gen(polsubcyclo(n, d, get_var(v)))
|
|
1176
|
+
if typ(plist.g) != t_VEC:
|
|
1177
|
+
return self.vector(1, [plist])
|
|
1178
|
+
else:
|
|
1179
|
+
return plist
|
|
1180
|
+
|
|
1181
|
+
def setrand(self, seed):
|
|
1182
|
+
"""
|
|
1183
|
+
Sets PARI's current random number seed.
|
|
1184
|
+
|
|
1185
|
+
INPUT:
|
|
1186
|
+
|
|
1187
|
+
- ``seed`` -- either a strictly positive integer or a GEN of
|
|
1188
|
+
type ``t_VECSMALL`` as output by ``getrand()``
|
|
1189
|
+
|
|
1190
|
+
Examples:
|
|
1191
|
+
|
|
1192
|
+
>>> import cypari2
|
|
1193
|
+
>>> pari = cypari2.Pari()
|
|
1194
|
+
>>> pari.setrand(50)
|
|
1195
|
+
>>> a = pari.getrand()
|
|
1196
|
+
>>> pari.setrand(a)
|
|
1197
|
+
>>> a == pari.getrand()
|
|
1198
|
+
True
|
|
1199
|
+
|
|
1200
|
+
Tests:
|
|
1201
|
+
|
|
1202
|
+
Check that invalid inputs are handled properly:
|
|
1203
|
+
|
|
1204
|
+
>>> pari.setrand("foobar")
|
|
1205
|
+
Traceback (most recent call last):
|
|
1206
|
+
...
|
|
1207
|
+
PariError: incorrect type in setrand (t_POL)
|
|
1208
|
+
"""
|
|
1209
|
+
cdef Gen t0 = objtogen(seed)
|
|
1210
|
+
sig_on()
|
|
1211
|
+
setrand(t0.g)
|
|
1212
|
+
sig_off()
|
|
1213
|
+
|
|
1214
|
+
def vector(self, long n, entries=None):
|
|
1215
|
+
"""
|
|
1216
|
+
vector(long n, entries=None): Create and return the length n PARI
|
|
1217
|
+
vector with given list of entries.
|
|
1218
|
+
|
|
1219
|
+
Examples:
|
|
1220
|
+
|
|
1221
|
+
>>> import cypari2
|
|
1222
|
+
>>> pari = cypari2.Pari()
|
|
1223
|
+
>>> pari.vector(5, [1, 2, 5, 4, 3])
|
|
1224
|
+
[1, 2, 5, 4, 3]
|
|
1225
|
+
>>> pari.vector(2, ['x', 1])
|
|
1226
|
+
[x, 1]
|
|
1227
|
+
>>> pari.vector(2, ['x', 1, 5])
|
|
1228
|
+
Traceback (most recent call last):
|
|
1229
|
+
...
|
|
1230
|
+
IndexError: length of entries (=3) must equal n (=2)
|
|
1231
|
+
"""
|
|
1232
|
+
# TODO: deprecate
|
|
1233
|
+
v = self._empty_vector(n)
|
|
1234
|
+
if entries is not None:
|
|
1235
|
+
if len(entries) != n:
|
|
1236
|
+
raise IndexError(f"length of entries (={len(entries)}) must equal n (={n})")
|
|
1237
|
+
for i, x in enumerate(entries):
|
|
1238
|
+
v[i] = x
|
|
1239
|
+
return v
|
|
1240
|
+
|
|
1241
|
+
cdef Gen _empty_vector(self, long n):
|
|
1242
|
+
cdef Gen v
|
|
1243
|
+
sig_on()
|
|
1244
|
+
v = new_gen(zerovec(n))
|
|
1245
|
+
return v
|
|
1246
|
+
|
|
1247
|
+
def matrix(self, long m, long n, entries=None):
|
|
1248
|
+
"""
|
|
1249
|
+
matrix(long m, long n, entries=None): Create and return the m x n
|
|
1250
|
+
PARI matrix with given list of entries.
|
|
1251
|
+
|
|
1252
|
+
Examples:
|
|
1253
|
+
|
|
1254
|
+
>>> import cypari2
|
|
1255
|
+
>>> pari = cypari2.Pari()
|
|
1256
|
+
>>> pari.matrix(3, 3, range(9))
|
|
1257
|
+
[0, 1, 2; 3, 4, 5; 6, 7, 8]
|
|
1258
|
+
"""
|
|
1259
|
+
cdef long i, j, k
|
|
1260
|
+
cdef Gen x
|
|
1261
|
+
|
|
1262
|
+
sig_on()
|
|
1263
|
+
A = new_gen(zeromatcopy(m, n))
|
|
1264
|
+
if entries is not None:
|
|
1265
|
+
if len(entries) != m * n:
|
|
1266
|
+
raise IndexError("len of entries (=%s) must be %s*%s=%s" % (len(entries), m, n, m*n))
|
|
1267
|
+
k = 0
|
|
1268
|
+
for i in range(m):
|
|
1269
|
+
for j in range(n):
|
|
1270
|
+
sig_check()
|
|
1271
|
+
x = objtogen(entries[k])
|
|
1272
|
+
set_gcoeff(A.g, i+1, j+1, x.ref_target())
|
|
1273
|
+
A.cache((i, j), x)
|
|
1274
|
+
k += 1
|
|
1275
|
+
return A
|
|
1276
|
+
|
|
1277
|
+
def genus2red(self, P, p=None):
|
|
1278
|
+
r"""
|
|
1279
|
+
Let `P` be a polynomial with integer coefficients.
|
|
1280
|
+
Determines the reduction of the (proper, smooth) genus 2
|
|
1281
|
+
curve `C/\QQ`, defined by the hyperelliptic equation `y^2 = P`.
|
|
1282
|
+
The special syntax ``genus2red([P,Q])`` is also allowed, where
|
|
1283
|
+
the polynomials `P` and `Q` have integer coefficients, to
|
|
1284
|
+
represent the model `y^2 + Q(x)y = P(x)`.
|
|
1285
|
+
|
|
1286
|
+
If the second argument `p` is specified, it must be a prime.
|
|
1287
|
+
Then only the local information at `p` is computed and returned.
|
|
1288
|
+
|
|
1289
|
+
Examples:
|
|
1290
|
+
|
|
1291
|
+
>>> import cypari2
|
|
1292
|
+
>>> pari = cypari2.Pari()
|
|
1293
|
+
>>> x = pari('x')
|
|
1294
|
+
>>> pari.genus2red([-5*x**5, x**3 - 2*x**2 - 2*x + 1])
|
|
1295
|
+
[1416875, [2, -1; 5, 4; 2267, 1], ..., [[2, [2, [Mod(1, 2)]], []], [5, [1, []], ["[V] page 156", [3]]], [2267, [2, [Mod(432, 2267)]], ["[I{1-0-0}] page 170", []]]]]
|
|
1296
|
+
>>> pari.genus2red([-5*x**5, x**3 - 2*x**2 - 2*x + 1],2267)
|
|
1297
|
+
[2267, Mat([2267, 1]), ..., [2267, [2, [Mod(432, 2267)]], ["[I{1-0-0}] page 170", []]]]
|
|
1298
|
+
"""
|
|
1299
|
+
cdef Gen t0 = objtogen(P)
|
|
1300
|
+
if p is None:
|
|
1301
|
+
sig_on()
|
|
1302
|
+
return new_gen(genus2red(t0.g, NULL))
|
|
1303
|
+
cdef Gen t1 = objtogen(p)
|
|
1304
|
+
sig_on()
|
|
1305
|
+
return new_gen(genus2red(t0.g, t1.g))
|
|
1306
|
+
|
|
1307
|
+
def List(self, x=None):
|
|
1308
|
+
"""
|
|
1309
|
+
Create an empty list or convert `x` to a list.
|
|
1310
|
+
|
|
1311
|
+
Examples:
|
|
1312
|
+
|
|
1313
|
+
>>> import cypari2
|
|
1314
|
+
>>> pari = cypari2.Pari()
|
|
1315
|
+
>>> pari.List(range(5))
|
|
1316
|
+
List([0, 1, 2, 3, 4])
|
|
1317
|
+
>>> L = pari.List()
|
|
1318
|
+
>>> L
|
|
1319
|
+
List([])
|
|
1320
|
+
>>> L.listput(42, 1)
|
|
1321
|
+
42
|
|
1322
|
+
>>> L
|
|
1323
|
+
List([42])
|
|
1324
|
+
>>> L.listinsert(24, 1)
|
|
1325
|
+
24
|
|
1326
|
+
>>> L
|
|
1327
|
+
List([24, 42])
|
|
1328
|
+
"""
|
|
1329
|
+
if x is None:
|
|
1330
|
+
sig_on()
|
|
1331
|
+
return new_gen(mklist())
|
|
1332
|
+
cdef Gen t0 = objtogen(x)
|
|
1333
|
+
sig_on()
|
|
1334
|
+
return new_gen(gtolist(t0.g))
|
|
1335
|
+
|
|
1336
|
+
|
|
1337
|
+
cdef long get_var(v) except -2:
|
|
1338
|
+
"""
|
|
1339
|
+
Convert ``v`` into a PARI variable number.
|
|
1340
|
+
|
|
1341
|
+
If ``v`` is a PARI object, return the variable number of
|
|
1342
|
+
``variable(v)``. If ``v`` is ``None``, return -1.
|
|
1343
|
+
Otherwise, treat ``v`` as a string and return the number of
|
|
1344
|
+
the variable named ``v``.
|
|
1345
|
+
|
|
1346
|
+
OUTPUT: a PARI variable number (varn) or -1 if there is no
|
|
1347
|
+
variable number.
|
|
1348
|
+
|
|
1349
|
+
.. WARNING::
|
|
1350
|
+
|
|
1351
|
+
You can easily create variables with garbage names using
|
|
1352
|
+
this function. This can actually be used as a feature, if
|
|
1353
|
+
you want variable names which cannot be confused with
|
|
1354
|
+
ordinary user variables.
|
|
1355
|
+
|
|
1356
|
+
Examples:
|
|
1357
|
+
|
|
1358
|
+
We test this function using ``Pol()`` which calls this function:
|
|
1359
|
+
|
|
1360
|
+
>>> import cypari2
|
|
1361
|
+
>>> pari = cypari2.Pari()
|
|
1362
|
+
>>> pari("[1,0]").Pol()
|
|
1363
|
+
x
|
|
1364
|
+
>>> pari("[2,0]").Pol('x')
|
|
1365
|
+
2*x
|
|
1366
|
+
>>> pari("[Pi,0]").Pol('!@#$%^&')
|
|
1367
|
+
3.14159265358979*!@#$%^&
|
|
1368
|
+
|
|
1369
|
+
We can use ``varhigher()`` and ``varlower()`` to create
|
|
1370
|
+
temporary variables without a name. The ``"xx"`` below is just a
|
|
1371
|
+
string to display the variable, it doesn't create a variable
|
|
1372
|
+
``"xx"``:
|
|
1373
|
+
|
|
1374
|
+
>>> xx = pari.varhigher("xx")
|
|
1375
|
+
>>> pari("[x,0]").Pol(xx)
|
|
1376
|
+
x*xx
|
|
1377
|
+
|
|
1378
|
+
Indeed, this is not the same as:
|
|
1379
|
+
|
|
1380
|
+
>>> pari("[x,0]").Pol("xx")
|
|
1381
|
+
Traceback (most recent call last):
|
|
1382
|
+
...
|
|
1383
|
+
PariError: incorrect priority in gtopoly: variable x <= xx
|
|
1384
|
+
"""
|
|
1385
|
+
if v is None:
|
|
1386
|
+
return -1
|
|
1387
|
+
cdef long varno
|
|
1388
|
+
if isinstance(v, Gen):
|
|
1389
|
+
sig_on()
|
|
1390
|
+
varno = gvar((<Gen>v).g)
|
|
1391
|
+
sig_off()
|
|
1392
|
+
if varno < 0:
|
|
1393
|
+
return -1
|
|
1394
|
+
else:
|
|
1395
|
+
return varno
|
|
1396
|
+
cdef bytes s = to_bytes(v)
|
|
1397
|
+
sig_on()
|
|
1398
|
+
varno = fetch_user_var(s)
|
|
1399
|
+
sig_off()
|
|
1400
|
+
return varno
|
|
1401
|
+
|
|
1402
|
+
|
|
1403
|
+
# Monkey-patched versions of default(parisize) and default(parisizemax)
|
|
1404
|
+
# which call before_resize() and after_resize().
|
|
1405
|
+
# The monkey-patching is set up in PariInstance.__cinit__
|
|
1406
|
+
cdef GEN patched_parisize(const char* v, long flag) noexcept:
|
|
1407
|
+
# Cast to `int(*)() noexcept` to avoid exception handling
|
|
1408
|
+
if (<int(*)() noexcept>before_resize)():
|
|
1409
|
+
sig_error()
|
|
1410
|
+
return sd_parisize(v, flag)
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
cdef GEN patched_parisizemax(const char* v, long flag) noexcept:
|
|
1414
|
+
# Cast to `int(*)() noexcept` to avoid exception handling
|
|
1415
|
+
if (<int(*)() noexcept>before_resize)():
|
|
1416
|
+
sig_error()
|
|
1417
|
+
return sd_parisizemax(v, flag)
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
IF HAVE_PLOT_SVG:
|
|
1421
|
+
cdef void get_plot_ipython(PARI_plot* T) noexcept:
|
|
1422
|
+
# Values copied from src/graph/plotsvg.c in PARI sources
|
|
1423
|
+
T.width = 480
|
|
1424
|
+
T.height = 320
|
|
1425
|
+
T.hunit = 3
|
|
1426
|
+
T.vunit = 3
|
|
1427
|
+
T.fwidth = 9
|
|
1428
|
+
T.fheight = 12
|
|
1429
|
+
|
|
1430
|
+
T.draw = draw_ipython
|
|
1431
|
+
|
|
1432
|
+
cdef void draw_ipython(PARI_plot *T, GEN w, GEN x, GEN y) noexcept:
|
|
1433
|
+
global avma
|
|
1434
|
+
cdef pari_sp av = avma
|
|
1435
|
+
cdef char* svg = rect2svg(w, x, y, T)
|
|
1436
|
+
from IPython.core.display import SVG, display
|
|
1437
|
+
display(SVG(svg))
|
|
1438
|
+
avma = av
|