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,869 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-pari
|
|
2
|
+
"""
|
|
3
|
+
This linkage file implements the API for unramified extensions of the padics
|
|
4
|
+
using FLINT's fmpz_poly_t.
|
|
5
|
+
|
|
6
|
+
AUTHORS:
|
|
7
|
+
|
|
8
|
+
- David Roe, Julian Rueth (2013-03-21) -- initial version
|
|
9
|
+
"""
|
|
10
|
+
#*****************************************************************************
|
|
11
|
+
# Copyright (C) 2013 David Roe <roed.math@gmail.com>
|
|
12
|
+
# Julian Rueth <julian.rueth@fsfe.org>
|
|
13
|
+
#
|
|
14
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
15
|
+
# as published by the Free Software Foundation; either version 2 of
|
|
16
|
+
# the License, or (at your option) any later version.
|
|
17
|
+
# http://www.gnu.org/licenses/
|
|
18
|
+
#*****************************************************************************
|
|
19
|
+
|
|
20
|
+
from cysignals.signals cimport sig_on, sig_off
|
|
21
|
+
from cpython.list cimport PyList_Check, PyList_New, PyList_Append
|
|
22
|
+
|
|
23
|
+
from sage.ext.stdsage cimport PY_NEW
|
|
24
|
+
|
|
25
|
+
from sage.rings.padics.common_conversion cimport cconv_mpz_t_out_shared, cconv_mpz_t_shared, cconv_mpq_t_out_shared, cconv_mpq_t_shared, cconv_shared
|
|
26
|
+
|
|
27
|
+
from sage.rings.integer cimport Integer
|
|
28
|
+
from sage.rings.rational cimport Rational
|
|
29
|
+
from sage.rings.padics.padic_generic_element cimport pAdicGenericElement
|
|
30
|
+
from sage.rings.finite_rings.integer_mod cimport IntegerMod_abstract
|
|
31
|
+
from sage.rings.finite_rings.integer_mod_ring import Zmod
|
|
32
|
+
|
|
33
|
+
from sage.libs.flint.fmpz cimport *
|
|
34
|
+
from sage.libs.flint.fmpz_poly cimport *
|
|
35
|
+
from sage.libs.flint.fmpz_poly_sage cimport *
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
DEF CELEMENT_IS_PY_OBJECT = False
|
|
39
|
+
|
|
40
|
+
cdef inline int cconstruct(celement value, PowComputer_ prime_pow) except -1:
|
|
41
|
+
"""
|
|
42
|
+
Construct a new element.
|
|
43
|
+
|
|
44
|
+
INPUT:
|
|
45
|
+
|
|
46
|
+
- ``unit`` -- an ``celement`` to be initialized
|
|
47
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
48
|
+
"""
|
|
49
|
+
fmpz_poly_init(value)
|
|
50
|
+
|
|
51
|
+
cdef inline int cdestruct(celement value, PowComputer_ prime_pow) except -1:
|
|
52
|
+
"""
|
|
53
|
+
Deallocate an element.
|
|
54
|
+
|
|
55
|
+
INPUT:
|
|
56
|
+
|
|
57
|
+
- ``unit`` -- an ``celement`` to be cleared
|
|
58
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
59
|
+
"""
|
|
60
|
+
fmpz_poly_clear(value)
|
|
61
|
+
|
|
62
|
+
cdef inline int ccmp(celement a, celement b, long prec, bint reduce_a, bint reduce_b, PowComputer_ prime_pow) except -2:
|
|
63
|
+
"""
|
|
64
|
+
Comparison of two elements.
|
|
65
|
+
|
|
66
|
+
INPUT:
|
|
67
|
+
|
|
68
|
+
- ``a`` -- an ``celement``
|
|
69
|
+
- ``b`` -- an ``celement``
|
|
70
|
+
- ``prec`` -- a long, the precision of the comparison
|
|
71
|
+
- ``reduce_a`` -- a bint, whether ``a`` needs to be reduced
|
|
72
|
+
- ``reduce_b`` -- a bint, whether ``b`` needs to be reduced
|
|
73
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
74
|
+
|
|
75
|
+
OUTPUT:
|
|
76
|
+
|
|
77
|
+
- If neither ``a`` nor ``b`` needs to be reduced, returns
|
|
78
|
+
-1 (if `a < b`), 0 (if `a == b`) or 1 (if `a > b`)
|
|
79
|
+
|
|
80
|
+
- If at least one needs to be reduced, returns
|
|
81
|
+
0 (if ``a == b mod p^prec``) or 1 (otherwise)
|
|
82
|
+
"""
|
|
83
|
+
csub(prime_pow.poly_ccmp, a, b, prec, prime_pow)
|
|
84
|
+
creduce(prime_pow.poly_ccmp, prime_pow.poly_ccmp, prec, prime_pow)
|
|
85
|
+
|
|
86
|
+
if reduce_a or reduce_b:
|
|
87
|
+
return not ciszero(prime_pow.poly_ccmp, prime_pow)
|
|
88
|
+
|
|
89
|
+
if prec == 0:
|
|
90
|
+
return 0
|
|
91
|
+
|
|
92
|
+
if ciszero(prime_pow.poly_ccmp, prime_pow):
|
|
93
|
+
return 0
|
|
94
|
+
|
|
95
|
+
cdef long da = fmpz_poly_degree(a)
|
|
96
|
+
cdef long db = fmpz_poly_degree(b)
|
|
97
|
+
if da < db:
|
|
98
|
+
return -1
|
|
99
|
+
elif da > db:
|
|
100
|
+
return 1
|
|
101
|
+
|
|
102
|
+
cdef long cmp
|
|
103
|
+
cdef long i
|
|
104
|
+
for i in range(da+1):
|
|
105
|
+
fmpz_poly_get_coeff_fmpz(prime_pow.fmpz_ccmp, prime_pow.poly_ccmp, i)
|
|
106
|
+
cmp = fmpz_cmp_si(prime_pow.fmpz_ccmp, 0)
|
|
107
|
+
if cmp < 0:
|
|
108
|
+
return -1
|
|
109
|
+
elif cmp > 0:
|
|
110
|
+
return 1
|
|
111
|
+
assert False
|
|
112
|
+
|
|
113
|
+
cdef inline int cneg(celement out, celement a, long prec, PowComputer_ prime_pow) except -1:
|
|
114
|
+
"""
|
|
115
|
+
Negation
|
|
116
|
+
|
|
117
|
+
Note that no reduction is performed.
|
|
118
|
+
|
|
119
|
+
INPUT:
|
|
120
|
+
|
|
121
|
+
- ``out`` -- an ``celement`` to store the negation
|
|
122
|
+
- ``a`` -- an ``celement`` to be negated
|
|
123
|
+
- ``prec`` -- a long, the precision: ignored
|
|
124
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
125
|
+
"""
|
|
126
|
+
fmpz_poly_neg(out, a)
|
|
127
|
+
|
|
128
|
+
cdef inline int cadd(celement out, celement a, celement b, long prec, PowComputer_ prime_pow) except -1:
|
|
129
|
+
"""
|
|
130
|
+
Addition
|
|
131
|
+
|
|
132
|
+
Note that no reduction is performed.
|
|
133
|
+
|
|
134
|
+
INPUT:
|
|
135
|
+
|
|
136
|
+
- ``out`` -- an ``celement`` to store the sum
|
|
137
|
+
- ``a`` -- an ``celement``, the first summand
|
|
138
|
+
- ``b`` -- an ``celement``, the second summand
|
|
139
|
+
- ``prec`` -- a long, the precision: ignored
|
|
140
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
141
|
+
"""
|
|
142
|
+
fmpz_poly_add(out, a, b)
|
|
143
|
+
|
|
144
|
+
cdef inline bint creduce(celement out, celement a, long prec, PowComputer_ prime_pow) except -1:
|
|
145
|
+
"""
|
|
146
|
+
Reduce modulo a power of the maximal ideal.
|
|
147
|
+
|
|
148
|
+
INPUT:
|
|
149
|
+
|
|
150
|
+
- ``out`` -- an ``celement`` to store the reduction
|
|
151
|
+
- ``a`` -- the element to be reduced
|
|
152
|
+
- ``prec`` -- a long, the precision to reduce modulo
|
|
153
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
154
|
+
|
|
155
|
+
OUTPUT: ``True`` if the reduction is zero; ``False`` otherwise
|
|
156
|
+
"""
|
|
157
|
+
if prec == 0:
|
|
158
|
+
csetzero(out, prime_pow)
|
|
159
|
+
return True
|
|
160
|
+
sig_on()
|
|
161
|
+
fmpz_poly_rem(out, a, prime_pow.get_modulus(prec)[0])
|
|
162
|
+
fmpz_poly_scalar_mod_fmpz(out, out, prime_pow.pow_fmpz_t_tmp(prec)[0])
|
|
163
|
+
sig_off()
|
|
164
|
+
return ciszero(out, prime_pow)
|
|
165
|
+
|
|
166
|
+
cdef inline bint creduce_small(celement out, celement a, long prec, PowComputer_ prime_pow) except -1:
|
|
167
|
+
"""
|
|
168
|
+
Reduce modulo a power of the maximal ideal.
|
|
169
|
+
|
|
170
|
+
This function assumes that at most one addition/subtraction has
|
|
171
|
+
happened on reduced inputs. For integral inputs this translates
|
|
172
|
+
to the assumption that `-p^prec < a < 2p^prec`.
|
|
173
|
+
|
|
174
|
+
INPUT:
|
|
175
|
+
|
|
176
|
+
- ``out`` -- an ``celement`` to store the reduction
|
|
177
|
+
- ``a`` -- the element to be reduced
|
|
178
|
+
- ``prec`` -- a long, the precision to reduce modulo
|
|
179
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
180
|
+
|
|
181
|
+
OUTPUT: ``True`` if the reduction is zero; ``False`` otherwise
|
|
182
|
+
"""
|
|
183
|
+
return creduce(out, a, prec, prime_pow)
|
|
184
|
+
|
|
185
|
+
cdef inline long cremove(celement out, celement a, long prec, PowComputer_ prime_pow, bint reduce_relative=False) except -1:
|
|
186
|
+
"""
|
|
187
|
+
Extract the maximum power of the uniformizer dividing this element.
|
|
188
|
+
|
|
189
|
+
INPUT:
|
|
190
|
+
|
|
191
|
+
- ``out`` -- an ``celement`` to store the unit
|
|
192
|
+
- ``a`` -- the element whose valuation and unit are desired
|
|
193
|
+
- ``prec`` -- a long, used if `a = 0`
|
|
194
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
195
|
+
- ``reduce_relative`` -- a bint: whether the final result
|
|
196
|
+
should be reduced at precision ``prec`` (case ``False``)
|
|
197
|
+
or ``prec - valuation`` (case ``True``)
|
|
198
|
+
|
|
199
|
+
OUTPUT:
|
|
200
|
+
|
|
201
|
+
- if `a = 0`, returns prec (the value of ``out`` is undefined).
|
|
202
|
+
Otherwise, returns the number of times `p` divides `a`.
|
|
203
|
+
"""
|
|
204
|
+
if ciszero(a, prime_pow):
|
|
205
|
+
return prec
|
|
206
|
+
cdef long ret = cvaluation(a, prec, prime_pow)
|
|
207
|
+
if ret:
|
|
208
|
+
sig_on()
|
|
209
|
+
fmpz_poly_scalar_divexact_fmpz(out, a, (<PowComputer_flint_unram>prime_pow).pow_fmpz_t_tmp(ret)[0])
|
|
210
|
+
sig_off()
|
|
211
|
+
else:
|
|
212
|
+
fmpz_poly_set(out, a)
|
|
213
|
+
return ret
|
|
214
|
+
|
|
215
|
+
cdef inline long cvaluation(celement a, long prec, PowComputer_ prime_pow) except -1:
|
|
216
|
+
"""
|
|
217
|
+
Return the maximum power of the uniformizer dividing this
|
|
218
|
+
element.
|
|
219
|
+
|
|
220
|
+
This function differs from :meth:`cremove` in that the unit is
|
|
221
|
+
discarded.
|
|
222
|
+
|
|
223
|
+
INPUT:
|
|
224
|
+
|
|
225
|
+
- ``a`` -- the element whose valuation is desired
|
|
226
|
+
- ``prec`` -- a long, used if `a = 0`
|
|
227
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
228
|
+
|
|
229
|
+
OUTPUT:
|
|
230
|
+
|
|
231
|
+
- if `a = 0`, returns prec. Otherwise, returns the number of
|
|
232
|
+
times p divides a.
|
|
233
|
+
"""
|
|
234
|
+
if ciszero(a, prime_pow):
|
|
235
|
+
return prec
|
|
236
|
+
cdef long ret = maxordp
|
|
237
|
+
cdef long val
|
|
238
|
+
cdef long i
|
|
239
|
+
for i in range(fmpz_poly_length(a)):
|
|
240
|
+
fmpz_poly_get_coeff_fmpz(prime_pow.fmpz_cval, a, i)
|
|
241
|
+
if fmpz_is_zero(prime_pow.fmpz_cval):
|
|
242
|
+
continue
|
|
243
|
+
val = fmpz_remove(prime_pow.fmpz_cval, prime_pow.fmpz_cval, prime_pow.fprime)
|
|
244
|
+
if val < ret:
|
|
245
|
+
ret = val
|
|
246
|
+
return ret
|
|
247
|
+
|
|
248
|
+
cdef inline bint cisunit(celement a, PowComputer_ prime_pow) except -1:
|
|
249
|
+
"""
|
|
250
|
+
Return whether this element has valuation zero.
|
|
251
|
+
|
|
252
|
+
INPUT:
|
|
253
|
+
|
|
254
|
+
- ``a`` -- the element to test
|
|
255
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
256
|
+
|
|
257
|
+
OUTPUT: ``True`` if `a` has valuation 0, and ``False`` otherwise
|
|
258
|
+
"""
|
|
259
|
+
fmpz_poly_scalar_mod_fmpz(prime_pow.poly_cisunit, a, prime_pow.fprime)
|
|
260
|
+
return not ciszero(prime_pow.poly_cisunit, prime_pow)
|
|
261
|
+
|
|
262
|
+
cdef inline int cshift(celement out, celement rem, celement a, long n, long prec, PowComputer_ prime_pow, bint reduce_afterward) except -1:
|
|
263
|
+
"""
|
|
264
|
+
Multiplies by a power of the uniformizer.
|
|
265
|
+
|
|
266
|
+
INPUT:
|
|
267
|
+
|
|
268
|
+
- ``out`` -- a ``celement`` to store the result. If `n >= 0`
|
|
269
|
+
then out will be set to `a * p^n`
|
|
270
|
+
If `n < 0`, out will be set to `a // p^-n`.
|
|
271
|
+
- ``rem`` -- a ``celement`` to store the remainder of the division
|
|
272
|
+
Should not be aliased with `a`
|
|
273
|
+
- ``a`` -- the element to shift
|
|
274
|
+
- ``n`` -- long, the amount to shift by
|
|
275
|
+
- ``prec`` -- long, a precision modulo which to reduce
|
|
276
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
277
|
+
- ``reduce_afterward`` -- whether to reduce afterward
|
|
278
|
+
"""
|
|
279
|
+
if n > 0:
|
|
280
|
+
fmpz_poly_zero(rem)
|
|
281
|
+
fmpz_poly_scalar_mul_fmpz(out, a, prime_pow.pow_fmpz_t_tmp(n)[0])
|
|
282
|
+
elif n < 0:
|
|
283
|
+
sig_on()
|
|
284
|
+
fmpz_poly_scalar_mod_fmpz(rem, a, prime_pow.pow_fmpz_t_tmp(-n)[0])
|
|
285
|
+
fmpz_poly_scalar_fdiv_fmpz(out, a, prime_pow.pow_fmpz_t_tmp(-n)[0])
|
|
286
|
+
sig_off()
|
|
287
|
+
else:
|
|
288
|
+
fmpz_poly_zero(rem)
|
|
289
|
+
fmpz_poly_set(out, a)
|
|
290
|
+
if reduce_afterward:
|
|
291
|
+
creduce(out, out, prec, prime_pow)
|
|
292
|
+
|
|
293
|
+
cdef inline int cshift_notrunc(celement out, celement a, long n, long prec, PowComputer_ prime_pow, bint reduce_afterward) except -1:
|
|
294
|
+
"""
|
|
295
|
+
Multiplies by a power of the uniformizer, assuming that the
|
|
296
|
+
valuation of a is at least -n.
|
|
297
|
+
|
|
298
|
+
INPUT:
|
|
299
|
+
|
|
300
|
+
- ``out`` -- an ``celement`` to store the result. If `n >= 0`
|
|
301
|
+
then out will be set to `a * p^n`
|
|
302
|
+
If `n < 0`, out will be set to `a // p^-n`.
|
|
303
|
+
- ``a`` -- the element to shift. Assumes that the valuation of a
|
|
304
|
+
is at least -n.
|
|
305
|
+
- ``n`` -- long, the amount to shift by
|
|
306
|
+
- ``prec`` -- long, a precision modulo which to reduce
|
|
307
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
308
|
+
- ``reduce_afterward`` -- whether to reduce afterward
|
|
309
|
+
"""
|
|
310
|
+
if n > 0:
|
|
311
|
+
fmpz_poly_scalar_mul_fmpz(out, a, prime_pow.pow_fmpz_t_tmp(n)[0])
|
|
312
|
+
elif n < 0:
|
|
313
|
+
sig_on()
|
|
314
|
+
fmpz_poly_scalar_divexact_fmpz(out, a, prime_pow.pow_fmpz_t_tmp(-n)[0])
|
|
315
|
+
sig_off()
|
|
316
|
+
else:
|
|
317
|
+
fmpz_poly_set(out, a)
|
|
318
|
+
if reduce_afterward:
|
|
319
|
+
creduce(out, out, prec, prime_pow)
|
|
320
|
+
|
|
321
|
+
cdef inline int csub(celement out, celement a, celement b, long prec, PowComputer_ prime_pow) except -1:
|
|
322
|
+
"""
|
|
323
|
+
Subtraction.
|
|
324
|
+
|
|
325
|
+
Note that no reduction is performed.
|
|
326
|
+
|
|
327
|
+
INPUT:
|
|
328
|
+
|
|
329
|
+
- ``out`` -- an ``celement`` to store the difference
|
|
330
|
+
- ``a`` -- an ``celement``, the first input
|
|
331
|
+
- ``b`` -- an ``celement``, the second input
|
|
332
|
+
- ``prec`` -- a long, the precision: ignored
|
|
333
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
334
|
+
"""
|
|
335
|
+
fmpz_poly_sub(out, a, b)
|
|
336
|
+
|
|
337
|
+
cdef inline int cinvert(celement out, celement a, long prec, PowComputer_ prime_pow) except -1:
|
|
338
|
+
"""
|
|
339
|
+
Inversion
|
|
340
|
+
|
|
341
|
+
The result will be reduced modulo p^prec.
|
|
342
|
+
|
|
343
|
+
INPUT:
|
|
344
|
+
|
|
345
|
+
- ``out`` -- an ``celement`` to store the inverse
|
|
346
|
+
- ``a`` -- an ``celement``, the element to be inverted
|
|
347
|
+
- ``prec`` -- a long, the precision
|
|
348
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
349
|
+
"""
|
|
350
|
+
sig_on()
|
|
351
|
+
try:
|
|
352
|
+
fmpz_poly_set(prime_pow.poly_cinv, prime_pow.get_modulus(prec)[0])
|
|
353
|
+
fmpz_poly_primitive_part(prime_pow.poly_cinv, prime_pow.poly_cinv)
|
|
354
|
+
|
|
355
|
+
fmpz_poly_content(prime_pow.fmpz_cinv, a)
|
|
356
|
+
fmpz_poly_scalar_divexact_fmpz(out, a, prime_pow.fmpz_cinv)
|
|
357
|
+
|
|
358
|
+
fmpz_poly_xgcd(prime_pow.fmpz_cinv2, out, prime_pow.poly_cinv2, out, prime_pow.poly_cinv)
|
|
359
|
+
if fmpz_is_zero(prime_pow.fmpz_cinv2):
|
|
360
|
+
raise ValueError("polynomials are not coprime")
|
|
361
|
+
|
|
362
|
+
fmpz_mul(prime_pow.fmpz_cinv2, prime_pow.fmpz_cinv, prime_pow.fmpz_cinv2)
|
|
363
|
+
if not fmpz_invmod(prime_pow.fmpz_cinv2, prime_pow.fmpz_cinv2, prime_pow.pow_fmpz_t_tmp(prec)[0]):
|
|
364
|
+
raise ValueError("content or xgcd is not a unit")
|
|
365
|
+
fmpz_poly_scalar_mul_fmpz(out, out, prime_pow.fmpz_cinv2)
|
|
366
|
+
|
|
367
|
+
creduce(out, out, prec, prime_pow)
|
|
368
|
+
finally:
|
|
369
|
+
sig_off()
|
|
370
|
+
|
|
371
|
+
cdef inline int cmul(celement out, celement a, celement b, long prec, PowComputer_ prime_pow) except -1:
|
|
372
|
+
"""
|
|
373
|
+
Multiplication.
|
|
374
|
+
|
|
375
|
+
Note that no reduction is performed.
|
|
376
|
+
|
|
377
|
+
INPUT:
|
|
378
|
+
|
|
379
|
+
- ``out`` -- an ``celement`` to store the product
|
|
380
|
+
- ``a`` -- an ``celement``, the first input
|
|
381
|
+
- ``b`` -- an ``celement``, the second input
|
|
382
|
+
- ``prec`` -- a long, the precision: ignored
|
|
383
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
384
|
+
"""
|
|
385
|
+
fmpz_poly_mul(out, a, b)
|
|
386
|
+
|
|
387
|
+
cdef inline int cdivunit(celement out, celement a, celement b, long prec, PowComputer_ prime_pow) except -1:
|
|
388
|
+
"""
|
|
389
|
+
Division.
|
|
390
|
+
|
|
391
|
+
The inversion is performed modulo p^prec. Note that no reduction
|
|
392
|
+
is performed after the product.
|
|
393
|
+
|
|
394
|
+
INPUT:
|
|
395
|
+
|
|
396
|
+
- ``out`` -- an ``celement`` to store the quotient
|
|
397
|
+
- ``a`` -- an ``celement``, the first input
|
|
398
|
+
- ``b`` -- an ``celement``, the second input
|
|
399
|
+
- ``prec`` -- a long, the precision
|
|
400
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
401
|
+
"""
|
|
402
|
+
cinvert(prime_pow.aliasing, b, prec, prime_pow)
|
|
403
|
+
cmul(out, a, prime_pow.aliasing, prec, prime_pow)
|
|
404
|
+
|
|
405
|
+
cdef inline int csetone(celement out, PowComputer_ prime_pow) except -1:
|
|
406
|
+
"""
|
|
407
|
+
Set to 1.
|
|
408
|
+
|
|
409
|
+
INPUT:
|
|
410
|
+
|
|
411
|
+
- ``out`` -- the ``celement`` in which to store 1
|
|
412
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
413
|
+
"""
|
|
414
|
+
fmpz_poly_set_ui(out, 1)
|
|
415
|
+
|
|
416
|
+
cdef inline int csetzero(celement out, PowComputer_ prime_pow) except -1:
|
|
417
|
+
"""
|
|
418
|
+
Set to 0.
|
|
419
|
+
|
|
420
|
+
INPUT:
|
|
421
|
+
|
|
422
|
+
- ``out`` -- the ``celement`` in which to store 0
|
|
423
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
424
|
+
"""
|
|
425
|
+
fmpz_poly_set_ui(out, 0)
|
|
426
|
+
|
|
427
|
+
cdef inline bint cisone(celement a, PowComputer_ prime_pow) except -1:
|
|
428
|
+
"""
|
|
429
|
+
Return whether this element is equal to 1.
|
|
430
|
+
|
|
431
|
+
INPUT:
|
|
432
|
+
|
|
433
|
+
- ``a`` -- the element to test
|
|
434
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
435
|
+
|
|
436
|
+
OUTPUT: ``True`` if `a = 1`, and ``False`` otherwise
|
|
437
|
+
"""
|
|
438
|
+
return fmpz_poly_is_one(a)
|
|
439
|
+
|
|
440
|
+
cdef inline bint ciszero(celement a, PowComputer_ prime_pow) except -1:
|
|
441
|
+
"""
|
|
442
|
+
Return whether this element is equal to 0.
|
|
443
|
+
|
|
444
|
+
INPUT:
|
|
445
|
+
|
|
446
|
+
- ``a`` -- the element to test
|
|
447
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
448
|
+
|
|
449
|
+
OUTPUT: ``True`` if `a = 0`, and ``False`` otherwise
|
|
450
|
+
"""
|
|
451
|
+
return fmpz_poly_is_zero(a)
|
|
452
|
+
|
|
453
|
+
cdef inline int cpow(celement out, celement a, mpz_t n, long prec, PowComputer_ prime_pow) except -1:
|
|
454
|
+
"""
|
|
455
|
+
Exponentiation.
|
|
456
|
+
|
|
457
|
+
INPUT:
|
|
458
|
+
|
|
459
|
+
- ``out`` -- the ``celement`` in which to store the result
|
|
460
|
+
- ``a`` -- the base
|
|
461
|
+
- ``n`` -- an ``mpz_t``, the exponent
|
|
462
|
+
- ``prec`` -- a long, the working absolute precision
|
|
463
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
464
|
+
"""
|
|
465
|
+
if mpz_sgn(n) < 0:
|
|
466
|
+
raise NotImplementedError("negative exponent")
|
|
467
|
+
elif mpz_sgn(n) == 0:
|
|
468
|
+
csetone(out, prime_pow)
|
|
469
|
+
elif mpz_even_p(n):
|
|
470
|
+
mpz_divexact_ui(prime_pow.mpz_cpow, n, 2)
|
|
471
|
+
cpow(out, a, prime_pow.mpz_cpow, prec, prime_pow)
|
|
472
|
+
fmpz_poly_sqr(out, out)
|
|
473
|
+
else:
|
|
474
|
+
mpz_sub_ui(prime_pow.mpz_cpow, n, 1)
|
|
475
|
+
cpow(out, a, prime_pow.mpz_cpow, prec, prime_pow)
|
|
476
|
+
fmpz_poly_mul(out, out, a)
|
|
477
|
+
|
|
478
|
+
creduce(out, out, prec, prime_pow)
|
|
479
|
+
|
|
480
|
+
cdef inline int ccopy(celement out, celement a, PowComputer_ prime_pow) except -1:
|
|
481
|
+
"""
|
|
482
|
+
Copying.
|
|
483
|
+
|
|
484
|
+
INPUT:
|
|
485
|
+
|
|
486
|
+
- ``out`` -- the ``celement`` to store the result
|
|
487
|
+
- ``a`` -- the element to copy
|
|
488
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
489
|
+
"""
|
|
490
|
+
fmpz_poly_set(out, a)
|
|
491
|
+
|
|
492
|
+
cdef inline cpickle(celement a, PowComputer_ prime_pow):
|
|
493
|
+
"""
|
|
494
|
+
Serialization into objects that Sage knows how to pickle.
|
|
495
|
+
|
|
496
|
+
INPUT:
|
|
497
|
+
|
|
498
|
+
- ``a`` -- the element to pickle
|
|
499
|
+
- ``prime_pow`` the PowComputer for the ring
|
|
500
|
+
|
|
501
|
+
OUTPUT:
|
|
502
|
+
|
|
503
|
+
- a serializable object storing ``a``.
|
|
504
|
+
"""
|
|
505
|
+
return fmpz_poly_get_str(a).decode("UTF-8")
|
|
506
|
+
|
|
507
|
+
cdef inline int cunpickle(celement out, x, PowComputer_ prime_pow) except -1:
|
|
508
|
+
"""
|
|
509
|
+
Reconstruction from the output of :meth:`cpickle`.
|
|
510
|
+
|
|
511
|
+
INPUT:
|
|
512
|
+
|
|
513
|
+
- ``out`` -- the ``celement`` in which to store the result
|
|
514
|
+
- ``x`` -- the result of :meth:`cpickle`
|
|
515
|
+
- ``prime_pow`` -- the PowComputer for the ring
|
|
516
|
+
"""
|
|
517
|
+
byte_string = x.encode("UTF-8")
|
|
518
|
+
cdef char* c_str = byte_string
|
|
519
|
+
fmpz_poly_set_str(out, c_str)
|
|
520
|
+
|
|
521
|
+
cdef inline long chash(celement a, long ordp, long prec, PowComputer_ prime_pow) except -1:
|
|
522
|
+
"""
|
|
523
|
+
Hashing.
|
|
524
|
+
|
|
525
|
+
INPUT:
|
|
526
|
+
|
|
527
|
+
- ``a`` -- a ``celement`` storing the underlying element to hash
|
|
528
|
+
- ``ordp`` -- a long storing the valuation
|
|
529
|
+
- ``prec`` -- a long storing the precision
|
|
530
|
+
- ``prime_pow`` -- a PowComputer for the ring
|
|
531
|
+
"""
|
|
532
|
+
if ciszero(a, prime_pow):
|
|
533
|
+
return 0
|
|
534
|
+
|
|
535
|
+
cdef Integer h = PY_NEW(Integer)
|
|
536
|
+
fmpz_poly_get_coeff_mpz(h.value, a, 0)
|
|
537
|
+
return hash(h)
|
|
538
|
+
|
|
539
|
+
cdef inline cmodp_rep(fmpz_poly_t rep, fmpz_poly_t value, expansion_mode mode, bint return_list, PowComputer_ prime_pow):
|
|
540
|
+
"""
|
|
541
|
+
Compute a polynomial that is reduced modulo p and equivalent to the given value.
|
|
542
|
+
|
|
543
|
+
INPUT:
|
|
544
|
+
|
|
545
|
+
- ``rep`` -- the reduction mod p
|
|
546
|
+
- ``value`` -- the element to be reduced
|
|
547
|
+
- ``mode`` -- if ``smallest_mode``, the coefficients of the reduction
|
|
548
|
+
` will be between -p/2 and p/2 instead of between 0 and p
|
|
549
|
+
- ``return_list`` -- boolean, whether to return a list of integers giving the coefficients of the expansion
|
|
550
|
+
- ``prime_pow`` -- a PowComputer for the ring
|
|
551
|
+
"""
|
|
552
|
+
cdef long i
|
|
553
|
+
cdef fmpz* c
|
|
554
|
+
cdef Integer digit
|
|
555
|
+
sig_on()
|
|
556
|
+
fmpz_poly_scalar_mod_fmpz(rep, value, prime_pow.fprime)
|
|
557
|
+
sig_off()
|
|
558
|
+
if return_list or mode == smallest_mode:
|
|
559
|
+
L = []
|
|
560
|
+
for i in range(fmpz_poly_length(rep)):
|
|
561
|
+
c = fmpz_poly_get_coeff_ptr(rep, i)
|
|
562
|
+
if mode == smallest_mode and fmpz_cmp(c, prime_pow.half_prime) > 0:
|
|
563
|
+
fmpz_sub(c, c, prime_pow.fprime)
|
|
564
|
+
if return_list:
|
|
565
|
+
digit = PY_NEW(Integer)
|
|
566
|
+
fmpz_get_mpz(digit.value, c)
|
|
567
|
+
L.append(digit)
|
|
568
|
+
if return_list:
|
|
569
|
+
return L
|
|
570
|
+
|
|
571
|
+
# the expansion_mode enum is defined in padic_template_element_header.pxi
|
|
572
|
+
cdef inline cexpansion_next(fmpz_poly_t value, expansion_mode mode, long curpower, PowComputer_ prime_pow):
|
|
573
|
+
"""
|
|
574
|
+
Return the next digit in a `p`-adic expansion of ``value``.
|
|
575
|
+
|
|
576
|
+
INPUT:
|
|
577
|
+
|
|
578
|
+
- ``value`` -- the `p`-adic element whose expansion is desired
|
|
579
|
+
- ``mode`` -- either ``simple_mode`` or ``smallest_mode``
|
|
580
|
+
- ``curpower`` -- the current power of `p` for which the coefficient
|
|
581
|
+
is being found. Only used in ``smallest_mode``
|
|
582
|
+
- ``prime_pow`` -- a ``PowComputer`` holding `p`-adic data
|
|
583
|
+
"""
|
|
584
|
+
if mode == teichmuller_mode:
|
|
585
|
+
raise NotImplementedError
|
|
586
|
+
ans = []
|
|
587
|
+
cdef fmpz* c
|
|
588
|
+
cdef long i
|
|
589
|
+
cdef Integer digit
|
|
590
|
+
for i in range(fmpz_poly_length(value)):
|
|
591
|
+
c = fmpz_poly_get_coeff_ptr(value, i)
|
|
592
|
+
fmpz_fdiv_qr(c, prime_pow.fmpz_cexp, c, prime_pow.fprime)
|
|
593
|
+
if mode == smallest_mode and fmpz_cmp(prime_pow.fmpz_cexp, prime_pow.half_prime) > 0:
|
|
594
|
+
fmpz_sub(prime_pow.fmpz_cexp, prime_pow.fmpz_cexp, prime_pow.fprime)
|
|
595
|
+
fmpz_add_ui(c, c, 1)
|
|
596
|
+
digit = PY_NEW(Integer)
|
|
597
|
+
fmpz_get_mpz(digit.value, prime_pow.fmpz_cexp)
|
|
598
|
+
ans.append(digit)
|
|
599
|
+
_fmpz_poly_normalise(value)
|
|
600
|
+
return trim_zeros(ans) # defined in sage.rings.padics.misc and imported in padic_template_element
|
|
601
|
+
|
|
602
|
+
cdef inline cexpansion_getitem(fmpz_poly_t value, long m, PowComputer_ prime_pow):
|
|
603
|
+
"""
|
|
604
|
+
Return the `m`-th `p`-adic digit in the ``simple_mode`` expansion.
|
|
605
|
+
|
|
606
|
+
INPUT:
|
|
607
|
+
|
|
608
|
+
- ``value`` -- the `p`-adic element whose expansion is desired
|
|
609
|
+
- ``m`` -- nonnegative integer: which entry in the `p`-adic expansion to return
|
|
610
|
+
- ``prime_pow`` -- a ``PowComputer`` holding `p`-adic data
|
|
611
|
+
"""
|
|
612
|
+
ans = []
|
|
613
|
+
cdef fmpz* c
|
|
614
|
+
cdef long i
|
|
615
|
+
cdef Integer digit
|
|
616
|
+
for i in range(fmpz_poly_length(value)):
|
|
617
|
+
c = fmpz_poly_get_coeff_ptr(value, i)
|
|
618
|
+
if m > 0:
|
|
619
|
+
fmpz_fdiv_q(prime_pow.fmpz_cexp, c, prime_pow.pow_fmpz_t_tmp(m)[0])
|
|
620
|
+
fmpz_mod(prime_pow.fmpz_cexp, prime_pow.fmpz_cexp, prime_pow.fprime)
|
|
621
|
+
else:
|
|
622
|
+
fmpz_mod(prime_pow.fmpz_cexp, c, prime_pow.fprime)
|
|
623
|
+
digit = PY_NEW(Integer)
|
|
624
|
+
fmpz_get_mpz(digit.value, prime_pow.fmpz_cexp)
|
|
625
|
+
ans.append(digit)
|
|
626
|
+
_fmpz_poly_normalise(value)
|
|
627
|
+
return trim_zeros(ans) # defined in sage.rings.padics.misc and imported in padic_template_element
|
|
628
|
+
|
|
629
|
+
# The element is filled in for zero in the p-adic expansion if necessary.
|
|
630
|
+
_expansion_zero = []
|
|
631
|
+
|
|
632
|
+
cdef list ccoefficients(celement x, long valshift, long prec, PowComputer_ prime_pow):
|
|
633
|
+
"""
|
|
634
|
+
Return a list of coefficients, as elements that can be converted into the base ring.
|
|
635
|
+
|
|
636
|
+
INPUT:
|
|
637
|
+
|
|
638
|
+
- ``x`` -- a ``celement`` giving the underlying `p`-adic element, or possibly its unit part
|
|
639
|
+
- ``valshift`` -- a long giving the power of the uniformizer to shift `x` by
|
|
640
|
+
- ``prec`` -- a long, the (relative) precision desired, used in rational reconstruction
|
|
641
|
+
- ``prime_pow`` -- the ``PowComputer`` of the ring
|
|
642
|
+
"""
|
|
643
|
+
cdef Integer ansz
|
|
644
|
+
cdef Rational ansq
|
|
645
|
+
cdef long i
|
|
646
|
+
ans = []
|
|
647
|
+
for i in range(fmpz_poly_length(x)):
|
|
648
|
+
if valshift >= 0:
|
|
649
|
+
ansz = PY_NEW(Integer)
|
|
650
|
+
fmpz_poly_get_coeff_mpz(ansz.value, x, i)
|
|
651
|
+
if valshift > 0:
|
|
652
|
+
mpz_mul(ansz.value, ansz.value, prime_pow.pow_mpz_t_tmp(valshift))
|
|
653
|
+
ans.append(ansz)
|
|
654
|
+
else:
|
|
655
|
+
ansq = Rational.__new__(Rational)
|
|
656
|
+
fmpz_poly_get_coeff_mpz(mpq_numref(ansq.value), x, i)
|
|
657
|
+
mpz_set(mpq_denref(ansq.value), prime_pow.pow_mpz_t_tmp(-valshift))
|
|
658
|
+
mpq_canonicalize(ansq.value)
|
|
659
|
+
ans.append(ansq)
|
|
660
|
+
return ans
|
|
661
|
+
|
|
662
|
+
cdef int cteichmuller(celement out, celement value, long prec, PowComputer_ prime_pow) except -1:
|
|
663
|
+
r"""
|
|
664
|
+
Teichmuller lifting.
|
|
665
|
+
|
|
666
|
+
INPUT:
|
|
667
|
+
|
|
668
|
+
- ``out`` -- an ``celement`` which is set to a `q-1` root of unity
|
|
669
|
+
congruent to `value` mod `\pi`; or 0 if `a \equiv 0
|
|
670
|
+
\pmod{\pi}`.
|
|
671
|
+
- ``value`` -- an ``celement``, the element mod `\pi` to lift
|
|
672
|
+
- ``prec`` -- a long, the precision to which to lift
|
|
673
|
+
- ``prime_pow`` -- the ``PowComputer`` of the ring
|
|
674
|
+
|
|
675
|
+
ALGORITHM:
|
|
676
|
+
|
|
677
|
+
We use Hensel lifting to solve the equation `f(T)=T^q-T`. Instead of
|
|
678
|
+
dividing by the derivative of `f`, we divide by `( q - 1 )` whose first
|
|
679
|
+
digits coincide with `f'`. This does probably not yield quadratic
|
|
680
|
+
convergence but taking inverses would be much more expensive than what is
|
|
681
|
+
done here.
|
|
682
|
+
"""
|
|
683
|
+
fmpz_poly_set(out, value)
|
|
684
|
+
|
|
685
|
+
if prec == 0:
|
|
686
|
+
return 0
|
|
687
|
+
|
|
688
|
+
# fmpz_ctm = 1 / (1 - q) (mod p^prec)
|
|
689
|
+
fmpz_set_ui(prime_pow.fmpz_ctm, 1)
|
|
690
|
+
fmpz_sub(prime_pow.fmpz_ctm, prime_pow.fmpz_ctm, prime_pow.q)
|
|
691
|
+
fmpz_invmod(prime_pow.fmpz_ctm, prime_pow.fmpz_ctm, prime_pow.pow_fmpz_t_tmp(prec)[0])
|
|
692
|
+
while True:
|
|
693
|
+
# poly_ctm = out + fmpz_ctm*(out^q - out)
|
|
694
|
+
fmpz_get_mpz(prime_pow.mpz_ctm, prime_pow.q)
|
|
695
|
+
cpow(prime_pow.poly_ctm, out, prime_pow.mpz_ctm, prec, prime_pow)
|
|
696
|
+
csub(prime_pow.poly_ctm, prime_pow.poly_ctm, out, prec, prime_pow)
|
|
697
|
+
fmpz_poly_scalar_mul_fmpz(prime_pow.poly_ctm, prime_pow.poly_ctm, prime_pow.fmpz_ctm)
|
|
698
|
+
cadd(prime_pow.poly_ctm, prime_pow.poly_ctm, out, prec, prime_pow)
|
|
699
|
+
creduce(prime_pow.poly_ctm, prime_pow.poly_ctm, prec, prime_pow)
|
|
700
|
+
# break if out == poly_ctm
|
|
701
|
+
if ccmp(prime_pow.poly_ctm, out, prec, False, False, prime_pow) == 0:
|
|
702
|
+
return 0
|
|
703
|
+
# out = poly_ctm
|
|
704
|
+
fmpz_poly_set(out, prime_pow.poly_ctm)
|
|
705
|
+
|
|
706
|
+
cdef int cconv(celement out, x, long prec, long valshift, PowComputer_ prime_pow) except -2:
|
|
707
|
+
"""
|
|
708
|
+
Conversion from other Sage types.
|
|
709
|
+
|
|
710
|
+
INPUT:
|
|
711
|
+
|
|
712
|
+
- ``out`` -- an ``celement`` to store the output
|
|
713
|
+
|
|
714
|
+
- ``x`` -- a Sage element that can be converted to a `p`-adic element
|
|
715
|
+
|
|
716
|
+
- ``prec`` -- a long, giving the precision desired; absolute if
|
|
717
|
+
`valshift = 0`, relative if `valshift != 0`
|
|
718
|
+
|
|
719
|
+
- ``valshift`` -- the power of the uniformizer to divide by before
|
|
720
|
+
storing the result in ``out``
|
|
721
|
+
|
|
722
|
+
- ``prime_pow`` -- a PowComputer for the ring
|
|
723
|
+
"""
|
|
724
|
+
cdef long i
|
|
725
|
+
cdef long degree
|
|
726
|
+
|
|
727
|
+
if PyList_Check(x):
|
|
728
|
+
for i in range(len(x)):
|
|
729
|
+
cconv(prime_pow.poly_cconv, x[i], prec, valshift, prime_pow)
|
|
730
|
+
degree = fmpz_poly_degree(prime_pow.poly_cconv)
|
|
731
|
+
if degree == -1:
|
|
732
|
+
continue
|
|
733
|
+
elif degree == 0:
|
|
734
|
+
fmpz_poly_get_coeff_fmpz(prime_pow.fmpz_cconv, prime_pow.poly_cconv, 0)
|
|
735
|
+
fmpz_poly_set_coeff_fmpz(out, i, prime_pow.fmpz_cconv)
|
|
736
|
+
else:
|
|
737
|
+
raise ValueError
|
|
738
|
+
creduce(out, out, prec, prime_pow)
|
|
739
|
+
else:
|
|
740
|
+
cconv_shared(prime_pow.mpz_cconv, x, prec, valshift, prime_pow)
|
|
741
|
+
fmpz_poly_set_mpz(out, prime_pow.mpz_cconv)
|
|
742
|
+
|
|
743
|
+
cdef inline long cconv_mpq_t(celement out, mpq_t x, long prec, bint absolute, PowComputer_ prime_pow) except? -10000:
|
|
744
|
+
"""
|
|
745
|
+
A fast pathway for conversion of rationals that doesn't require
|
|
746
|
+
precomputation of the valuation.
|
|
747
|
+
|
|
748
|
+
INPUT:
|
|
749
|
+
|
|
750
|
+
- ``out`` -- an ``celement`` to store the output
|
|
751
|
+
- ``x`` -- an ``mpq_t`` giving the integer to be converted
|
|
752
|
+
- ``prec`` -- a long, giving the precision desired: absolute or
|
|
753
|
+
relative depending on the ``absolute`` input
|
|
754
|
+
- ``absolute`` -- if ``False`` then extracts the valuation and returns
|
|
755
|
+
it, storing the unit in ``out``; if ``True`` then just reduces ``x``
|
|
756
|
+
modulo the precision.
|
|
757
|
+
- ``prime_pow`` -- a PowComputer for the ring
|
|
758
|
+
|
|
759
|
+
OUTPUT:
|
|
760
|
+
|
|
761
|
+
If ``absolute`` is ``False`` then returns the valuation that was
|
|
762
|
+
extracted (``maxordp`` when `x = 0`).
|
|
763
|
+
"""
|
|
764
|
+
cdef long val
|
|
765
|
+
val = cconv_mpq_t_shared(prime_pow.mpz_cconv, x, prec, absolute, prime_pow)
|
|
766
|
+
fmpz_poly_set_mpz(out, prime_pow.mpz_cconv)
|
|
767
|
+
return val
|
|
768
|
+
|
|
769
|
+
cdef inline int cconv_mpq_t_out(mpq_t out, celement x, long valshift, long prec, PowComputer_ prime_pow) except -1:
|
|
770
|
+
"""
|
|
771
|
+
Convert the underlying `p`-adic element into a rational.
|
|
772
|
+
|
|
773
|
+
- ``out`` -- gives a rational approximating the input. Currently uses rational reconstruction but
|
|
774
|
+
may change in the future to use a more naive method
|
|
775
|
+
- ``x`` -- an ``celement`` giving the underlying `p`-adic element
|
|
776
|
+
- ``valshift`` -- a long giving the power of `p` to shift `x` by
|
|
777
|
+
-` ``prec`` -- a long, the precision of ``x``, used in rational reconstruction
|
|
778
|
+
- ``prime_pow`` -- a PowComputer for the ring
|
|
779
|
+
"""
|
|
780
|
+
cdef long degree = fmpz_poly_degree(x)
|
|
781
|
+
if degree > 0:
|
|
782
|
+
raise ValueError
|
|
783
|
+
elif degree == -1:
|
|
784
|
+
mpz_set_ui(prime_pow.mpz_cconv, 0)
|
|
785
|
+
else:
|
|
786
|
+
fmpz_poly_get_coeff_mpz(prime_pow.mpz_cconv, x, 0)
|
|
787
|
+
|
|
788
|
+
cconv_mpq_t_out_shared(out, prime_pow.mpz_cconv, valshift, prec, prime_pow)
|
|
789
|
+
|
|
790
|
+
cdef inline long cconv_mpz_t(celement out, mpz_t x, long prec, bint absolute, PowComputer_ prime_pow) except -2:
|
|
791
|
+
"""
|
|
792
|
+
A fast pathway for conversion of integers that doesn't require
|
|
793
|
+
precomputation of the valuation.
|
|
794
|
+
|
|
795
|
+
INPUT:
|
|
796
|
+
|
|
797
|
+
- ``out`` -- an ``celement`` to store the output
|
|
798
|
+
- ``x`` -- an ``mpz_t`` giving the integer to be converted
|
|
799
|
+
- ``prec`` -- a long, giving the precision desired: absolute or
|
|
800
|
+
relative depending on the ``absolute`` input
|
|
801
|
+
- ``absolute`` -- if False then extracts the valuation and returns
|
|
802
|
+
it, storing the unit in ``out``; if ``True`` then just reduces ``x``
|
|
803
|
+
modulo the precision
|
|
804
|
+
- ``prime_pow`` -- a PowComputer for the ring
|
|
805
|
+
|
|
806
|
+
OUTPUT:
|
|
807
|
+
|
|
808
|
+
- If ``absolute`` is False then returns the valuation that was
|
|
809
|
+
extracted (``maxordp`` when `x = 0`).
|
|
810
|
+
"""
|
|
811
|
+
cdef long val
|
|
812
|
+
val = cconv_mpz_t_shared(prime_pow.mpz_cconv, x, prec, absolute, prime_pow)
|
|
813
|
+
fmpz_poly_set_mpz(out, prime_pow.mpz_cconv)
|
|
814
|
+
return val
|
|
815
|
+
|
|
816
|
+
cdef inline int cconv_mpz_t_out(mpz_t out, celement x, long valshift, long prec, PowComputer_ prime_pow) except -1:
|
|
817
|
+
"""
|
|
818
|
+
Convert the underlying `p`-adic element into an integer if
|
|
819
|
+
possible.
|
|
820
|
+
|
|
821
|
+
- ``out`` -- stores the resulting integer as an integer between 0
|
|
822
|
+
and `p^{prec + valshift}`
|
|
823
|
+
- ``x`` -- an ``celement`` giving the underlying `p`-adic element
|
|
824
|
+
- ``valshift`` -- a long giving the power of `p` to shift `x` by
|
|
825
|
+
-` ``prec`` -- a long, the precision of ``x``: currently not used
|
|
826
|
+
- ``prime_pow`` -- a PowComputer for the ring
|
|
827
|
+
"""
|
|
828
|
+
cdef long degree = fmpz_poly_degree(x)
|
|
829
|
+
if degree > 0:
|
|
830
|
+
raise ValueError
|
|
831
|
+
elif degree == -1:
|
|
832
|
+
mpz_set_ui(prime_pow.mpz_cconv, 0)
|
|
833
|
+
else:
|
|
834
|
+
fmpz_poly_get_coeff_mpz(prime_pow.mpz_cconv, x, 0)
|
|
835
|
+
|
|
836
|
+
cconv_mpz_t_out_shared(out, prime_pow.mpz_cconv, valshift, prec, prime_pow)
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
## Extra functions ##
|
|
840
|
+
|
|
841
|
+
cdef cmatrix_mod_pn(celement a, long aprec, long valshift, PowComputer_ prime_pow):
|
|
842
|
+
r"""
|
|
843
|
+
Return the matrix of right multiplication by the element on
|
|
844
|
+
the power basis `1, x, x^2, \ldots, x^{d-1}` for this
|
|
845
|
+
extension field. Thus the *rows* of this matrix give the
|
|
846
|
+
images of each of the `x^i`. The entries of the matrices are
|
|
847
|
+
IntegerMod elements, defined modulo ``p^(self.absprec() / e)``.
|
|
848
|
+
"""
|
|
849
|
+
cdef Py_ssize_t i, j, d, deg = prime_pow.deg
|
|
850
|
+
cdef int fail
|
|
851
|
+
R = Zmod(prime_pow.pow_Integer(aprec))
|
|
852
|
+
cdef IntegerMod_abstract zero = R(0)
|
|
853
|
+
cdef IntegerMod_abstract item
|
|
854
|
+
L = []
|
|
855
|
+
cshift_notrunc(prime_pow.poly_matmod, a, valshift, aprec, prime_pow, True)
|
|
856
|
+
for i in range(deg):
|
|
857
|
+
L.append([])
|
|
858
|
+
d = fmpz_poly_degree(prime_pow.poly_matmod)
|
|
859
|
+
for j in range(d+1):
|
|
860
|
+
item = zero._new_c_from_long(0)
|
|
861
|
+
fmpz_poly_get_coeff_mpz(prime_pow.mpz_matmod, prime_pow.poly_matmod, j)
|
|
862
|
+
item.set_from_mpz(prime_pow.mpz_matmod)
|
|
863
|
+
L[-1].append(item)
|
|
864
|
+
for j in range(d+1,deg):
|
|
865
|
+
L[-1].append(zero)
|
|
866
|
+
fmpz_poly_shift_left(prime_pow.poly_matmod, prime_pow.poly_matmod, 1)
|
|
867
|
+
creduce(prime_pow.poly_matmod, prime_pow.poly_matmod, aprec, prime_pow)
|
|
868
|
+
from sage.matrix.constructor import matrix
|
|
869
|
+
return matrix(R, deg, deg, L)
|