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
cypari2/paripriv.pxd
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# distutils: libraries = gmp pari
|
|
2
|
+
"""
|
|
3
|
+
Declarations for private functions from PARI
|
|
4
|
+
|
|
5
|
+
Ideally, we shouldn't use these, but for technical reasons, we have to.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .types cimport *
|
|
9
|
+
|
|
10
|
+
cdef extern from "pari/paripriv.h":
|
|
11
|
+
int t_FF_FpXQ, t_FF_Flxq, t_FF_F2xq
|
|
12
|
+
|
|
13
|
+
int gpd_QUIET, gpd_TEST, gpd_EMACS, gpd_TEXMACS
|
|
14
|
+
|
|
15
|
+
struct pariout_t:
|
|
16
|
+
char format # e,f,g
|
|
17
|
+
long fieldw # 0 (ignored) or field width
|
|
18
|
+
long sigd # -1 (all) or number of significant digits printed
|
|
19
|
+
int sp # 0 = suppress whitespace from output
|
|
20
|
+
int prettyp # output style: raw, prettyprint, etc
|
|
21
|
+
int TeXstyle
|
|
22
|
+
|
|
23
|
+
struct gp_data:
|
|
24
|
+
pariout_t *fmt
|
|
25
|
+
unsigned long flags
|
|
26
|
+
ulong primelimit # deprecated
|
|
27
|
+
|
|
28
|
+
extern gp_data* GP_DATA
|
|
29
|
+
|
|
30
|
+
# In older versions of PARI, this is declared in the private
|
|
31
|
+
# non-installed PARI header file "anal.h". More recently, this is
|
|
32
|
+
# declared in "paripriv.h". Since a double declaration does not hurt,
|
|
33
|
+
# we declare it here regardless.
|
|
34
|
+
cdef extern const char* closure_func_err()
|
cypari2/pycore_long.h
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#include "Python.h"
|
|
2
|
+
#include <stdbool.h>
|
|
3
|
+
|
|
4
|
+
#if PY_VERSION_HEX >= 0x030C00A5
|
|
5
|
+
#define ob_digit(o) (((PyLongObject*)o)->long_value.ob_digit)
|
|
6
|
+
#else
|
|
7
|
+
#define ob_digit(o) (((PyLongObject*)o)->ob_digit)
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#if PY_VERSION_HEX >= 0x030C00A7
|
|
11
|
+
// taken from cpython:Include/internal/pycore_long.h @ 3.12
|
|
12
|
+
|
|
13
|
+
/* Long value tag bits:
|
|
14
|
+
* 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
|
|
15
|
+
* 2: Reserved for immortality bit
|
|
16
|
+
* 3+ Unsigned digit count
|
|
17
|
+
*/
|
|
18
|
+
#define SIGN_MASK 3
|
|
19
|
+
#define SIGN_ZERO 1
|
|
20
|
+
#define SIGN_NEGATIVE 2
|
|
21
|
+
#define NON_SIZE_BITS 3
|
|
22
|
+
|
|
23
|
+
static inline bool
|
|
24
|
+
_PyLong_IsZero(const PyLongObject *op)
|
|
25
|
+
{
|
|
26
|
+
return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static inline bool
|
|
30
|
+
_PyLong_IsNegative(const PyLongObject *op)
|
|
31
|
+
{
|
|
32
|
+
return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static inline bool
|
|
36
|
+
_PyLong_IsPositive(const PyLongObject *op)
|
|
37
|
+
{
|
|
38
|
+
return (op->long_value.lv_tag & SIGN_MASK) == 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static inline Py_ssize_t
|
|
42
|
+
_PyLong_DigitCount(const PyLongObject *op)
|
|
43
|
+
{
|
|
44
|
+
assert(PyLong_Check(op));
|
|
45
|
+
return op->long_value.lv_tag >> NON_SIZE_BITS;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
|
|
49
|
+
|
|
50
|
+
static inline void
|
|
51
|
+
_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
|
|
52
|
+
{
|
|
53
|
+
assert(size >= 0);
|
|
54
|
+
assert(-1 <= sign && sign <= 1);
|
|
55
|
+
assert(sign != 0 || size == 0);
|
|
56
|
+
op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#else
|
|
60
|
+
// fallback for < 3.12
|
|
61
|
+
|
|
62
|
+
static inline bool
|
|
63
|
+
_PyLong_IsZero(const PyLongObject *op)
|
|
64
|
+
{
|
|
65
|
+
return Py_SIZE(op) == 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static inline bool
|
|
69
|
+
_PyLong_IsNegative(const PyLongObject *op)
|
|
70
|
+
{
|
|
71
|
+
return Py_SIZE(op) < 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static inline bool
|
|
75
|
+
_PyLong_IsPositive(const PyLongObject *op)
|
|
76
|
+
{
|
|
77
|
+
return Py_SIZE(op) > 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static inline Py_ssize_t
|
|
81
|
+
_PyLong_DigitCount(const PyLongObject *op)
|
|
82
|
+
{
|
|
83
|
+
Py_ssize_t size = Py_SIZE(op);
|
|
84
|
+
return size < 0 ? -size : size;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static inline void
|
|
88
|
+
_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
|
|
89
|
+
{
|
|
90
|
+
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
|
|
91
|
+
// The function Py_SET_SIZE is defined starting with python 3.9.
|
|
92
|
+
Py_SIZE(op) = size;
|
|
93
|
+
#else
|
|
94
|
+
Py_SET_SIZE(op, sign < 0 ? -size : size);
|
|
95
|
+
#endif
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#endif
|
cypari2/pycore_long.pxd
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from cpython.longintrepr cimport py_long, digit
|
|
2
|
+
|
|
3
|
+
cdef extern from "pycore_long.h":
|
|
4
|
+
digit* ob_digit(py_long o)
|
|
5
|
+
bint _PyLong_IsZero(py_long o)
|
|
6
|
+
bint _PyLong_IsNegative(py_long o)
|
|
7
|
+
bint _PyLong_IsPositive(py_long o)
|
|
8
|
+
Py_ssize_t _PyLong_DigitCount(py_long o)
|
|
9
|
+
void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
|
|
Binary file
|
cypari2/stack.pxd
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-pari
|
|
2
|
+
|
|
3
|
+
from .types cimport GEN, pari_sp
|
|
4
|
+
from .gen cimport Gen_base, Gen
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
cdef Gen new_gen(GEN x)
|
|
8
|
+
cdef new_gens2(GEN x, GEN y)
|
|
9
|
+
cdef Gen new_gen_noclear(GEN x)
|
|
10
|
+
cdef Gen clone_gen(GEN x)
|
|
11
|
+
cdef Gen clone_gen_noclear(GEN x)
|
|
12
|
+
|
|
13
|
+
cdef void clear_stack() noexcept
|
|
14
|
+
cdef void reset_avma() noexcept
|
|
15
|
+
|
|
16
|
+
cdef void remove_from_pari_stack(Gen self) noexcept
|
|
17
|
+
cdef int move_gens_to_heap(pari_sp lim) except -1
|
|
18
|
+
|
|
19
|
+
cdef int before_resize() except -1
|
|
20
|
+
cdef int set_pari_stack_size(size_t size, size_t sizemax) except -1
|
|
21
|
+
cdef void after_resize() noexcept
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
cdef class DetachGen:
|
|
25
|
+
cdef source
|
|
26
|
+
|
|
27
|
+
cdef GEN detach(self) except NULL
|
cypari2/stack.pyx
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-pari
|
|
2
|
+
"""
|
|
3
|
+
Memory management for Gens on the PARI stack or the heap
|
|
4
|
+
********************************************************
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
# ****************************************************************************
|
|
8
|
+
# Copyright (C) 2016 Luca De Feo <luca.defeo@polytechnique.edu>
|
|
9
|
+
# Copyright (C) 2018 Jeroen Demeyer <J.Demeyer@UGent.be>
|
|
10
|
+
#
|
|
11
|
+
# This program is free software: you can redistribute it and/or modify
|
|
12
|
+
# it under the terms of the GNU General Public License as published by
|
|
13
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
14
|
+
# (at your option) any later version.
|
|
15
|
+
# http://www.gnu.org/licenses/
|
|
16
|
+
# ****************************************************************************
|
|
17
|
+
|
|
18
|
+
cimport cython
|
|
19
|
+
|
|
20
|
+
from cpython.ref cimport PyObject, _Py_REFCNT
|
|
21
|
+
from cpython.exc cimport PyErr_SetString
|
|
22
|
+
|
|
23
|
+
from cysignals.signals cimport (sig_on, sig_off, sig_block, sig_unblock,
|
|
24
|
+
sig_error)
|
|
25
|
+
|
|
26
|
+
from .gen cimport Gen, Gen_new
|
|
27
|
+
from .paridecl cimport (avma, pari_mainstack, gnil, gcopy,
|
|
28
|
+
is_universal_constant, is_on_stack,
|
|
29
|
+
isclone, gclone, gclone_refc,
|
|
30
|
+
paristack_setsize)
|
|
31
|
+
|
|
32
|
+
from warnings import warn
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
cdef extern from *:
|
|
36
|
+
int sig_on_count "cysigs.sig_on_count"
|
|
37
|
+
int block_sigint "cysigs.block_sigint"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Singleton object to denote the top of the PARI stack
|
|
41
|
+
cdef Gen top_of_stack = Gen_new(gnil, NULL)
|
|
42
|
+
|
|
43
|
+
# Pointer to the Gen on the bottom of the PARI stack. This is the first
|
|
44
|
+
# element of the Gen linked list. If the linked list is empty, this
|
|
45
|
+
# equals top_of_stack. This pointer is *not* refcounted, so it does not
|
|
46
|
+
# prevent the stackbottom object from being deallocated. In that case,
|
|
47
|
+
# we update stackbottom in Gen.__dealloc__
|
|
48
|
+
cdef PyObject* stackbottom = <PyObject*>top_of_stack
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
cdef void remove_from_pari_stack(Gen self) noexcept:
|
|
52
|
+
global avma, stackbottom
|
|
53
|
+
if <PyObject*>self is not stackbottom:
|
|
54
|
+
print("ERROR: removing wrong instance of Gen")
|
|
55
|
+
print(f"Expected: {<object>stackbottom}")
|
|
56
|
+
print(f"Actual: {self}")
|
|
57
|
+
if sig_on_count and not block_sigint:
|
|
58
|
+
PyErr_SetString(SystemError, "calling remove_from_pari_stack() inside sig_on()")
|
|
59
|
+
sig_error()
|
|
60
|
+
if self.sp() != avma:
|
|
61
|
+
if avma > self.sp():
|
|
62
|
+
print("ERROR: inconsistent avma when removing Gen from PARI stack")
|
|
63
|
+
print(f"Expected: 0x{self.sp():x}")
|
|
64
|
+
print(f"Actual: 0x{avma:x}")
|
|
65
|
+
else:
|
|
66
|
+
warn(f"cypari2 leaked {self.sp() - avma} bytes on the PARI stack",
|
|
67
|
+
RuntimeWarning, stacklevel=2)
|
|
68
|
+
n = self.next
|
|
69
|
+
stackbottom = <PyObject*>n
|
|
70
|
+
self.next = None
|
|
71
|
+
reset_avma()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
cdef inline Gen Gen_stack_new(GEN x):
|
|
75
|
+
"""
|
|
76
|
+
Allocate and initialize a new instance of ``Gen`` wrapping
|
|
77
|
+
a GEN on the PARI stack.
|
|
78
|
+
"""
|
|
79
|
+
global stackbottom
|
|
80
|
+
# n = <Gen>stackbottom must be done BEFORE calling Gen_new()
|
|
81
|
+
# since Gen_new may invoke gc.collect() which would mess up
|
|
82
|
+
# the PARI stack.
|
|
83
|
+
n = <Gen>stackbottom
|
|
84
|
+
z = Gen_new(x, <GEN>avma)
|
|
85
|
+
z.next = n
|
|
86
|
+
stackbottom = <PyObject*>z
|
|
87
|
+
sz = z.sp()
|
|
88
|
+
sn = n.sp()
|
|
89
|
+
if sz > sn:
|
|
90
|
+
raise SystemError(f"objects on PARI stack in invalid order (first: 0x{sz:x}; next: 0x{sn:x})")
|
|
91
|
+
return z
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
cdef void reset_avma() noexcept:
|
|
95
|
+
"""
|
|
96
|
+
Reset PARI stack pointer to remove unused stuff from the PARI stack.
|
|
97
|
+
|
|
98
|
+
Note that the actual data remains on the stack. Therefore, it is
|
|
99
|
+
safe to use as long as no further PARI functions are called.
|
|
100
|
+
"""
|
|
101
|
+
# NOTE: this can be called with an exception set (the error handler
|
|
102
|
+
# does that)!
|
|
103
|
+
global avma
|
|
104
|
+
avma = (<Gen>stackbottom).sp()
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
cdef void clear_stack() noexcept:
|
|
108
|
+
"""
|
|
109
|
+
Call ``sig_off()`` and clean the PARI stack.
|
|
110
|
+
"""
|
|
111
|
+
sig_off()
|
|
112
|
+
reset_avma()
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
cdef int move_gens_to_heap(pari_sp lim) except -1:
|
|
116
|
+
"""
|
|
117
|
+
Move some/all Gens from the PARI stack to the heap.
|
|
118
|
+
|
|
119
|
+
If lim == -1, move everything. Otherwise, keep moving as long as
|
|
120
|
+
avma <= lim.
|
|
121
|
+
"""
|
|
122
|
+
while avma <= lim and stackbottom is not <PyObject*>top_of_stack:
|
|
123
|
+
current = <Gen>stackbottom
|
|
124
|
+
sig_on()
|
|
125
|
+
current.g = gclone(current.g)
|
|
126
|
+
sig_block()
|
|
127
|
+
remove_from_pari_stack(current)
|
|
128
|
+
sig_unblock()
|
|
129
|
+
sig_off()
|
|
130
|
+
# The .address attribute can only be updated now because it is
|
|
131
|
+
# needed in remove_from_pari_stack(). This means that the object
|
|
132
|
+
# is temporarily in an inconsistent state but this does not
|
|
133
|
+
# matter since .address is normally not used.
|
|
134
|
+
#
|
|
135
|
+
# The more important .g attribute is updated correctly before
|
|
136
|
+
# remove_from_pari_stack(). Therefore, the object can be used
|
|
137
|
+
# normally regardless of what happens to the PARI stack.
|
|
138
|
+
current.address = current.g
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
cdef int before_resize() except -1:
|
|
142
|
+
"""
|
|
143
|
+
Prepare for resizing the PARI stack
|
|
144
|
+
|
|
145
|
+
This must be called before reallocating the PARI stack
|
|
146
|
+
"""
|
|
147
|
+
move_gens_to_heap(-1)
|
|
148
|
+
if top_of_stack.sp() != pari_mainstack.top:
|
|
149
|
+
raise RuntimeError("cannot resize PARI stack here")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
cdef int set_pari_stack_size(size_t size, size_t sizemax) except -1:
|
|
153
|
+
"""
|
|
154
|
+
Safely set the PARI stack size
|
|
155
|
+
"""
|
|
156
|
+
before_resize()
|
|
157
|
+
sig_on()
|
|
158
|
+
paristack_setsize(size, sizemax)
|
|
159
|
+
sig_off()
|
|
160
|
+
after_resize()
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
cdef void after_resize() noexcept:
|
|
164
|
+
"""
|
|
165
|
+
This must be called after reallocating the PARI stack
|
|
166
|
+
"""
|
|
167
|
+
top_of_stack.address = <GEN>pari_mainstack.top
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
cdef Gen new_gen(GEN x):
|
|
171
|
+
"""
|
|
172
|
+
Create a new ``Gen`` from a ``GEN``. Except if `x` is ``gnil``, then
|
|
173
|
+
return ``None`` instead.
|
|
174
|
+
|
|
175
|
+
Also call ``sig_off``() and clear the PARI stack.
|
|
176
|
+
"""
|
|
177
|
+
sig_off()
|
|
178
|
+
if x is gnil:
|
|
179
|
+
reset_avma()
|
|
180
|
+
return None
|
|
181
|
+
return new_gen_noclear(x)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
cdef new_gens2(GEN x, GEN y):
|
|
185
|
+
"""
|
|
186
|
+
Create a 2-tuple of new ``Gen``s from 2 ``GEN``s.
|
|
187
|
+
|
|
188
|
+
Also call ``sig_off``() and clear the PARI stack.
|
|
189
|
+
"""
|
|
190
|
+
sig_off()
|
|
191
|
+
global avma
|
|
192
|
+
av = avma
|
|
193
|
+
g1 = new_gen_noclear(x)
|
|
194
|
+
# Restore avma in case that remove_from_pari_stack() was called
|
|
195
|
+
avma = av
|
|
196
|
+
g2 = new_gen_noclear(y)
|
|
197
|
+
return (g1, g2)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
cdef Gen new_gen_noclear(GEN x):
|
|
201
|
+
"""
|
|
202
|
+
Create a new ``Gen`` from a ``GEN``.
|
|
203
|
+
"""
|
|
204
|
+
if not is_on_stack(x):
|
|
205
|
+
reset_avma()
|
|
206
|
+
if is_universal_constant(x):
|
|
207
|
+
return Gen_new(x, NULL)
|
|
208
|
+
elif isclone(x):
|
|
209
|
+
gclone_refc(x)
|
|
210
|
+
return Gen_new(x, x)
|
|
211
|
+
raise SystemError("new_gen() argument not on PARI stack, not on PARI heap and not a universal constant")
|
|
212
|
+
|
|
213
|
+
z = Gen_stack_new(x)
|
|
214
|
+
|
|
215
|
+
# If we used over half of the PARI stack, move all Gens to the heap
|
|
216
|
+
if (pari_mainstack.top - avma) >= pari_mainstack.size // 2:
|
|
217
|
+
if sig_on_count == 0:
|
|
218
|
+
try:
|
|
219
|
+
move_gens_to_heap(-1)
|
|
220
|
+
except MemoryError:
|
|
221
|
+
pass
|
|
222
|
+
|
|
223
|
+
return z
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
cdef Gen clone_gen(GEN x):
|
|
227
|
+
x = gclone(x)
|
|
228
|
+
clear_stack()
|
|
229
|
+
return Gen_new(x, x)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
cdef Gen clone_gen_noclear(GEN x):
|
|
233
|
+
x = gclone(x)
|
|
234
|
+
return Gen_new(x, x)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
@cython.no_gc
|
|
238
|
+
cdef class DetachGen:
|
|
239
|
+
"""
|
|
240
|
+
Destroy a :class:`Gen` but keep the ``GEN`` which is inside it.
|
|
241
|
+
|
|
242
|
+
The typical usage is as follows:
|
|
243
|
+
|
|
244
|
+
1. Creates the ``DetachGen`` object from a :class`Gen`.
|
|
245
|
+
|
|
246
|
+
2. Removes all other references to that :class:`Gen`.
|
|
247
|
+
|
|
248
|
+
3. Call the ``detach`` method to retrieve the ``GEN`` (or a copy of
|
|
249
|
+
it if the original was not on the stack).
|
|
250
|
+
"""
|
|
251
|
+
def __init__(self, s):
|
|
252
|
+
self.source = s
|
|
253
|
+
|
|
254
|
+
cdef GEN detach(self) except NULL:
|
|
255
|
+
src = <Gen?>self.source
|
|
256
|
+
|
|
257
|
+
# Whatever happens, delete self.source
|
|
258
|
+
self.source = None
|
|
259
|
+
|
|
260
|
+
# Delete src safely, keeping it available as GEN
|
|
261
|
+
cdef GEN res = src.g
|
|
262
|
+
if is_on_stack(res):
|
|
263
|
+
# Verify that we hold the only reference to src
|
|
264
|
+
if _Py_REFCNT(<PyObject*>src) != 1:
|
|
265
|
+
raise SystemError("cannot detach a Gen which is still referenced")
|
|
266
|
+
elif is_universal_constant(res):
|
|
267
|
+
pass
|
|
268
|
+
else:
|
|
269
|
+
# Make a copy to the PARI stack
|
|
270
|
+
res = gcopy(res)
|
|
271
|
+
|
|
272
|
+
# delete src but do not change avma
|
|
273
|
+
global avma
|
|
274
|
+
cdef pari_sp av = avma
|
|
275
|
+
avma = src.sp() # Avoid a warning when deallocating
|
|
276
|
+
del src
|
|
277
|
+
avma = av
|
|
278
|
+
return res
|
|
Binary file
|
cypari2/string_utils.pxd
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-pari
|
|
2
|
+
|
|
3
|
+
cdef extern from *:
|
|
4
|
+
int PY_MAJOR_VERSION
|
|
5
|
+
|
|
6
|
+
cpdef bytes to_bytes(s)
|
|
7
|
+
cpdef unicode to_unicode(s)
|
|
8
|
+
|
|
9
|
+
cpdef inline to_string(s):
|
|
10
|
+
r"""
|
|
11
|
+
Converts a bytes and unicode ``s`` to a string.
|
|
12
|
+
|
|
13
|
+
String means bytes in Python2 and unicode in Python3
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
|
|
17
|
+
>>> from cypari2.string_utils import to_string
|
|
18
|
+
>>> s1 = to_string(b'hello')
|
|
19
|
+
>>> s2 = to_string('hello')
|
|
20
|
+
>>> s3 = to_string(u'hello')
|
|
21
|
+
>>> type(s1) == type(s2) == type(s3) == str
|
|
22
|
+
True
|
|
23
|
+
>>> s1 == s2 == s3 == 'hello'
|
|
24
|
+
True
|
|
25
|
+
"""
|
|
26
|
+
if PY_MAJOR_VERSION <= 2:
|
|
27
|
+
return to_bytes(s)
|
|
28
|
+
else:
|
|
29
|
+
return to_unicode(s)
|
cypari2/string_utils.pyx
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-pari
|
|
2
|
+
r"""
|
|
3
|
+
Conversion functions for bytes/unicode
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
encoding = sys.getfilesystemencoding()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
cpdef bytes to_bytes(s):
|
|
11
|
+
"""
|
|
12
|
+
Converts bytes and unicode ``s`` to bytes.
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
15
|
+
|
|
16
|
+
>>> from cypari2.string_utils import to_bytes
|
|
17
|
+
>>> s1 = to_bytes(b'hello')
|
|
18
|
+
>>> s2 = to_bytes('hello')
|
|
19
|
+
>>> s3 = to_bytes(u'hello')
|
|
20
|
+
>>> type(s1) is type(s2) is type(s3) is bytes
|
|
21
|
+
True
|
|
22
|
+
>>> s1 == s2 == s3 == b'hello'
|
|
23
|
+
True
|
|
24
|
+
|
|
25
|
+
>>> type(to_bytes(1234)) is bytes
|
|
26
|
+
True
|
|
27
|
+
>>> int(to_bytes(1234))
|
|
28
|
+
1234
|
|
29
|
+
"""
|
|
30
|
+
cdef int convert
|
|
31
|
+
for convert in range(2):
|
|
32
|
+
if convert:
|
|
33
|
+
s = str(s)
|
|
34
|
+
if isinstance(s, bytes):
|
|
35
|
+
return <bytes> s
|
|
36
|
+
elif isinstance(s, unicode):
|
|
37
|
+
return (<unicode> s).encode(encoding)
|
|
38
|
+
raise AssertionError(f"str() returned {type(s)}")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
cpdef unicode to_unicode(s):
|
|
42
|
+
r"""
|
|
43
|
+
Converts bytes and unicode ``s`` to unicode.
|
|
44
|
+
|
|
45
|
+
Examples:
|
|
46
|
+
|
|
47
|
+
>>> from cypari2.string_utils import to_unicode
|
|
48
|
+
>>> s1 = to_unicode(b'hello')
|
|
49
|
+
>>> s2 = to_unicode('hello')
|
|
50
|
+
>>> s3 = to_unicode(u'hello')
|
|
51
|
+
>>> type(s1) is type(s2) is type(s3) is type(u"")
|
|
52
|
+
True
|
|
53
|
+
>>> s1 == s2 == s3 == u'hello'
|
|
54
|
+
True
|
|
55
|
+
|
|
56
|
+
>>> print(to_unicode(1234))
|
|
57
|
+
1234
|
|
58
|
+
>>> type(to_unicode(1234)) is type(u"")
|
|
59
|
+
True
|
|
60
|
+
"""
|
|
61
|
+
if isinstance(s, bytes):
|
|
62
|
+
return (<bytes> s).decode(encoding)
|
|
63
|
+
elif isinstance(s, unicode):
|
|
64
|
+
return <unicode> s
|
|
65
|
+
return unicode(s)
|
cypari2/types.pxd
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-pari
|
|
2
|
+
"""
|
|
3
|
+
Declarations for types used by PARI
|
|
4
|
+
|
|
5
|
+
This includes both the C types as well as the PARI types (and a few
|
|
6
|
+
macros for dealing with those).
|
|
7
|
+
|
|
8
|
+
It is important that the functionality in this file does not call any
|
|
9
|
+
PARI library functions. The reason is that we want to allow just using
|
|
10
|
+
these types (for example, to define a Cython extension type) without
|
|
11
|
+
linking to PARI. This file should consist only of typedefs and macros
|
|
12
|
+
from PARI's include files.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
# ****************************************************************************
|
|
16
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
17
|
+
# as published by the Free Software Foundation; either version 2 of
|
|
18
|
+
# the License, or (at your option) any later version.
|
|
19
|
+
# https://www.gnu.org/licenses/
|
|
20
|
+
# ****************************************************************************
|
|
21
|
+
|
|
22
|
+
cdef extern from "pari/pari.h":
|
|
23
|
+
ctypedef unsigned long ulong "pari_ulong"
|
|
24
|
+
|
|
25
|
+
ctypedef long* GEN
|
|
26
|
+
ctypedef char* byteptr
|
|
27
|
+
ctypedef unsigned long pari_sp
|
|
28
|
+
ctypedef unsigned long pari_prime
|
|
29
|
+
|
|
30
|
+
# PARI types
|
|
31
|
+
enum:
|
|
32
|
+
t_INT
|
|
33
|
+
t_REAL
|
|
34
|
+
t_INTMOD
|
|
35
|
+
t_FRAC
|
|
36
|
+
t_FFELT
|
|
37
|
+
t_COMPLEX
|
|
38
|
+
t_PADIC
|
|
39
|
+
t_QUAD
|
|
40
|
+
t_POLMOD
|
|
41
|
+
t_POL
|
|
42
|
+
t_SER
|
|
43
|
+
t_RFRAC
|
|
44
|
+
t_QFR
|
|
45
|
+
t_QFI
|
|
46
|
+
t_VEC
|
|
47
|
+
t_COL
|
|
48
|
+
t_MAT
|
|
49
|
+
t_LIST
|
|
50
|
+
t_STR
|
|
51
|
+
t_VECSMALL
|
|
52
|
+
t_CLOSURE
|
|
53
|
+
t_ERROR
|
|
54
|
+
t_INFINITY
|
|
55
|
+
|
|
56
|
+
int BITS_IN_LONG
|
|
57
|
+
int LOWDEFAULTPREC
|
|
58
|
+
long DEFAULTPREC # 64 bits precision
|
|
59
|
+
long MEDDEFAULTPREC # 128 bits precision
|
|
60
|
+
long BIGDEFAULTPREC # 192 bits precision
|
|
61
|
+
|
|
62
|
+
ulong CLONEBIT
|
|
63
|
+
|
|
64
|
+
long typ(GEN x)
|
|
65
|
+
long settyp(GEN x, long s)
|
|
66
|
+
long isclone(GEN x)
|
|
67
|
+
long setisclone(GEN x)
|
|
68
|
+
long unsetisclone(GEN x)
|
|
69
|
+
long lg(GEN x)
|
|
70
|
+
long setlg(GEN x, long s)
|
|
71
|
+
long signe(GEN x)
|
|
72
|
+
long setsigne(GEN x, long s)
|
|
73
|
+
long lgefint(GEN x)
|
|
74
|
+
long setlgefint(GEN x, long s)
|
|
75
|
+
long expo(GEN x)
|
|
76
|
+
long setexpo(GEN x, long s)
|
|
77
|
+
long valp(GEN x)
|
|
78
|
+
long setvalp(GEN x, long s)
|
|
79
|
+
long precp(GEN x)
|
|
80
|
+
long setprecp(GEN x, long s)
|
|
81
|
+
long varn(GEN x)
|
|
82
|
+
long setvarn(GEN x, long s)
|
|
83
|
+
long evaltyp(long x)
|
|
84
|
+
long evallg(long x)
|
|
85
|
+
long evalvarn(long x)
|
|
86
|
+
long evalsigne(long x)
|
|
87
|
+
long evalprecp(long x)
|
|
88
|
+
long evalvalp(long x)
|
|
89
|
+
long evalexpo(long x)
|
|
90
|
+
long evallgefint(long x)
|
|
91
|
+
|
|
92
|
+
ctypedef struct PARI_plot:
|
|
93
|
+
long width
|
|
94
|
+
long height
|
|
95
|
+
long hunit
|
|
96
|
+
long vunit
|
|
97
|
+
long fwidth
|
|
98
|
+
long fheight
|
|
99
|
+
void (*draw)(PARI_plot *T, GEN w, GEN x, GEN y)
|
|
100
|
+
|
|
101
|
+
ctypedef struct entree:
|
|
102
|
+
const char *name
|
|
103
|
+
ulong valence
|
|
104
|
+
void *value
|
|
105
|
+
long menu
|
|
106
|
+
const char *code
|
|
107
|
+
const char *help
|
|
108
|
+
void *pvalue
|
|
109
|
+
long arity
|
|
110
|
+
ulong hash
|
|
111
|
+
entree *next
|
|
112
|
+
|
|
113
|
+
# Various structures that we don't interface but which need to be
|
|
114
|
+
# declared, such that Cython understands the declarations of
|
|
115
|
+
# functions using these types.
|
|
116
|
+
struct bb_group
|
|
117
|
+
struct bb_field
|
|
118
|
+
struct bb_ring
|
|
119
|
+
struct bb_algebra
|
|
120
|
+
struct qfr_data
|
|
121
|
+
struct nfmaxord_t
|
|
122
|
+
struct forcomposite_t
|
|
123
|
+
struct forpart_t
|
|
124
|
+
struct forprime_t
|
|
125
|
+
struct forvec_t
|
|
126
|
+
struct gp_context
|
|
127
|
+
struct nfbasic_t
|
|
128
|
+
struct pariFILE
|
|
129
|
+
struct pari_mt
|
|
130
|
+
struct pari_stack
|
|
131
|
+
struct pari_thread
|
|
132
|
+
struct pari_timer
|
|
133
|
+
struct GENbin
|
|
134
|
+
struct hashentry
|
|
135
|
+
struct hashtable
|
|
136
|
+
|
|
137
|
+
# These are actually defined in cypari.h but we put them here to
|
|
138
|
+
# prevent Cython from reordering the includes.
|
|
139
|
+
GEN set_gel(GEN x, long n, GEN z) # gel(x, n) = z
|
|
140
|
+
GEN set_gmael(GEN x, long i, long j, GEN z) # gmael(x, i, j) = z
|
|
141
|
+
GEN set_gcoeff(GEN x, long i, long j, GEN z) # gcoeff(x, i, j) = z
|
|
142
|
+
GEN set_uel(GEN x, long n, ulong z) # uel(x, n) = z
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# It is important that this gets included *after* all PARI includes
|
|
146
|
+
cdef extern from "cypari.h":
|
|
147
|
+
pass
|