passagemath-singular 10.6.31rc3__cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.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-singular might be problematic. Click here for more details.
- PySingular.cpython-314-aarch64-linux-gnu.so +0 -0
- passagemath_singular-10.6.31rc3.dist-info/METADATA +183 -0
- passagemath_singular-10.6.31rc3.dist-info/RECORD +490 -0
- passagemath_singular-10.6.31rc3.dist-info/WHEEL +6 -0
- passagemath_singular-10.6.31rc3.dist-info/top_level.txt +3 -0
- passagemath_singular.libs/libSingular-4-6a2a8666.4.1.so +0 -0
- passagemath_singular.libs/libcddgmp-ac579979.so.0.1.3 +0 -0
- passagemath_singular.libs/libfactory-4-66e33516.4.1.so +0 -0
- passagemath_singular.libs/libflint-81de1160.so.21.0.0 +0 -0
- passagemath_singular.libs/libgf2x-fbd36f80.so.3.0.0 +0 -0
- passagemath_singular.libs/libgfortran-e1b7dfc8.so.5.0.0 +0 -0
- passagemath_singular.libs/libgmp-93ebf16a.so.10.5.0 +0 -0
- passagemath_singular.libs/libgsl-e3525837.so.28.0.0 +0 -0
- passagemath_singular.libs/libmpfr-e0f11cf3.so.6.2.1 +0 -0
- passagemath_singular.libs/libntl-0043a3a2.so.44.0.1 +0 -0
- passagemath_singular.libs/libomalloc-0-06512335.9.6.so +0 -0
- passagemath_singular.libs/libopenblasp-r0-4c5b64b1.3.29.so +0 -0
- passagemath_singular.libs/libpolys-4-cb7246b5.4.1.so +0 -0
- passagemath_singular.libs/libreadline-28330744.so.8.2 +0 -0
- passagemath_singular.libs/libsingular_resources-4-8c425241.4.1.so +0 -0
- passagemath_singular.libs/libtinfo-f81c2d16.so.6.3 +0 -0
- sage/algebras/all__sagemath_singular.py +3 -0
- sage/algebras/fusion_rings/all.py +19 -0
- sage/algebras/fusion_rings/f_matrix.py +2448 -0
- sage/algebras/fusion_rings/fast_parallel_fmats_methods.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd +5 -0
- sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx +538 -0
- sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd +3 -0
- sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx +331 -0
- sage/algebras/fusion_rings/fusion_double.py +899 -0
- sage/algebras/fusion_rings/fusion_ring.py +1580 -0
- sage/algebras/fusion_rings/poly_tup_engine.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/fusion_rings/poly_tup_engine.pxd +24 -0
- sage/algebras/fusion_rings/poly_tup_engine.pyx +579 -0
- sage/algebras/fusion_rings/shm_managers.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/fusion_rings/shm_managers.pxd +24 -0
- sage/algebras/fusion_rings/shm_managers.pyx +780 -0
- sage/algebras/letterplace/all.py +1 -0
- sage/algebras/letterplace/free_algebra_element_letterplace.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/letterplace/free_algebra_element_letterplace.pxd +18 -0
- sage/algebras/letterplace/free_algebra_element_letterplace.pyx +755 -0
- sage/algebras/letterplace/free_algebra_letterplace.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/letterplace/free_algebra_letterplace.pxd +35 -0
- sage/algebras/letterplace/free_algebra_letterplace.pyx +914 -0
- sage/algebras/letterplace/letterplace_ideal.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/letterplace/letterplace_ideal.pyx +408 -0
- sage/algebras/quatalg/all.py +2 -0
- sage/algebras/quatalg/quaternion_algebra.py +4778 -0
- sage/algebras/quatalg/quaternion_algebra_cython.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/quatalg/quaternion_algebra_cython.pyx +261 -0
- sage/algebras/quatalg/quaternion_algebra_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/quatalg/quaternion_algebra_element.pxd +29 -0
- sage/algebras/quatalg/quaternion_algebra_element.pyx +2176 -0
- sage/all__sagemath_singular.py +11 -0
- sage/ext_data/all__sagemath_singular.py +1 -0
- sage/ext_data/singular/function_field/core.lib +98 -0
- sage/interfaces/all__sagemath_singular.py +1 -0
- sage/interfaces/singular.py +2835 -0
- sage/libs/all__sagemath_singular.py +1 -0
- sage/libs/singular/__init__.py +1 -0
- sage/libs/singular/decl.pxd +1168 -0
- sage/libs/singular/function.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/libs/singular/function.pxd +87 -0
- sage/libs/singular/function.pyx +1901 -0
- sage/libs/singular/function_factory.py +61 -0
- sage/libs/singular/groebner_strategy.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/libs/singular/groebner_strategy.pxd +22 -0
- sage/libs/singular/groebner_strategy.pyx +582 -0
- sage/libs/singular/option.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/libs/singular/option.pyx +671 -0
- sage/libs/singular/polynomial.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/libs/singular/polynomial.pxd +39 -0
- sage/libs/singular/polynomial.pyx +661 -0
- sage/libs/singular/ring.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/libs/singular/ring.pxd +58 -0
- sage/libs/singular/ring.pyx +893 -0
- sage/libs/singular/singular.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/libs/singular/singular.pxd +72 -0
- sage/libs/singular/singular.pyx +1944 -0
- sage/libs/singular/standard_options.py +145 -0
- sage/matrix/all__sagemath_singular.py +1 -0
- sage/matrix/matrix_mpolynomial_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_mpolynomial_dense.pxd +7 -0
- sage/matrix/matrix_mpolynomial_dense.pyx +615 -0
- sage/rings/all__sagemath_singular.py +1 -0
- sage/rings/function_field/all__sagemath_singular.py +1 -0
- sage/rings/function_field/derivations_polymod.py +911 -0
- sage/rings/function_field/element_polymod.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/function_field/element_polymod.pyx +406 -0
- sage/rings/function_field/function_field_polymod.py +2611 -0
- sage/rings/function_field/ideal_polymod.py +1775 -0
- sage/rings/function_field/order_polymod.py +1475 -0
- sage/rings/function_field/place_polymod.py +681 -0
- sage/rings/polynomial/all__sagemath_singular.py +1 -0
- sage/rings/polynomial/multi_polynomial_ideal_libsingular.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/polynomial/multi_polynomial_ideal_libsingular.pxd +5 -0
- sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx +339 -0
- sage/rings/polynomial/multi_polynomial_libsingular.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/polynomial/multi_polynomial_libsingular.pxd +30 -0
- sage/rings/polynomial/multi_polynomial_libsingular.pyx +6277 -0
- sage/rings/polynomial/plural.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/polynomial/plural.pxd +48 -0
- sage/rings/polynomial/plural.pyx +3171 -0
- sage/symbolic/all__sagemath_singular.py +1 -0
- sage/symbolic/comparison_impl.pxi +428 -0
- sage/symbolic/constants_c_impl.pxi +178 -0
- sage/symbolic/expression.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/symbolic/expression.pxd +7 -0
- sage/symbolic/expression.pyx +14200 -0
- sage/symbolic/getitem_impl.pxi +202 -0
- sage/symbolic/pynac.pxi +572 -0
- sage/symbolic/pynac_constant_impl.pxi +133 -0
- sage/symbolic/pynac_function_impl.pxi +206 -0
- sage/symbolic/pynac_impl.pxi +2576 -0
- sage/symbolic/pynac_wrap.h +124 -0
- sage/symbolic/series_impl.pxi +272 -0
- sage/symbolic/substitution_map_impl.pxi +94 -0
- sage_wheels/bin/ESingular +0 -0
- sage_wheels/bin/Singular +0 -0
- sage_wheels/bin/TSingular +0 -0
- sage_wheels/lib/singular/MOD/cohomo.la +41 -0
- sage_wheels/lib/singular/MOD/cohomo.so +0 -0
- sage_wheels/lib/singular/MOD/customstd.la +41 -0
- sage_wheels/lib/singular/MOD/customstd.so +0 -0
- sage_wheels/lib/singular/MOD/freealgebra.la +41 -0
- sage_wheels/lib/singular/MOD/freealgebra.so +0 -0
- sage_wheels/lib/singular/MOD/gfanlib.la +41 -0
- sage_wheels/lib/singular/MOD/gfanlib.so +0 -0
- sage_wheels/lib/singular/MOD/gitfan.la +41 -0
- sage_wheels/lib/singular/MOD/gitfan.so +0 -0
- sage_wheels/lib/singular/MOD/interval.la +41 -0
- sage_wheels/lib/singular/MOD/interval.so +0 -0
- sage_wheels/lib/singular/MOD/loctriv.la +41 -0
- sage_wheels/lib/singular/MOD/loctriv.so +0 -0
- sage_wheels/lib/singular/MOD/machinelearning.la +41 -0
- sage_wheels/lib/singular/MOD/machinelearning.so +0 -0
- sage_wheels/lib/singular/MOD/p_Procs_FieldGeneral.la +41 -0
- sage_wheels/lib/singular/MOD/p_Procs_FieldGeneral.so +0 -0
- sage_wheels/lib/singular/MOD/p_Procs_FieldIndep.la +41 -0
- sage_wheels/lib/singular/MOD/p_Procs_FieldIndep.so +0 -0
- sage_wheels/lib/singular/MOD/p_Procs_FieldQ.la +41 -0
- sage_wheels/lib/singular/MOD/p_Procs_FieldQ.so +0 -0
- sage_wheels/lib/singular/MOD/p_Procs_FieldZp.la +41 -0
- sage_wheels/lib/singular/MOD/p_Procs_FieldZp.so +0 -0
- sage_wheels/lib/singular/MOD/partialgb.la +41 -0
- sage_wheels/lib/singular/MOD/partialgb.so +0 -0
- sage_wheels/lib/singular/MOD/pyobject.la +41 -0
- sage_wheels/lib/singular/MOD/pyobject.so +0 -0
- sage_wheels/lib/singular/MOD/singmathic.la +41 -0
- sage_wheels/lib/singular/MOD/singmathic.so +0 -0
- sage_wheels/lib/singular/MOD/sispasm.la +41 -0
- sage_wheels/lib/singular/MOD/sispasm.so +0 -0
- sage_wheels/lib/singular/MOD/subsets.la +41 -0
- sage_wheels/lib/singular/MOD/subsets.so +0 -0
- sage_wheels/lib/singular/MOD/systhreads.la +41 -0
- sage_wheels/lib/singular/MOD/systhreads.so +0 -0
- sage_wheels/lib/singular/MOD/syzextra.la +41 -0
- sage_wheels/lib/singular/MOD/syzextra.so +0 -0
- sage_wheels/libexec/singular/MOD/change_cost +0 -0
- sage_wheels/libexec/singular/MOD/singularsurf +11 -0
- sage_wheels/libexec/singular/MOD/singularsurf_jupyter +9 -0
- sage_wheels/libexec/singular/MOD/singularsurf_win +10 -0
- sage_wheels/libexec/singular/MOD/solve_IP +0 -0
- sage_wheels/libexec/singular/MOD/surfex +16 -0
- sage_wheels/libexec/singular/MOD/toric_ideal +0 -0
- sage_wheels/share/factory/gftables/10201 +342 -0
- sage_wheels/share/factory/gftables/1024 +37 -0
- sage_wheels/share/factory/gftables/10609 +356 -0
- sage_wheels/share/factory/gftables/11449 +384 -0
- sage_wheels/share/factory/gftables/11881 +398 -0
- sage_wheels/share/factory/gftables/121 +6 -0
- sage_wheels/share/factory/gftables/12167 +408 -0
- sage_wheels/share/factory/gftables/125 +7 -0
- sage_wheels/share/factory/gftables/12769 +428 -0
- sage_wheels/share/factory/gftables/128 +7 -0
- sage_wheels/share/factory/gftables/1331 +47 -0
- sage_wheels/share/factory/gftables/1369 +48 -0
- sage_wheels/share/factory/gftables/14641 +490 -0
- sage_wheels/share/factory/gftables/15625 +523 -0
- sage_wheels/share/factory/gftables/16 +3 -0
- sage_wheels/share/factory/gftables/16129 +540 -0
- sage_wheels/share/factory/gftables/16384 +549 -0
- sage_wheels/share/factory/gftables/16807 +563 -0
- sage_wheels/share/factory/gftables/1681 +58 -0
- sage_wheels/share/factory/gftables/169 +8 -0
- sage_wheels/share/factory/gftables/17161 +574 -0
- sage_wheels/share/factory/gftables/1849 +64 -0
- sage_wheels/share/factory/gftables/18769 +628 -0
- sage_wheels/share/factory/gftables/19321 +646 -0
- sage_wheels/share/factory/gftables/19683 +659 -0
- sage_wheels/share/factory/gftables/2048 +71 -0
- sage_wheels/share/factory/gftables/2187 +75 -0
- sage_wheels/share/factory/gftables/2197 +76 -0
- sage_wheels/share/factory/gftables/2209 +76 -0
- sage_wheels/share/factory/gftables/22201 +742 -0
- sage_wheels/share/factory/gftables/22801 +762 -0
- sage_wheels/share/factory/gftables/2401 +82 -0
- sage_wheels/share/factory/gftables/243 +11 -0
- sage_wheels/share/factory/gftables/24389 +815 -0
- sage_wheels/share/factory/gftables/24649 +824 -0
- sage_wheels/share/factory/gftables/25 +3 -0
- sage_wheels/share/factory/gftables/256 +11 -0
- sage_wheels/share/factory/gftables/26569 +888 -0
- sage_wheels/share/factory/gftables/27 +3 -0
- sage_wheels/share/factory/gftables/27889 +932 -0
- sage_wheels/share/factory/gftables/2809 +96 -0
- sage_wheels/share/factory/gftables/28561 +954 -0
- sage_wheels/share/factory/gftables/289 +12 -0
- sage_wheels/share/factory/gftables/29791 +995 -0
- sage_wheels/share/factory/gftables/29929 +1000 -0
- sage_wheels/share/factory/gftables/3125 +107 -0
- sage_wheels/share/factory/gftables/32 +4 -0
- sage_wheels/share/factory/gftables/32041 +1070 -0
- sage_wheels/share/factory/gftables/32761 +1094 -0
- sage_wheels/share/factory/gftables/32768 +1095 -0
- sage_wheels/share/factory/gftables/343 +14 -0
- sage_wheels/share/factory/gftables/3481 +118 -0
- sage_wheels/share/factory/gftables/361 +14 -0
- sage_wheels/share/factory/gftables/36481 +1218 -0
- sage_wheels/share/factory/gftables/3721 +126 -0
- sage_wheels/share/factory/gftables/37249 +1244 -0
- sage_wheels/share/factory/gftables/38809 +1296 -0
- sage_wheels/share/factory/gftables/39601 +1322 -0
- sage_wheels/share/factory/gftables/4 +3 -0
- sage_wheels/share/factory/gftables/4096 +139 -0
- sage_wheels/share/factory/gftables/44521 +1486 -0
- sage_wheels/share/factory/gftables/4489 +152 -0
- sage_wheels/share/factory/gftables/49 +4 -0
- sage_wheels/share/factory/gftables/4913 +166 -0
- sage_wheels/share/factory/gftables/49729 +1660 -0
- sage_wheels/share/factory/gftables/5041 +170 -0
- sage_wheels/share/factory/gftables/50653 +1691 -0
- sage_wheels/share/factory/gftables/512 +20 -0
- sage_wheels/share/factory/gftables/51529 +1720 -0
- sage_wheels/share/factory/gftables/52441 +1750 -0
- sage_wheels/share/factory/gftables/529 +20 -0
- sage_wheels/share/factory/gftables/5329 +180 -0
- sage_wheels/share/factory/gftables/54289 +1812 -0
- sage_wheels/share/factory/gftables/57121 +1906 -0
- sage_wheels/share/factory/gftables/58081 +1938 -0
- sage_wheels/share/factory/gftables/59049 +1971 -0
- sage_wheels/share/factory/gftables/6241 +210 -0
- sage_wheels/share/factory/gftables/625 +23 -0
- sage_wheels/share/factory/gftables/63001 +2102 -0
- sage_wheels/share/factory/gftables/64 +5 -0
- sage_wheels/share/factory/gftables/6561 +221 -0
- sage_wheels/share/factory/gftables/6859 +231 -0
- sage_wheels/share/factory/gftables/6889 +232 -0
- sage_wheels/share/factory/gftables/729 +27 -0
- sage_wheels/share/factory/gftables/7921 +266 -0
- sage_wheels/share/factory/gftables/8 +3 -0
- sage_wheels/share/factory/gftables/81 +5 -0
- sage_wheels/share/factory/gftables/8192 +276 -0
- sage_wheels/share/factory/gftables/841 +30 -0
- sage_wheels/share/factory/gftables/9 +3 -0
- sage_wheels/share/factory/gftables/9409 +316 -0
- sage_wheels/share/factory/gftables/961 +34 -0
- sage_wheels/share/info/singular.info +191898 -0
- sage_wheels/share/singular/LIB/GND.lib +1359 -0
- sage_wheels/share/singular/LIB/JMBTest.lib +976 -0
- sage_wheels/share/singular/LIB/JMSConst.lib +1363 -0
- sage_wheels/share/singular/LIB/KVequiv.lib +699 -0
- sage_wheels/share/singular/LIB/SingularityDBM.lib +491 -0
- sage_wheels/share/singular/LIB/VecField.lib +1542 -0
- sage_wheels/share/singular/LIB/absfact.lib +959 -0
- sage_wheels/share/singular/LIB/ainvar.lib +730 -0
- sage_wheels/share/singular/LIB/aksaka.lib +419 -0
- sage_wheels/share/singular/LIB/alexpoly.lib +2542 -0
- sage_wheels/share/singular/LIB/algebra.lib +1193 -0
- sage_wheels/share/singular/LIB/all.lib +136 -0
- sage_wheels/share/singular/LIB/arcpoint.lib +514 -0
- sage_wheels/share/singular/LIB/arnold.lib +4553 -0
- sage_wheels/share/singular/LIB/arnoldclassify.lib +2058 -0
- sage_wheels/share/singular/LIB/arr.lib +3486 -0
- sage_wheels/share/singular/LIB/assprimeszerodim.lib +755 -0
- sage_wheels/share/singular/LIB/autgradalg.lib +3361 -0
- sage_wheels/share/singular/LIB/bfun.lib +1964 -0
- sage_wheels/share/singular/LIB/bimodules.lib +774 -0
- sage_wheels/share/singular/LIB/brillnoether.lib +226 -0
- sage_wheels/share/singular/LIB/brnoeth.lib +5017 -0
- sage_wheels/share/singular/LIB/central.lib +2169 -0
- sage_wheels/share/singular/LIB/chern.lib +4162 -0
- sage_wheels/share/singular/LIB/cimonom.lib +571 -0
- sage_wheels/share/singular/LIB/cisimplicial.lib +1835 -0
- sage_wheels/share/singular/LIB/classify.lib +3239 -0
- sage_wheels/share/singular/LIB/classify2.lib +1462 -0
- sage_wheels/share/singular/LIB/classifyMapGerms.lib +1515 -0
- sage_wheels/share/singular/LIB/classify_aeq.lib +3253 -0
- sage_wheels/share/singular/LIB/classifyceq.lib +2092 -0
- sage_wheels/share/singular/LIB/classifyci.lib +1133 -0
- sage_wheels/share/singular/LIB/combinat.lib +91 -0
- sage_wheels/share/singular/LIB/compregb.lib +276 -0
- sage_wheels/share/singular/LIB/control.lib +1636 -0
- sage_wheels/share/singular/LIB/crypto.lib +3795 -0
- sage_wheels/share/singular/LIB/curveInv.lib +667 -0
- sage_wheels/share/singular/LIB/curvepar.lib +1817 -0
- sage_wheels/share/singular/LIB/customstd.lib +100 -0
- sage_wheels/share/singular/LIB/deRham.lib +5979 -0
- sage_wheels/share/singular/LIB/decodegb.lib +2134 -0
- sage_wheels/share/singular/LIB/decomp.lib +1655 -0
- sage_wheels/share/singular/LIB/deflation.lib +872 -0
- sage_wheels/share/singular/LIB/deform.lib +925 -0
- sage_wheels/share/singular/LIB/difform.lib +3055 -0
- sage_wheels/share/singular/LIB/divisors.lib +750 -0
- sage_wheels/share/singular/LIB/dmod.lib +5817 -0
- sage_wheels/share/singular/LIB/dmodapp.lib +3269 -0
- sage_wheels/share/singular/LIB/dmodideal.lib +1211 -0
- sage_wheels/share/singular/LIB/dmodloc.lib +2645 -0
- sage_wheels/share/singular/LIB/dmodvar.lib +818 -0
- sage_wheels/share/singular/LIB/dummy.lib +17 -0
- sage_wheels/share/singular/LIB/elim.lib +1009 -0
- sage_wheels/share/singular/LIB/ellipticcovers.lib +548 -0
- sage_wheels/share/singular/LIB/enumpoints.lib +146 -0
- sage_wheels/share/singular/LIB/equising.lib +2127 -0
- sage_wheels/share/singular/LIB/ffmodstd.lib +2384 -0
- sage_wheels/share/singular/LIB/ffsolve.lib +1289 -0
- sage_wheels/share/singular/LIB/findifs.lib +778 -0
- sage_wheels/share/singular/LIB/finitediff.lib +1768 -0
- sage_wheels/share/singular/LIB/finvar.lib +7989 -0
- sage_wheels/share/singular/LIB/fpadim.lib +2429 -0
- sage_wheels/share/singular/LIB/fpalgebras.lib +1666 -0
- sage_wheels/share/singular/LIB/fpaprops.lib +1462 -0
- sage_wheels/share/singular/LIB/freegb.lib +3853 -0
- sage_wheels/share/singular/LIB/general.lib +1350 -0
- sage_wheels/share/singular/LIB/gfan.lib +1768 -0
- sage_wheels/share/singular/LIB/gitfan.lib +3130 -0
- sage_wheels/share/singular/LIB/gkdim.lib +99 -0
- sage_wheels/share/singular/LIB/gmspoly.lib +589 -0
- sage_wheels/share/singular/LIB/gmssing.lib +1739 -0
- sage_wheels/share/singular/LIB/goettsche.lib +909 -0
- sage_wheels/share/singular/LIB/graal.lib +1366 -0
- sage_wheels/share/singular/LIB/gradedModules.lib +2541 -0
- sage_wheels/share/singular/LIB/graphics.lib +360 -0
- sage_wheels/share/singular/LIB/grobcov.lib +7706 -0
- sage_wheels/share/singular/LIB/groups.lib +1123 -0
- sage_wheels/share/singular/LIB/grwalk.lib +507 -0
- sage_wheels/share/singular/LIB/hdepth.lib +194 -0
- sage_wheels/share/singular/LIB/help.cnf +57 -0
- sage_wheels/share/singular/LIB/hess.lib +1946 -0
- sage_wheels/share/singular/LIB/hnoether.lib +4292 -0
- sage_wheels/share/singular/LIB/hodge.lib +400 -0
- sage_wheels/share/singular/LIB/homolog.lib +1965 -0
- sage_wheels/share/singular/LIB/hyperel.lib +975 -0
- sage_wheels/share/singular/LIB/inout.lib +679 -0
- sage_wheels/share/singular/LIB/integralbasis.lib +6224 -0
- sage_wheels/share/singular/LIB/interval.lib +1418 -0
- sage_wheels/share/singular/LIB/intprog.lib +778 -0
- sage_wheels/share/singular/LIB/invar.lib +443 -0
- sage_wheels/share/singular/LIB/involut.lib +980 -0
- sage_wheels/share/singular/LIB/jacobson.lib +1215 -0
- sage_wheels/share/singular/LIB/kskernel.lib +534 -0
- sage_wheels/share/singular/LIB/latex.lib +3146 -0
- sage_wheels/share/singular/LIB/lejeune.lib +651 -0
- sage_wheels/share/singular/LIB/linalg.lib +2040 -0
- sage_wheels/share/singular/LIB/locnormal.lib +212 -0
- sage_wheels/share/singular/LIB/lrcalc.lib +526 -0
- sage_wheels/share/singular/LIB/makedbm.lib +294 -0
- sage_wheels/share/singular/LIB/mathml.lib +813 -0
- sage_wheels/share/singular/LIB/matrix.lib +1372 -0
- sage_wheels/share/singular/LIB/maxlike.lib +1132 -0
- sage_wheels/share/singular/LIB/methods.lib +212 -0
- sage_wheels/share/singular/LIB/moddiq.lib +322 -0
- sage_wheels/share/singular/LIB/modfinduni.lib +181 -0
- sage_wheels/share/singular/LIB/modnormal.lib +218 -0
- sage_wheels/share/singular/LIB/modprimdec.lib +1278 -0
- sage_wheels/share/singular/LIB/modquotient.lib +269 -0
- sage_wheels/share/singular/LIB/modstd.lib +1024 -0
- sage_wheels/share/singular/LIB/modular.lib +545 -0
- sage_wheels/share/singular/LIB/modules.lib +2561 -0
- sage_wheels/share/singular/LIB/modwalk.lib +609 -0
- sage_wheels/share/singular/LIB/mondromy.lib +1016 -0
- sage_wheels/share/singular/LIB/monomialideal.lib +3851 -0
- sage_wheels/share/singular/LIB/mprimdec.lib +2353 -0
- sage_wheels/share/singular/LIB/mregular.lib +1863 -0
- sage_wheels/share/singular/LIB/multigrading.lib +5629 -0
- sage_wheels/share/singular/LIB/ncHilb.lib +777 -0
- sage_wheels/share/singular/LIB/ncModslimgb.lib +791 -0
- sage_wheels/share/singular/LIB/ncalg.lib +16311 -0
- sage_wheels/share/singular/LIB/ncall.lib +31 -0
- sage_wheels/share/singular/LIB/ncdecomp.lib +468 -0
- sage_wheels/share/singular/LIB/ncfactor.lib +13371 -0
- sage_wheels/share/singular/LIB/ncfrac.lib +1023 -0
- sage_wheels/share/singular/LIB/nchilbert.lib +448 -0
- sage_wheels/share/singular/LIB/nchomolog.lib +759 -0
- sage_wheels/share/singular/LIB/ncloc.lib +361 -0
- sage_wheels/share/singular/LIB/ncpreim.lib +795 -0
- sage_wheels/share/singular/LIB/ncrat.lib +2849 -0
- sage_wheels/share/singular/LIB/nctools.lib +1887 -0
- sage_wheels/share/singular/LIB/nets.lib +1456 -0
- sage_wheels/share/singular/LIB/nfmodstd.lib +1000 -0
- sage_wheels/share/singular/LIB/nfmodsyz.lib +732 -0
- sage_wheels/share/singular/LIB/noether.lib +1106 -0
- sage_wheels/share/singular/LIB/normal.lib +8700 -0
- sage_wheels/share/singular/LIB/normaliz.lib +2226 -0
- sage_wheels/share/singular/LIB/ntsolve.lib +362 -0
- sage_wheels/share/singular/LIB/numerAlg.lib +560 -0
- sage_wheels/share/singular/LIB/numerDecom.lib +2261 -0
- sage_wheels/share/singular/LIB/olga.lib +1933 -0
- sage_wheels/share/singular/LIB/orbitparam.lib +351 -0
- sage_wheels/share/singular/LIB/parallel.lib +319 -0
- sage_wheels/share/singular/LIB/paraplanecurves.lib +3110 -0
- sage_wheels/share/singular/LIB/perron.lib +202 -0
- sage_wheels/share/singular/LIB/pfd.lib +2223 -0
- sage_wheels/share/singular/LIB/phindex.lib +642 -0
- sage_wheels/share/singular/LIB/pointid.lib +673 -0
- sage_wheels/share/singular/LIB/polybori.lib +1430 -0
- sage_wheels/share/singular/LIB/polyclass.lib +525 -0
- sage_wheels/share/singular/LIB/polylib.lib +1174 -0
- sage_wheels/share/singular/LIB/polymake.lib +1902 -0
- sage_wheels/share/singular/LIB/presolve.lib +1533 -0
- sage_wheels/share/singular/LIB/primdec.lib +9576 -0
- sage_wheels/share/singular/LIB/primdecint.lib +1782 -0
- sage_wheels/share/singular/LIB/primitiv.lib +401 -0
- sage_wheels/share/singular/LIB/puiseuxexpansions.lib +1631 -0
- sage_wheels/share/singular/LIB/purityfiltration.lib +960 -0
- sage_wheels/share/singular/LIB/qhmoduli.lib +1561 -0
- sage_wheels/share/singular/LIB/qmatrix.lib +293 -0
- sage_wheels/share/singular/LIB/random.lib +455 -0
- sage_wheels/share/singular/LIB/ratgb.lib +489 -0
- sage_wheels/share/singular/LIB/realclassify.lib +5759 -0
- sage_wheels/share/singular/LIB/realizationMatroids.lib +772 -0
- sage_wheels/share/singular/LIB/realrad.lib +1197 -0
- sage_wheels/share/singular/LIB/recover.lib +2628 -0
- sage_wheels/share/singular/LIB/redcgs.lib +3984 -0
- sage_wheels/share/singular/LIB/reesclos.lib +465 -0
- sage_wheels/share/singular/LIB/resbinomial.lib +2802 -0
- sage_wheels/share/singular/LIB/resgraph.lib +789 -0
- sage_wheels/share/singular/LIB/resjung.lib +820 -0
- sage_wheels/share/singular/LIB/resolve.lib +5110 -0
- sage_wheels/share/singular/LIB/resources.lib +170 -0
- sage_wheels/share/singular/LIB/reszeta.lib +5473 -0
- sage_wheels/share/singular/LIB/ring.lib +1328 -0
- sage_wheels/share/singular/LIB/ringgb.lib +343 -0
- sage_wheels/share/singular/LIB/rinvar.lib +1153 -0
- sage_wheels/share/singular/LIB/rootisolation.lib +1481 -0
- sage_wheels/share/singular/LIB/rootsmr.lib +709 -0
- sage_wheels/share/singular/LIB/rootsur.lib +886 -0
- sage_wheels/share/singular/LIB/rstandard.lib +607 -0
- sage_wheels/share/singular/LIB/rwalk.lib +336 -0
- sage_wheels/share/singular/LIB/sagbi.lib +1353 -0
- sage_wheels/share/singular/LIB/sagbiNormaliz.lib +1622 -0
- sage_wheels/share/singular/LIB/sagbiNormaliz0.lib +1498 -0
- sage_wheels/share/singular/LIB/sagbigrob.lib +449 -0
- sage_wheels/share/singular/LIB/schreyer.lib +321 -0
- sage_wheels/share/singular/LIB/schubert.lib +2551 -0
- sage_wheels/share/singular/LIB/sets.lib +524 -0
- sage_wheels/share/singular/LIB/sheafcoh.lib +1663 -0
- sage_wheels/share/singular/LIB/signcond.lib +437 -0
- sage_wheels/share/singular/LIB/sing.lib +1094 -0
- sage_wheels/share/singular/LIB/sing4ti2.lib +419 -0
- sage_wheels/share/singular/LIB/solve.lib +2243 -0
- sage_wheels/share/singular/LIB/spcurve.lib +1077 -0
- sage_wheels/share/singular/LIB/spectrum.lib +62 -0
- sage_wheels/share/singular/LIB/sresext.lib +757 -0
- sage_wheels/share/singular/LIB/ssi.lib +143 -0
- sage_wheels/share/singular/LIB/standard.lib +2769 -0
- sage_wheels/share/singular/LIB/stanleyreisner.lib +473 -0
- sage_wheels/share/singular/LIB/stdmodule.lib +547 -0
- sage_wheels/share/singular/LIB/stratify.lib +1070 -0
- sage_wheels/share/singular/LIB/surf.lib +506 -0
- sage_wheels/share/singular/LIB/surf_jupyter.lib +223 -0
- sage_wheels/share/singular/LIB/surfacesignature.lib +522 -0
- sage_wheels/share/singular/LIB/surfex.lib +1462 -0
- sage_wheels/share/singular/LIB/swalk.lib +877 -0
- sage_wheels/share/singular/LIB/symodstd.lib +1570 -0
- sage_wheels/share/singular/LIB/systhreads.lib +74 -0
- sage_wheels/share/singular/LIB/tasks.lib +1324 -0
- sage_wheels/share/singular/LIB/tateProdCplxNegGrad.lib +2412 -0
- sage_wheels/share/singular/LIB/teachstd.lib +858 -0
- sage_wheels/share/singular/LIB/template.lib +116 -0
- sage_wheels/share/singular/LIB/toric.lib +1119 -0
- sage_wheels/share/singular/LIB/transformation.lib +116 -0
- sage_wheels/share/singular/LIB/triang.lib +1197 -0
- sage_wheels/share/singular/LIB/tropical.lib +8741 -0
- sage_wheels/share/singular/LIB/tropicalEllipticCovers.lib +2922 -0
- sage_wheels/share/singular/LIB/tropicalNewton.lib +1128 -0
- sage_wheels/share/singular/LIB/tst.lib +1108 -0
- sage_wheels/share/singular/LIB/weierstr.lib +241 -0
- sage_wheels/share/singular/LIB/zeroset.lib +1478 -0
- sage_wheels/share/singular/emacs/.emacs-general +184 -0
- sage_wheels/share/singular/emacs/.emacs-singular +234 -0
- sage_wheels/share/singular/emacs/COPYING +44 -0
- sage_wheels/share/singular/emacs/cmd-cmpl.el +241 -0
- sage_wheels/share/singular/emacs/ex-cmpl.el +1681 -0
- sage_wheels/share/singular/emacs/hlp-cmpl.el +4318 -0
- sage_wheels/share/singular/emacs/lib-cmpl.el +179 -0
- sage_wheels/share/singular/emacs/singular.el +4273 -0
- sage_wheels/share/singular/emacs/singular.xpm +39 -0
- sage_wheels/share/singular/singular.idx +5002 -0
|
@@ -0,0 +1,1944 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-singular
|
|
2
|
+
"""
|
|
3
|
+
libSingular: Conversion Routines and Initialisation
|
|
4
|
+
|
|
5
|
+
AUTHOR:
|
|
6
|
+
|
|
7
|
+
- Martin Albrecht <malb@informatik.uni-bremen.de>
|
|
8
|
+
|
|
9
|
+
- Miguel Marco <mmarco@unizar.es> (2021): added transcendental extensions over Q
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
# ****************************************************************************
|
|
13
|
+
# Copyright (C) 2005, 2006 William Stein <wstein@gmail.com>
|
|
14
|
+
#
|
|
15
|
+
# This program is free software: you can redistribute it and/or modify
|
|
16
|
+
# it under the terms of the GNU General Public License as published by
|
|
17
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
18
|
+
# (at your option) any later version.
|
|
19
|
+
# https://www.gnu.org/licenses/
|
|
20
|
+
# ****************************************************************************
|
|
21
|
+
|
|
22
|
+
include "sage/libs/ntl/decl.pxi"
|
|
23
|
+
|
|
24
|
+
cdef extern from "limits.h":
|
|
25
|
+
long INT_MAX
|
|
26
|
+
long INT_MIN
|
|
27
|
+
|
|
28
|
+
import os
|
|
29
|
+
from warnings import warn
|
|
30
|
+
|
|
31
|
+
from libc.stdint cimport int64_t
|
|
32
|
+
from sage.libs.singular.decl cimport *
|
|
33
|
+
|
|
34
|
+
from sage.rings.polynomial.polydict import ETuple
|
|
35
|
+
from sage.libs.singular.function cimport new_sage_polynomial, access_singular_ring
|
|
36
|
+
|
|
37
|
+
from sage.rings.rational_field import RationalField
|
|
38
|
+
from sage.rings.integer_ring cimport IntegerRing_class
|
|
39
|
+
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic
|
|
40
|
+
from sage.rings.finite_rings.finite_field_base import FiniteField
|
|
41
|
+
from sage.rings.polynomial.polynomial_ring import PolynomialRing_field
|
|
42
|
+
from sage.rings.fraction_field import FractionField_generic
|
|
43
|
+
|
|
44
|
+
from sage.rings.finite_rings.finite_field_prime_modn import FiniteField_prime_modn
|
|
45
|
+
from sage.rings.finite_rings.finite_field_givaro import FiniteField_givaro
|
|
46
|
+
from sage.rings.finite_rings.finite_field_ntl_gf2e import FiniteField_ntl_gf2e
|
|
47
|
+
from sage.libs.gmp.all cimport *
|
|
48
|
+
|
|
49
|
+
from sage.cpython.string import FS_ENCODING
|
|
50
|
+
from sage.cpython.string cimport str_to_bytes, char_to_str, bytes_to_str
|
|
51
|
+
|
|
52
|
+
from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomialRing_libsingular
|
|
53
|
+
|
|
54
|
+
ctypedef struct fraction "fractionObject":
|
|
55
|
+
poly *numerator
|
|
56
|
+
poly *denominator
|
|
57
|
+
int complexity
|
|
58
|
+
|
|
59
|
+
_saved_options = (int(0),0,0)
|
|
60
|
+
|
|
61
|
+
cdef Rational si2sa_QQ(number *n, number **nn, ring *_ring):
|
|
62
|
+
"""
|
|
63
|
+
Create a sage rational number from a singular one.
|
|
64
|
+
|
|
65
|
+
INPUT:
|
|
66
|
+
|
|
67
|
+
- ``n`` -- a (pointer to) a singular rational number
|
|
68
|
+
|
|
69
|
+
- ``*n`` -- a pointer to a pointer like before
|
|
70
|
+
|
|
71
|
+
- ``_ ring`` -- a (pointer to) a singular ring, in whose coefficient field
|
|
72
|
+
lives ``n``
|
|
73
|
+
|
|
74
|
+
OUTPUT: a sage Rational
|
|
75
|
+
|
|
76
|
+
TESTS::
|
|
77
|
+
|
|
78
|
+
sage: P.<x,y,z> = QQ[]
|
|
79
|
+
sage: P(1/3).lc()
|
|
80
|
+
1/3
|
|
81
|
+
sage: P(1).lc()
|
|
82
|
+
1
|
|
83
|
+
sage: P(0).lc()
|
|
84
|
+
0
|
|
85
|
+
sage: P(-1/3).lc()
|
|
86
|
+
-1/3
|
|
87
|
+
sage: type(P(3).lc())
|
|
88
|
+
<class 'sage.rings.rational.Rational'>
|
|
89
|
+
"""
|
|
90
|
+
cdef number *nom
|
|
91
|
+
cdef number *denom
|
|
92
|
+
cdef mpq_t _z
|
|
93
|
+
|
|
94
|
+
cdef mpz_t nom_z, denom_z
|
|
95
|
+
|
|
96
|
+
cdef Rational z
|
|
97
|
+
|
|
98
|
+
mpq_init(_z)
|
|
99
|
+
|
|
100
|
+
# Immediate integers handles carry the tag 'SR_INT', i.e. the last bit is 1.
|
|
101
|
+
# This distinguishes immediate integers from other handles which point to
|
|
102
|
+
# structures aligned on 4 byte boundaries and therefore have last bit zero.
|
|
103
|
+
# (The second bit is reserved as tag to allow extensions of this scheme.)
|
|
104
|
+
# Using immediates as pointers and dereferencing them gives address errors.
|
|
105
|
+
nom = nlGetNumerator(n, _ring.cf)
|
|
106
|
+
mpz_init(nom_z)
|
|
107
|
+
|
|
108
|
+
if SR_HDL(nom) & SR_INT:
|
|
109
|
+
mpz_set_si(nom_z, SR_TO_INT(nom))
|
|
110
|
+
else:
|
|
111
|
+
mpz_set(nom_z,nom.z)
|
|
112
|
+
|
|
113
|
+
mpq_set_num(_z,nom_z)
|
|
114
|
+
nlDelete(&nom,_ring.cf)
|
|
115
|
+
mpz_clear(nom_z)
|
|
116
|
+
|
|
117
|
+
denom = nlGetDenom(n, _ring.cf)
|
|
118
|
+
mpz_init(denom_z)
|
|
119
|
+
|
|
120
|
+
if SR_HDL(denom) & SR_INT:
|
|
121
|
+
mpz_set_si(denom_z, SR_TO_INT(denom))
|
|
122
|
+
else:
|
|
123
|
+
mpz_set(denom_z,denom.z)
|
|
124
|
+
|
|
125
|
+
mpq_set_den(_z, denom_z)
|
|
126
|
+
nlDelete(&denom,_ring.cf)
|
|
127
|
+
mpz_clear(denom_z)
|
|
128
|
+
|
|
129
|
+
nn[0] = n
|
|
130
|
+
z = Rational()
|
|
131
|
+
z.set_from_mpq(_z)
|
|
132
|
+
mpq_clear(_z)
|
|
133
|
+
return z
|
|
134
|
+
|
|
135
|
+
cdef Integer si2sa_ZZ(number *n, ring *_ring):
|
|
136
|
+
"""
|
|
137
|
+
Create a sage integer number from a singular one.
|
|
138
|
+
|
|
139
|
+
INPUT:
|
|
140
|
+
|
|
141
|
+
- ``n`` -- a (pointer to) a singular integer number
|
|
142
|
+
|
|
143
|
+
- ``_ ring`` -- a (pointer to) a singular ring, in whose coefficient field
|
|
144
|
+
lives ``n``
|
|
145
|
+
|
|
146
|
+
OUTPUT: a sage Integer
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
TESTS::
|
|
150
|
+
|
|
151
|
+
sage: P.<x,y,z> = ZZ[]
|
|
152
|
+
sage: P(3).lc()
|
|
153
|
+
3
|
|
154
|
+
sage: P(0).lc()
|
|
155
|
+
0
|
|
156
|
+
sage: P(-3).lc()
|
|
157
|
+
-3
|
|
158
|
+
sage: P(-1234567890).lc()
|
|
159
|
+
-1234567890
|
|
160
|
+
sage: type(P(3).lc())
|
|
161
|
+
<class 'sage.rings.integer.Integer'>
|
|
162
|
+
"""
|
|
163
|
+
cdef Integer z
|
|
164
|
+
z = Integer()
|
|
165
|
+
z.set_from_mpz(<mpz_ptr>n)
|
|
166
|
+
return z
|
|
167
|
+
|
|
168
|
+
cdef FFgivE si2sa_GFqGivaro(number *n, ring *_ring, Cache_givaro cache):
|
|
169
|
+
"""
|
|
170
|
+
Create a sage element of a small finite field from a singular one.
|
|
171
|
+
|
|
172
|
+
INPUT:
|
|
173
|
+
|
|
174
|
+
- ``n`` -- a (pointer to) a singular number in a finite field
|
|
175
|
+
|
|
176
|
+
- ``_ ring`` -- a (pointer to) a singular ring, in whose coefficient field
|
|
177
|
+
lives ``n``
|
|
178
|
+
|
|
179
|
+
- ``cache`` -- a Givaro number field
|
|
180
|
+
|
|
181
|
+
OUTPUT: a sage element of ``cache``
|
|
182
|
+
|
|
183
|
+
TESTS::
|
|
184
|
+
|
|
185
|
+
sage: K.<a> = GF(5^3)
|
|
186
|
+
sage: R.<x,y,z> = PolynomialRing(K)
|
|
187
|
+
sage: K( (4*R(a)^2 + R(a))^3 )
|
|
188
|
+
a^2
|
|
189
|
+
sage: K(R(0))
|
|
190
|
+
0
|
|
191
|
+
"""
|
|
192
|
+
cdef poly *z
|
|
193
|
+
cdef int c, e
|
|
194
|
+
cdef int a
|
|
195
|
+
cdef int ret
|
|
196
|
+
cdef int order
|
|
197
|
+
cdef ring *cfRing = _ring.cf.extRing
|
|
198
|
+
|
|
199
|
+
if _ring.cf.cfIsZero(n,_ring.cf):
|
|
200
|
+
return cache._zero_element
|
|
201
|
+
elif _ring.cf.cfIsOne(n,_ring.cf):
|
|
202
|
+
return cache._one_element
|
|
203
|
+
|
|
204
|
+
z = <poly*>n
|
|
205
|
+
|
|
206
|
+
a = cache.objectptr.indeterminate()
|
|
207
|
+
ret = cache.objectptr.zero
|
|
208
|
+
order = cache.objectptr.cardinality() - 1
|
|
209
|
+
|
|
210
|
+
while z:
|
|
211
|
+
c = cache.objectptr.initi(c, <int64_t>p_GetCoeff(z, cfRing))
|
|
212
|
+
e = p_GetExp(z, 1, cfRing)
|
|
213
|
+
if e == 0:
|
|
214
|
+
ret = cache.objectptr.add(ret, c, ret)
|
|
215
|
+
else:
|
|
216
|
+
a = ( e * cache.objectptr.indeterminate() ) % order
|
|
217
|
+
ret = cache.objectptr.axpy(ret, c, a, ret)
|
|
218
|
+
z = <poly*>pNext(<poly*>z)
|
|
219
|
+
return (<FFgivE>cache._zero_element)._new_c(ret)
|
|
220
|
+
|
|
221
|
+
cdef FFgf2eE si2sa_GFqNTLGF2E(number *n, ring *_ring, Cache_ntl_gf2e cache):
|
|
222
|
+
"""
|
|
223
|
+
Create a sage element of a finite field of characteristic 2 from a
|
|
224
|
+
singular one.
|
|
225
|
+
|
|
226
|
+
INPUT:
|
|
227
|
+
|
|
228
|
+
- ``n`` -- a (pointer to) a singular number in a finite field
|
|
229
|
+
|
|
230
|
+
- ``_ ring`` -- a (pointer to) a singular ring, in whose coefficient field
|
|
231
|
+
lives ``n``
|
|
232
|
+
|
|
233
|
+
- ``cache`` -- a ntl_gf2e number field
|
|
234
|
+
|
|
235
|
+
OUTPUT: a sage element of ``cache``
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
TESTS::
|
|
239
|
+
|
|
240
|
+
sage: K.<a> = GF(2^20)
|
|
241
|
+
sage: P.<x,y,z> = K[]
|
|
242
|
+
sage: f = a^21*x^2 + 1 # indirect doctest
|
|
243
|
+
sage: f.lc()
|
|
244
|
+
a^11 + a^10 + a^8 + a^7 + a^6 + a^5 + a^2 + a
|
|
245
|
+
sage: type(f.lc())
|
|
246
|
+
<class 'sage.rings.finite_rings.element_ntl_gf2e.FiniteField_ntl_gf2eElement'>
|
|
247
|
+
"""
|
|
248
|
+
cdef poly *z
|
|
249
|
+
cdef long c
|
|
250
|
+
cdef int e
|
|
251
|
+
cdef FFgf2eE a
|
|
252
|
+
cdef FFgf2eE ret
|
|
253
|
+
cdef ring *cfRing = _ring.cf.extRing
|
|
254
|
+
|
|
255
|
+
if _ring.cf.cfIsZero(n,_ring.cf):
|
|
256
|
+
return cache._zero_element
|
|
257
|
+
elif _ring.cf.cfIsOne(n,_ring.cf):
|
|
258
|
+
return cache._one_element
|
|
259
|
+
|
|
260
|
+
z = <poly*>n
|
|
261
|
+
a = cache._gen
|
|
262
|
+
ret = cache._zero_element
|
|
263
|
+
|
|
264
|
+
while z:
|
|
265
|
+
c = <long>p_GetCoeff(z, cfRing)
|
|
266
|
+
e = p_GetExp(z, 1, cfRing)
|
|
267
|
+
ret += c * a**e
|
|
268
|
+
z = <poly*>pNext(<poly*>z)
|
|
269
|
+
return ret
|
|
270
|
+
|
|
271
|
+
cdef object si2sa_GFq_generic(number *n, ring *_ring, object base):
|
|
272
|
+
"""
|
|
273
|
+
Create a sage element of a generic finite field from a singular one.
|
|
274
|
+
|
|
275
|
+
INPUT:
|
|
276
|
+
|
|
277
|
+
- ``n`` -- a (pointer to) a singular number in a finite field
|
|
278
|
+
|
|
279
|
+
- ``_ ring`` -- a (pointer to) a singular ring, in whose coefficient field
|
|
280
|
+
lives ``n``
|
|
281
|
+
|
|
282
|
+
- ``base`` -- a sage finite field
|
|
283
|
+
|
|
284
|
+
OUTPUT: a sage element of ``base``
|
|
285
|
+
|
|
286
|
+
TESTS::
|
|
287
|
+
|
|
288
|
+
sage: K.<a> = GF(3^16)
|
|
289
|
+
sage: P.<x,y,z> = K[]
|
|
290
|
+
sage: f = a^21*x^2 + 1 # indirect doctest
|
|
291
|
+
sage: f.lc()
|
|
292
|
+
a^12 + a^11 + a^9 + a^8 + a^7 + 2*a^6 + a^5
|
|
293
|
+
sage: type(f.lc())
|
|
294
|
+
<class 'sage.rings.finite_rings.element_pari_ffelt.FiniteFieldElement_pari_ffelt'>
|
|
295
|
+
|
|
296
|
+
Try the largest characteristic which Singular supports::
|
|
297
|
+
|
|
298
|
+
sage: p = previous_prime(2^31)
|
|
299
|
+
sage: F.<a> = FiniteField(p^2)
|
|
300
|
+
sage: R.<x,y> = F[]
|
|
301
|
+
sage: R(-1).constant_coefficient() # indirect doctest
|
|
302
|
+
2147483646
|
|
303
|
+
"""
|
|
304
|
+
cdef poly *z
|
|
305
|
+
cdef long c
|
|
306
|
+
cdef int e
|
|
307
|
+
cdef object a
|
|
308
|
+
cdef object ret
|
|
309
|
+
cdef ring *cfRing = _ring.cf.extRing
|
|
310
|
+
|
|
311
|
+
if _ring.cf.type in (n_Zn, n_Znm):
|
|
312
|
+
return si2sa_ZZmod(n, _ring, base)
|
|
313
|
+
|
|
314
|
+
if _ring.cf.cfIsZero(n,_ring.cf):
|
|
315
|
+
return base.zero()
|
|
316
|
+
elif _ring.cf.cfIsOne(n,_ring.cf):
|
|
317
|
+
return base.one()
|
|
318
|
+
|
|
319
|
+
z = <poly*>n
|
|
320
|
+
|
|
321
|
+
a = base.gen()
|
|
322
|
+
ret = base.zero()
|
|
323
|
+
|
|
324
|
+
while z:
|
|
325
|
+
c = <long>p_GetCoeff(z, cfRing)
|
|
326
|
+
e = p_GetExp(z, 1, cfRing)
|
|
327
|
+
if e == 0:
|
|
328
|
+
ret = ret + c
|
|
329
|
+
elif c != 0:
|
|
330
|
+
ret = ret + c * a**e
|
|
331
|
+
z = <poly*>pNext(<poly*>z)
|
|
332
|
+
return ret
|
|
333
|
+
|
|
334
|
+
cdef object si2sa_transext_QQ(number *n, ring *_ring, object base):
|
|
335
|
+
"""
|
|
336
|
+
Create a sage element of a transcendental extension of ``QQ`` from a
|
|
337
|
+
singular one.
|
|
338
|
+
|
|
339
|
+
INPUT:
|
|
340
|
+
|
|
341
|
+
- ``n`` -- a (pointer to) a singular number in a transcendental extension
|
|
342
|
+
of the rationals
|
|
343
|
+
|
|
344
|
+
- ``_ ring`` -- a (pointer to) a singular ring, in whose coefficient field
|
|
345
|
+
lives ``n``
|
|
346
|
+
|
|
347
|
+
- ``base`` -- a sage FractionField
|
|
348
|
+
|
|
349
|
+
OUTPUT: a sage element of ``base``
|
|
350
|
+
|
|
351
|
+
TESTS::
|
|
352
|
+
|
|
353
|
+
sage: F = PolynomialRing(QQ,'a,b').fraction_field()
|
|
354
|
+
sage: F.inject_variables()
|
|
355
|
+
Defining a, b
|
|
356
|
+
sage: R.<x,y> = F[]
|
|
357
|
+
sage: a*x
|
|
358
|
+
a*x
|
|
359
|
+
sage: I = R.ideal([a*x])
|
|
360
|
+
sage: I
|
|
361
|
+
Ideal (a*x) of Multivariate Polynomial Ring in x, y over Fraction Field of Multivariate Polynomial Ring in a, b over Rational Field
|
|
362
|
+
sage: I.groebner_basis()
|
|
363
|
+
[x]
|
|
364
|
+
sage: I = R.ideal([a*x+b*y^2, (b+a)/(b-a)*x^3-3*y*x])
|
|
365
|
+
sage: I.groebner_basis()
|
|
366
|
+
[x^3 + (3*a - 3*b)/(a + b)*x*y, y^2 + a/b*x]
|
|
367
|
+
sage: R.term_order()
|
|
368
|
+
Degree reverse lexicographic term order
|
|
369
|
+
"""
|
|
370
|
+
|
|
371
|
+
cdef poly *numer
|
|
372
|
+
cdef poly *denom
|
|
373
|
+
cdef number *c
|
|
374
|
+
cdef int e
|
|
375
|
+
cdef fraction *frac
|
|
376
|
+
cdef object snumer
|
|
377
|
+
cdef object sdenom
|
|
378
|
+
|
|
379
|
+
cdef ring *cfRing = _ring.cf.extRing
|
|
380
|
+
|
|
381
|
+
if _ring.cf.cfIsZero(n,_ring.cf):
|
|
382
|
+
return base._zero_element
|
|
383
|
+
elif _ring.cf.cfIsOne(n,_ring.cf):
|
|
384
|
+
return base._one_element
|
|
385
|
+
|
|
386
|
+
snumer = base(0)
|
|
387
|
+
sdenom = base(0)
|
|
388
|
+
|
|
389
|
+
frac = <fraction*>n
|
|
390
|
+
|
|
391
|
+
numer = frac.numerator
|
|
392
|
+
denom = frac.denominator
|
|
393
|
+
|
|
394
|
+
while numer:
|
|
395
|
+
c = p_GetCoeff(numer, cfRing)
|
|
396
|
+
coeff = si2sa_QQ(c, &c, cfRing)
|
|
397
|
+
numer.coef = c
|
|
398
|
+
for i in range(base.ngens()):
|
|
399
|
+
e = p_GetExp(numer, i+1, cfRing)
|
|
400
|
+
if e!= 0:
|
|
401
|
+
coeff *= base.gen(i)**e
|
|
402
|
+
snumer += coeff
|
|
403
|
+
numer = <poly*>pNext(<poly*>numer)
|
|
404
|
+
|
|
405
|
+
if not denom:
|
|
406
|
+
sdenom = base(1)
|
|
407
|
+
else:
|
|
408
|
+
while denom:
|
|
409
|
+
c = p_GetCoeff(denom, cfRing)
|
|
410
|
+
coeff = si2sa_QQ(c, &c, cfRing)
|
|
411
|
+
denom.coef = c
|
|
412
|
+
for i in range(base.ngens()):
|
|
413
|
+
e = p_GetExp(denom, i+1, cfRing)
|
|
414
|
+
if e!= 0:
|
|
415
|
+
coeff *= base.gen(i)**e
|
|
416
|
+
sdenom += coeff
|
|
417
|
+
denom = <poly*>pNext(<poly*>denom)
|
|
418
|
+
|
|
419
|
+
return snumer/sdenom
|
|
420
|
+
|
|
421
|
+
cdef object si2sa_transext_FF(number *n, ring *_ring, object base):
|
|
422
|
+
"""
|
|
423
|
+
Create a sage element of a transcendental extension of a prime field from a
|
|
424
|
+
singular one.
|
|
425
|
+
|
|
426
|
+
INPUT:
|
|
427
|
+
|
|
428
|
+
- ``n`` -- a (pointer to) a singular number in a transcendental extension
|
|
429
|
+
of the rationals
|
|
430
|
+
|
|
431
|
+
- ``_ ring`` -- a (pointer to) a singular ring, in whose coefficient field
|
|
432
|
+
lives ``n``
|
|
433
|
+
|
|
434
|
+
- ``base`` -- a sage FractionField
|
|
435
|
+
|
|
436
|
+
OUTPUT: a sage element of ``base``
|
|
437
|
+
|
|
438
|
+
TESTS::
|
|
439
|
+
|
|
440
|
+
sage: F = PolynomialRing(FiniteField(7),'a,b').fraction_field()
|
|
441
|
+
sage: R.<x,y,z> = F[]
|
|
442
|
+
sage: n = R(5)
|
|
443
|
+
sage: n
|
|
444
|
+
-2
|
|
445
|
+
sage: type(n)
|
|
446
|
+
<class 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
|
|
447
|
+
"""
|
|
448
|
+
|
|
449
|
+
cdef poly *numer
|
|
450
|
+
cdef poly *denom
|
|
451
|
+
cdef number *c
|
|
452
|
+
cdef int e
|
|
453
|
+
cdef fraction *frac
|
|
454
|
+
cdef object snumer
|
|
455
|
+
cdef object sdenom
|
|
456
|
+
|
|
457
|
+
cdef ring *cfRing = _ring.cf.extRing
|
|
458
|
+
|
|
459
|
+
if _ring.cf.cfIsZero(n,_ring.cf):
|
|
460
|
+
return base._zero_element
|
|
461
|
+
elif _ring.cf.cfIsOne(n,_ring.cf):
|
|
462
|
+
return base._one_element
|
|
463
|
+
|
|
464
|
+
snumer = base(0)
|
|
465
|
+
sdenom = base(0)
|
|
466
|
+
|
|
467
|
+
frac = <fraction*>n
|
|
468
|
+
|
|
469
|
+
numer = frac.numerator
|
|
470
|
+
denom = frac.denominator
|
|
471
|
+
|
|
472
|
+
while numer:
|
|
473
|
+
|
|
474
|
+
c = p_GetCoeff(numer, cfRing)
|
|
475
|
+
coeff = base(cfRing.cf.cfInt(c, cfRing.cf))
|
|
476
|
+
numer.coef = c
|
|
477
|
+
for i in range(base.ngens()):
|
|
478
|
+
e = p_GetExp(numer, i+1, cfRing)
|
|
479
|
+
if e!= 0:
|
|
480
|
+
coeff *= base.gen(i)**e
|
|
481
|
+
snumer += coeff
|
|
482
|
+
numer = <poly*>pNext(<poly*>numer)
|
|
483
|
+
|
|
484
|
+
if not denom:
|
|
485
|
+
sdenom = base(1)
|
|
486
|
+
else:
|
|
487
|
+
while denom:
|
|
488
|
+
c = p_GetCoeff(denom, cfRing)
|
|
489
|
+
coeff = base(cfRing.cf.cfInt(c, cfRing.cf))
|
|
490
|
+
denom.coef = c
|
|
491
|
+
for i in range(base.ngens()):
|
|
492
|
+
e = p_GetExp(denom, i+1, cfRing)
|
|
493
|
+
if e!= 0:
|
|
494
|
+
coeff *= base.gen(i)**e
|
|
495
|
+
sdenom += coeff
|
|
496
|
+
denom = <poly*>pNext(<poly*>denom)
|
|
497
|
+
|
|
498
|
+
return snumer/sdenom
|
|
499
|
+
|
|
500
|
+
cdef object si2sa_NF(number *n, ring *_ring, object base):
|
|
501
|
+
"""
|
|
502
|
+
Create a sage element of a number field from a singular one.
|
|
503
|
+
|
|
504
|
+
INPUT:
|
|
505
|
+
|
|
506
|
+
- ``n`` -- a (pointer to) a singular number in an algebraic extension of
|
|
507
|
+
the rationals
|
|
508
|
+
|
|
509
|
+
- ``_ ring`` -- a (pointer to) a singular ring, in whose coefficient field
|
|
510
|
+
lives ``n``
|
|
511
|
+
|
|
512
|
+
- ``base`` -- a sage NumberField
|
|
513
|
+
|
|
514
|
+
OUTPUT: a sage element of ``base``
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
TESTS::
|
|
518
|
+
|
|
519
|
+
sage: x = polygen(ZZ, 'x')
|
|
520
|
+
sage: K.<a> = NumberField(x^2 - 2)
|
|
521
|
+
sage: P.<x,y,z> = K[]
|
|
522
|
+
sage: f = a^21*x^2 + 1 # indirect doctest
|
|
523
|
+
sage: f.lc()
|
|
524
|
+
1024*a
|
|
525
|
+
sage: type(f.lc())
|
|
526
|
+
<class 'sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_quadratic_sqrt'>
|
|
527
|
+
"""
|
|
528
|
+
cdef poly *z
|
|
529
|
+
cdef number *c
|
|
530
|
+
cdef int e
|
|
531
|
+
cdef object a
|
|
532
|
+
cdef object ret
|
|
533
|
+
cdef ring *cfRing = _ring.cf.extRing
|
|
534
|
+
|
|
535
|
+
if _ring.cf.cfIsZero(n,_ring.cf):
|
|
536
|
+
return base._zero_element
|
|
537
|
+
elif _ring.cf.cfIsOne(n,_ring.cf):
|
|
538
|
+
return base._one_element
|
|
539
|
+
|
|
540
|
+
z = <poly*>n
|
|
541
|
+
|
|
542
|
+
a = base.gen()
|
|
543
|
+
ret = base(0)
|
|
544
|
+
|
|
545
|
+
while z:
|
|
546
|
+
# p_GetCoeff returns a reference
|
|
547
|
+
c = p_GetCoeff(z, cfRing)
|
|
548
|
+
# si2sa_QQ might modify c
|
|
549
|
+
coeff = si2sa_QQ(c, &c, cfRing)
|
|
550
|
+
# so we force it back.
|
|
551
|
+
z.coef = c
|
|
552
|
+
#pSetCoeff0(z,c)
|
|
553
|
+
#p_SetCoeff(z, c, cfRing)
|
|
554
|
+
# rather than trying to let Cython and C++ automagically modify it
|
|
555
|
+
#coeff = si2sa_QQ(p_GetCoeff(z, cfRing), cfRing)
|
|
556
|
+
e = p_GetExp(z, 1, cfRing)
|
|
557
|
+
if e == 0:
|
|
558
|
+
ret = ret + coeff
|
|
559
|
+
elif coeff != 0:
|
|
560
|
+
ret = ret + coeff * a**e
|
|
561
|
+
z = <poly*>pNext(<poly*>z)
|
|
562
|
+
return base(ret)
|
|
563
|
+
|
|
564
|
+
cdef inline object si2sa_ZZmod(number *n, ring *_ring, object base):
|
|
565
|
+
"""
|
|
566
|
+
Create a sage element of a ring of integers modulo n from a singular one.
|
|
567
|
+
|
|
568
|
+
INPUT:
|
|
569
|
+
|
|
570
|
+
- ``n`` -- a (pointer to) a singular number in a ring of integers modulo n
|
|
571
|
+
|
|
572
|
+
- ``_ ring`` -- a (pointer to) a singular ring, in whose coefficient field
|
|
573
|
+
lives ``n``
|
|
574
|
+
|
|
575
|
+
- ``base`` -- a sage IntegerModRing
|
|
576
|
+
|
|
577
|
+
OUTPUT: a sage element of ``base``
|
|
578
|
+
|
|
579
|
+
TESTS::
|
|
580
|
+
|
|
581
|
+
sage: P.<x,y,z> = Integers(10)[]
|
|
582
|
+
sage: P(3).lc()
|
|
583
|
+
3
|
|
584
|
+
sage: P(13).lc()
|
|
585
|
+
3
|
|
586
|
+
|
|
587
|
+
sage: P.<x,y,z> = Integers(16)[]
|
|
588
|
+
sage: P(3).lc()
|
|
589
|
+
3
|
|
590
|
+
sage: P(19).lc()
|
|
591
|
+
3
|
|
592
|
+
|
|
593
|
+
sage: P.<x,y,z> = Integers(3**2)[]
|
|
594
|
+
sage: P(3).lc()
|
|
595
|
+
3
|
|
596
|
+
sage: P(12).lc()
|
|
597
|
+
3
|
|
598
|
+
|
|
599
|
+
sage: P.<x,y,z> = Integers(2^32)[]
|
|
600
|
+
sage: P(2^32-1).lc()
|
|
601
|
+
4294967295
|
|
602
|
+
|
|
603
|
+
sage: P(3).lc()
|
|
604
|
+
3
|
|
605
|
+
|
|
606
|
+
sage: P.<x,y,z> = Integers(17^20)[]
|
|
607
|
+
sage: P(17^19 + 3).lc()
|
|
608
|
+
239072435685151324847156
|
|
609
|
+
|
|
610
|
+
sage: P(3)
|
|
611
|
+
3
|
|
612
|
+
"""
|
|
613
|
+
cdef Integer ret
|
|
614
|
+
if _ring.cf.type == n_Z2m:
|
|
615
|
+
return base(<long>n)
|
|
616
|
+
elif _ring.cf.type == n_Znm or _ring.cf.type == n_Zn:
|
|
617
|
+
ret = Integer()
|
|
618
|
+
ret.set_from_mpz(<mpz_ptr>n)
|
|
619
|
+
return base(ret)
|
|
620
|
+
|
|
621
|
+
return base(_ring.cf.cfInt(n,_ring.cf))
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
cdef list singular_monomial_exponents(poly *p, ring *r):
|
|
625
|
+
r"""
|
|
626
|
+
Return the list of exponents of monomial ``p``.
|
|
627
|
+
"""
|
|
628
|
+
cdef int v
|
|
629
|
+
cdef list ml = [None] * r.N
|
|
630
|
+
|
|
631
|
+
for v in range(1, r.N + 1):
|
|
632
|
+
ml[v-1] = p_GetExp(p, v, r)
|
|
633
|
+
return ml
|
|
634
|
+
|
|
635
|
+
cpdef list si2sa_resolution(Resolution res):
|
|
636
|
+
r"""
|
|
637
|
+
Pull the data from Singular resolution ``res`` to construct a Sage
|
|
638
|
+
resolution.
|
|
639
|
+
|
|
640
|
+
INPUT:
|
|
641
|
+
|
|
642
|
+
- ``res`` -- Singular resolution
|
|
643
|
+
|
|
644
|
+
The procedure is destructive and ``res`` is not usable afterward.
|
|
645
|
+
|
|
646
|
+
EXAMPLES::
|
|
647
|
+
|
|
648
|
+
sage: from sage.libs.singular.singular import si2sa_resolution
|
|
649
|
+
sage: from sage.libs.singular.function import singular_function
|
|
650
|
+
sage: module = singular_function("module")
|
|
651
|
+
sage: mres = singular_function('mres')
|
|
652
|
+
|
|
653
|
+
sage: S.<x,y,z,w> = PolynomialRing(QQ)
|
|
654
|
+
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
|
|
655
|
+
sage: mod = module(I)
|
|
656
|
+
sage: r = mres(mod, 0)
|
|
657
|
+
sage: si2sa_resolution(r)
|
|
658
|
+
[
|
|
659
|
+
[ y x]
|
|
660
|
+
[-z -y]
|
|
661
|
+
[z^2 - y*w y*z - x*w y^2 - x*z], [ w z]
|
|
662
|
+
]
|
|
663
|
+
"""
|
|
664
|
+
cdef ring *singular_ring
|
|
665
|
+
cdef syStrategy singular_res
|
|
666
|
+
cdef poly *p
|
|
667
|
+
cdef poly *p_iter
|
|
668
|
+
cdef poly *first
|
|
669
|
+
cdef poly *previous
|
|
670
|
+
cdef poly *acc
|
|
671
|
+
cdef resolvente mods
|
|
672
|
+
cdef ideal *mod
|
|
673
|
+
cdef int i, j, k, idx, rank, nrows, ncols
|
|
674
|
+
cdef bint zero_mat
|
|
675
|
+
cdef list degs, matdegs
|
|
676
|
+
|
|
677
|
+
from sage.modules.free_module import FreeModule
|
|
678
|
+
from sage.matrix.constructor import matrix as _matrix
|
|
679
|
+
|
|
680
|
+
singular_res = res._resolution[0]
|
|
681
|
+
sage_ring = res.base_ring
|
|
682
|
+
singular_ring = access_singular_ring(res.base_ring)
|
|
683
|
+
|
|
684
|
+
if singular_res.minres != NULL:
|
|
685
|
+
mods = singular_res.minres
|
|
686
|
+
elif singular_res.fullres != NULL:
|
|
687
|
+
mods = singular_res.fullres
|
|
688
|
+
else:
|
|
689
|
+
raise ValueError('Singular resolution is not usable')
|
|
690
|
+
|
|
691
|
+
cdef list res_mats = []
|
|
692
|
+
|
|
693
|
+
# length is the length of fullres. The length of minres
|
|
694
|
+
# can be shorter. Hence we avoid SEGFAULT by stopping
|
|
695
|
+
# at NULL pointer.
|
|
696
|
+
for idx in range(singular_res.length):
|
|
697
|
+
mod = <ideal *> mods[idx]
|
|
698
|
+
if mod == NULL:
|
|
699
|
+
break
|
|
700
|
+
rank = mod.rank
|
|
701
|
+
free_module = FreeModule(sage_ring, rank)
|
|
702
|
+
|
|
703
|
+
nrows = rank
|
|
704
|
+
ncols = mod.ncols # IDELEMS(mod)
|
|
705
|
+
|
|
706
|
+
mat = _matrix(sage_ring, nrows, ncols)
|
|
707
|
+
matdegs = []
|
|
708
|
+
zero_mat = True
|
|
709
|
+
for j in range(ncols):
|
|
710
|
+
p = <poly *> mod.m[j]
|
|
711
|
+
degs = []
|
|
712
|
+
# code below copied and modified from to_sage_vector_destructive
|
|
713
|
+
# in sage.libs.singular.function.Converter
|
|
714
|
+
for i in range(1, rank + 1):
|
|
715
|
+
previous = NULL
|
|
716
|
+
acc = NULL
|
|
717
|
+
first = NULL
|
|
718
|
+
p_iter = p
|
|
719
|
+
while p_iter != NULL:
|
|
720
|
+
if p_GetComp(p_iter, singular_ring) == i:
|
|
721
|
+
p_SetComp(p_iter, 0, singular_ring)
|
|
722
|
+
p_Setm(p_iter, singular_ring)
|
|
723
|
+
if acc == NULL:
|
|
724
|
+
first = p_iter
|
|
725
|
+
else:
|
|
726
|
+
acc.next = p_iter
|
|
727
|
+
acc = p_iter
|
|
728
|
+
if p_iter == p:
|
|
729
|
+
p = pNext(p_iter)
|
|
730
|
+
if previous != NULL:
|
|
731
|
+
previous.next = pNext(p_iter)
|
|
732
|
+
p_iter = pNext(p_iter)
|
|
733
|
+
acc.next = NULL
|
|
734
|
+
else:
|
|
735
|
+
previous = p_iter
|
|
736
|
+
p_iter = pNext(p_iter)
|
|
737
|
+
|
|
738
|
+
if zero_mat:
|
|
739
|
+
zero_mat = first == NULL
|
|
740
|
+
|
|
741
|
+
mat[i - 1, j] = new_sage_polynomial(sage_ring, first)
|
|
742
|
+
|
|
743
|
+
# Singular sometimes leaves zero matrix in the resolution. We can stop
|
|
744
|
+
# when one is seen.
|
|
745
|
+
if zero_mat:
|
|
746
|
+
break
|
|
747
|
+
|
|
748
|
+
res_mats.append(mat)
|
|
749
|
+
|
|
750
|
+
return res_mats
|
|
751
|
+
|
|
752
|
+
cpdef tuple si2sa_resolution_graded(Resolution res, tuple degrees):
|
|
753
|
+
"""
|
|
754
|
+
Pull the data from Singular resolution ``res`` to construct a Sage
|
|
755
|
+
resolution.
|
|
756
|
+
|
|
757
|
+
INPUT:
|
|
758
|
+
|
|
759
|
+
- ``res`` -- Singular resolution
|
|
760
|
+
|
|
761
|
+
- ``degrees`` -- list of integers or integer vectors
|
|
762
|
+
|
|
763
|
+
The procedure is destructive, and ``res`` is not usable afterward.
|
|
764
|
+
|
|
765
|
+
EXAMPLES::
|
|
766
|
+
|
|
767
|
+
sage: from sage.libs.singular.singular import si2sa_resolution_graded
|
|
768
|
+
sage: from sage.libs.singular.function import singular_function
|
|
769
|
+
sage: module = singular_function("module")
|
|
770
|
+
sage: mres = singular_function('mres')
|
|
771
|
+
|
|
772
|
+
sage: S.<x,y,z,w> = PolynomialRing(QQ)
|
|
773
|
+
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
|
|
774
|
+
sage: mod = module(I)
|
|
775
|
+
sage: r = mres(mod, 0)
|
|
776
|
+
sage: res_mats, res_degs = si2sa_resolution_graded(r, (1, 1, 1, 1))
|
|
777
|
+
sage: res_mats
|
|
778
|
+
[
|
|
779
|
+
[ y x]
|
|
780
|
+
[-z -y]
|
|
781
|
+
[z^2 - y*w y*z - x*w y^2 - x*z], [ w z]
|
|
782
|
+
]
|
|
783
|
+
sage: res_degs
|
|
784
|
+
[[[2], [2], [2]], [[1, 1, 1], [1, 1, 1]]]
|
|
785
|
+
"""
|
|
786
|
+
cdef ring *singular_ring
|
|
787
|
+
cdef syStrategy singular_res
|
|
788
|
+
cdef poly *p
|
|
789
|
+
cdef poly *p_iter
|
|
790
|
+
cdef poly *first
|
|
791
|
+
cdef poly *previous
|
|
792
|
+
cdef poly *acc
|
|
793
|
+
cdef resolvente mods
|
|
794
|
+
cdef ideal *mod
|
|
795
|
+
cdef int i, j, k, idx, rank, nrows, ncols
|
|
796
|
+
cdef int ngens = len(degrees)
|
|
797
|
+
cdef bint zero_mat
|
|
798
|
+
cdef list matdegs, exps
|
|
799
|
+
|
|
800
|
+
from sage.matrix.constructor import matrix as _matrix
|
|
801
|
+
|
|
802
|
+
singular_res = res._resolution[0]
|
|
803
|
+
sage_ring = res.base_ring
|
|
804
|
+
singular_ring = access_singular_ring(res.base_ring)
|
|
805
|
+
|
|
806
|
+
if singular_res.minres != NULL:
|
|
807
|
+
mods = singular_res.minres
|
|
808
|
+
elif singular_res.fullres != NULL:
|
|
809
|
+
mods = singular_res.fullres
|
|
810
|
+
else:
|
|
811
|
+
raise ValueError('Singular resolution is not usable')
|
|
812
|
+
|
|
813
|
+
cdef list res_mats = []
|
|
814
|
+
cdef list res_degs = []
|
|
815
|
+
|
|
816
|
+
# length is the length of fullres. The length of minres
|
|
817
|
+
# can be shorter. Hence we avoid SEGFAULT by stopping
|
|
818
|
+
# at NULL pointer.
|
|
819
|
+
for idx in range(singular_res.length):
|
|
820
|
+
mod = <ideal *> mods[idx]
|
|
821
|
+
if mod == NULL:
|
|
822
|
+
break
|
|
823
|
+
rank = mod.rank
|
|
824
|
+
free_module = sage_ring ** rank
|
|
825
|
+
|
|
826
|
+
nrows = rank
|
|
827
|
+
ncols = mod.ncols # IDELEMS(mod)
|
|
828
|
+
|
|
829
|
+
mat = _matrix(sage_ring, nrows, ncols)
|
|
830
|
+
matdegs = []
|
|
831
|
+
zero_mat = True
|
|
832
|
+
for j in range(ncols):
|
|
833
|
+
p = <poly *> mod.m[j]
|
|
834
|
+
degs = []
|
|
835
|
+
# code below copied and modified from to_sage_vector_destructive
|
|
836
|
+
# in sage.libs.singular.function.Converter
|
|
837
|
+
for i in range(1, rank + 1):
|
|
838
|
+
previous = NULL
|
|
839
|
+
acc = NULL
|
|
840
|
+
first = NULL
|
|
841
|
+
p_iter = p
|
|
842
|
+
while p_iter != NULL:
|
|
843
|
+
if p_GetComp(p_iter, singular_ring) == i:
|
|
844
|
+
p_SetComp(p_iter, 0, singular_ring)
|
|
845
|
+
p_Setm(p_iter, singular_ring)
|
|
846
|
+
if acc == NULL:
|
|
847
|
+
first = p_iter
|
|
848
|
+
else:
|
|
849
|
+
acc.next = p_iter
|
|
850
|
+
acc = p_iter
|
|
851
|
+
if p_iter == p:
|
|
852
|
+
p = pNext(p_iter)
|
|
853
|
+
if previous != NULL:
|
|
854
|
+
previous.next = pNext(p_iter)
|
|
855
|
+
p_iter = pNext(p_iter)
|
|
856
|
+
acc.next = NULL
|
|
857
|
+
else:
|
|
858
|
+
previous = p_iter
|
|
859
|
+
p_iter = pNext(p_iter)
|
|
860
|
+
|
|
861
|
+
if zero_mat:
|
|
862
|
+
zero_mat = first == NULL
|
|
863
|
+
|
|
864
|
+
mat[i - 1, j] = new_sage_polynomial(sage_ring, first)
|
|
865
|
+
|
|
866
|
+
# degree of a homogeneous polynomial can be computed from the
|
|
867
|
+
# first monomial
|
|
868
|
+
if first != NULL:
|
|
869
|
+
exps = singular_monomial_exponents(first, singular_ring)
|
|
870
|
+
deg = 0
|
|
871
|
+
for k in range(ngens):
|
|
872
|
+
deg += exps[k] * degrees[k]
|
|
873
|
+
degs.append(deg)
|
|
874
|
+
else:
|
|
875
|
+
degs.append(None)
|
|
876
|
+
|
|
877
|
+
matdegs.append(degs) # store degrees of the column
|
|
878
|
+
|
|
879
|
+
# Singular sometimes leaves zero matrix in the resolution. We can stop
|
|
880
|
+
# when one is seen.
|
|
881
|
+
if zero_mat:
|
|
882
|
+
break
|
|
883
|
+
|
|
884
|
+
res_mats.append(mat)
|
|
885
|
+
res_degs.append(matdegs)
|
|
886
|
+
|
|
887
|
+
return (res_mats, res_degs)
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
cdef number *sa2si_QQ(Rational r, ring *_ring) noexcept:
|
|
891
|
+
"""
|
|
892
|
+
Create a singular number from a sage rational.
|
|
893
|
+
|
|
894
|
+
INPUT:
|
|
895
|
+
|
|
896
|
+
- ``r`` -- a sage rational number
|
|
897
|
+
|
|
898
|
+
- ``_ ring`` -- a (pointer to) a singular ring, where the result will live
|
|
899
|
+
|
|
900
|
+
OUTPUT:
|
|
901
|
+
|
|
902
|
+
- A (pointer to) a singular number
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
TESTS::
|
|
906
|
+
|
|
907
|
+
sage: P.<x,y,z> = QQ[]
|
|
908
|
+
sage: P(0) + 1/2 - 2/4
|
|
909
|
+
0
|
|
910
|
+
sage: P(1/2) + 3/5 - 3/5
|
|
911
|
+
1/2
|
|
912
|
+
sage: P(2/3) + 1/4 - 1/4
|
|
913
|
+
2/3
|
|
914
|
+
sage: P(12345678901234567890/23) + 5/2 - 5/2
|
|
915
|
+
12345678901234567890/23
|
|
916
|
+
"""
|
|
917
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
918
|
+
return nlInit2gmp( mpq_numref(r.value), mpq_denref(r.value),_ring.cf )
|
|
919
|
+
|
|
920
|
+
cdef number *sa2si_GFqGivaro(int quo, ring *_ring) noexcept:
|
|
921
|
+
"""
|
|
922
|
+
Create a singular number in a small finite field.
|
|
923
|
+
|
|
924
|
+
INPUT:
|
|
925
|
+
|
|
926
|
+
- ``quo`` -- sage integer
|
|
927
|
+
|
|
928
|
+
- ``_ ring`` -- a (pointer to) a singular ring, where the result will live
|
|
929
|
+
|
|
930
|
+
OUTPUT:
|
|
931
|
+
|
|
932
|
+
- A (pointer to) a singular number
|
|
933
|
+
|
|
934
|
+
Number field elements are represented as polynomials in the number field
|
|
935
|
+
generator. In this case, ``quo`` is the integer resulting from evaluating
|
|
936
|
+
that polynomial in the characteristic of the field.
|
|
937
|
+
|
|
938
|
+
TESTS::
|
|
939
|
+
|
|
940
|
+
sage: F = FiniteField(5^2)
|
|
941
|
+
sage: type(F)
|
|
942
|
+
<class 'sage.rings.finite_rings.finite_field_givaro.FiniteField_givaro_with_category'>
|
|
943
|
+
sage: R.<x,y,z> = F[]
|
|
944
|
+
sage: R(0) + 1
|
|
945
|
+
1
|
|
946
|
+
sage: R(F.gen()) + 1
|
|
947
|
+
(z2 + 1)
|
|
948
|
+
sage: R(F.gen()^2) + 1
|
|
949
|
+
(z2 - 1)
|
|
950
|
+
"""
|
|
951
|
+
if _ring != currRing:
|
|
952
|
+
rChangeCurrRing(_ring)
|
|
953
|
+
cdef number* n1
|
|
954
|
+
cdef number* n2
|
|
955
|
+
cdef number* a
|
|
956
|
+
cdef number* coeff
|
|
957
|
+
cdef number* apow1
|
|
958
|
+
cdef number* apow2
|
|
959
|
+
cdef int b = _ring.cf.ch
|
|
960
|
+
|
|
961
|
+
a = _ring.cf.cfParameter(1, _ring.cf)
|
|
962
|
+
|
|
963
|
+
apow1 = _ring.cf.cfInit(1, _ring.cf)
|
|
964
|
+
n1 = _ring.cf.cfInit(0, _ring.cf)
|
|
965
|
+
|
|
966
|
+
while quo!=0:
|
|
967
|
+
coeff = _ring.cf.cfInit(quo % b, _ring.cf)
|
|
968
|
+
|
|
969
|
+
if not _ring.cf.cfIsZero(coeff, _ring.cf):
|
|
970
|
+
apow2 = _ring.cf.cfMult(coeff, apow1, _ring.cf)
|
|
971
|
+
n2 = _ring.cf.cfAdd(apow2, n1, _ring.cf)
|
|
972
|
+
_ring.cf.cfDelete(&apow2, _ring.cf)
|
|
973
|
+
_ring.cf.cfDelete(&n1, _ring.cf)
|
|
974
|
+
n1 = n2
|
|
975
|
+
|
|
976
|
+
apow2 = _ring.cf.cfMult(apow1, a, _ring.cf)
|
|
977
|
+
_ring.cf.cfDelete(&apow1, _ring.cf)
|
|
978
|
+
apow1 = apow2
|
|
979
|
+
|
|
980
|
+
quo = quo/b
|
|
981
|
+
_ring.cf.cfDelete(&coeff, _ring.cf)
|
|
982
|
+
|
|
983
|
+
_ring.cf.cfDelete(&apow1, _ring.cf)
|
|
984
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
985
|
+
return n1
|
|
986
|
+
|
|
987
|
+
cdef number *sa2si_GFqNTLGF2E(FFgf2eE elem, ring *_ring) noexcept:
|
|
988
|
+
"""
|
|
989
|
+
Create a singular number from a sage element of a finite field of
|
|
990
|
+
characteristic 2.
|
|
991
|
+
|
|
992
|
+
INPUT:
|
|
993
|
+
|
|
994
|
+
- ``elem`` -- a sage element of a ntl_gf2e finite field
|
|
995
|
+
|
|
996
|
+
- ``_ ring`` -- a (pointer to) a singular ring, where the result will live
|
|
997
|
+
|
|
998
|
+
OUTPUT:
|
|
999
|
+
|
|
1000
|
+
- A (pointer to) a singular number
|
|
1001
|
+
|
|
1002
|
+
TESTS::
|
|
1003
|
+
|
|
1004
|
+
sage: F = FiniteField(2^20)
|
|
1005
|
+
sage: type(F)
|
|
1006
|
+
<class 'sage.rings.finite_rings.finite_field_ntl_gf2e.FiniteField_ntl_gf2e_with_category'>
|
|
1007
|
+
sage: R.<x,y,z> = F[]
|
|
1008
|
+
sage: R(0)+1
|
|
1009
|
+
1
|
|
1010
|
+
sage: R(F.gen()) + 1
|
|
1011
|
+
(z20 + 1)
|
|
1012
|
+
sage: R(F.gen()^21) + 1
|
|
1013
|
+
(z20^11 + z20^10 + z20^8 + z20^7 + z20^6 + z20^5 + z20^2 + z20 + 1)
|
|
1014
|
+
"""
|
|
1015
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
1016
|
+
cdef int i
|
|
1017
|
+
cdef number *n1
|
|
1018
|
+
cdef number *n2
|
|
1019
|
+
cdef number *a
|
|
1020
|
+
cdef number *coeff
|
|
1021
|
+
cdef number *apow1
|
|
1022
|
+
cdef number *apow2
|
|
1023
|
+
cdef GF2X_c rep = GF2E_rep(elem.x)
|
|
1024
|
+
|
|
1025
|
+
if GF2X_deg(rep) >= 1:
|
|
1026
|
+
n1 = _ring.cf.cfInit(0, _ring.cf)
|
|
1027
|
+
a = _ring.cf.cfParameter(1,_ring.cf)
|
|
1028
|
+
apow1 = _ring.cf.cfInit(1, _ring.cf)
|
|
1029
|
+
|
|
1030
|
+
for i from 0 <= i <= GF2X_deg(rep):
|
|
1031
|
+
coeff = _ring.cf.cfInit(GF2_conv_to_long(GF2X_coeff(rep,i)), _ring.cf)
|
|
1032
|
+
|
|
1033
|
+
if not _ring.cf.cfIsZero(coeff,_ring.cf):
|
|
1034
|
+
apow2 = _ring.cf.cfMult(coeff, apow1,_ring.cf)
|
|
1035
|
+
n2 = _ring.cf.cfAdd(apow2, n1,_ring.cf)
|
|
1036
|
+
_ring.cf.cfDelete(&apow2, _ring.cf)
|
|
1037
|
+
_ring.cf.cfDelete(&n1, _ring.cf)
|
|
1038
|
+
n1 = n2
|
|
1039
|
+
|
|
1040
|
+
apow2 = _ring.cf.cfMult(apow1, a,_ring.cf)
|
|
1041
|
+
_ring.cf.cfDelete(&apow1, _ring.cf)
|
|
1042
|
+
apow1 = apow2
|
|
1043
|
+
|
|
1044
|
+
_ring.cf.cfDelete(&coeff, _ring.cf)
|
|
1045
|
+
|
|
1046
|
+
_ring.cf.cfDelete(&apow1, _ring.cf)
|
|
1047
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
1048
|
+
else:
|
|
1049
|
+
n1 = _ring.cf.cfInit(GF2_conv_to_long(GF2X_coeff(rep,0)), _ring.cf)
|
|
1050
|
+
|
|
1051
|
+
return n1
|
|
1052
|
+
|
|
1053
|
+
cdef number *sa2si_GFq_generic(object elem, ring *_ring) noexcept:
|
|
1054
|
+
"""
|
|
1055
|
+
Create a singular number from a sage element of a generic finite field.
|
|
1056
|
+
|
|
1057
|
+
INPUT:
|
|
1058
|
+
|
|
1059
|
+
- ``elem`` -- a sage element of a generic finite field
|
|
1060
|
+
|
|
1061
|
+
- ``_ ring`` -- a (pointer to) a singular ring, where the result will live
|
|
1062
|
+
|
|
1063
|
+
OUTPUT:
|
|
1064
|
+
|
|
1065
|
+
- A (pointer to) a singular number
|
|
1066
|
+
|
|
1067
|
+
TESTS::
|
|
1068
|
+
|
|
1069
|
+
sage: F = FiniteField(3^20)
|
|
1070
|
+
sage: type(F)
|
|
1071
|
+
<class 'sage.rings.finite_rings.finite_field_pari_ffelt.FiniteField_pari_ffelt_with_category'>
|
|
1072
|
+
sage: R.<x,y,z> = F[]
|
|
1073
|
+
sage: R(0) + 1
|
|
1074
|
+
1
|
|
1075
|
+
sage: R(F.gen()) + 1
|
|
1076
|
+
(z20 + 1)
|
|
1077
|
+
sage: R(F.gen()^21) + 1
|
|
1078
|
+
(z20^14 - z20^12 - z20^11 - z20^10 - z20^9 + z20^6 + z20^5 + z20^4 - z20^2 + z20 + 1)
|
|
1079
|
+
"""
|
|
1080
|
+
cdef int i
|
|
1081
|
+
cdef number *n1
|
|
1082
|
+
cdef number *n2
|
|
1083
|
+
cdef number *a
|
|
1084
|
+
cdef number *coeff
|
|
1085
|
+
cdef number *apow1
|
|
1086
|
+
cdef number *apow2
|
|
1087
|
+
|
|
1088
|
+
if _ring.cf.type in (n_Zn, n_Znm):
|
|
1089
|
+
return sa2si_ZZmod(elem, _ring)
|
|
1090
|
+
elem = elem.polynomial()
|
|
1091
|
+
|
|
1092
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
1093
|
+
if elem.degree() > 0:
|
|
1094
|
+
n1 = _ring.cf.cfInit(0, _ring.cf)
|
|
1095
|
+
a = _ring.cf.cfParameter(1,_ring.cf)
|
|
1096
|
+
apow1 = _ring.cf.cfInit(1, _ring.cf)
|
|
1097
|
+
|
|
1098
|
+
for i from 0 <= i <= elem.degree():
|
|
1099
|
+
coeff = _ring.cf.cfInit(int(elem[i]), _ring.cf)
|
|
1100
|
+
|
|
1101
|
+
if not _ring.cf.cfIsZero(coeff,_ring.cf):
|
|
1102
|
+
apow2 = _ring.cf.cfMult(coeff, apow1,_ring.cf)
|
|
1103
|
+
n2 = _ring.cf.cfAdd(apow2, n1,_ring.cf)
|
|
1104
|
+
_ring.cf.cfDelete(&apow2, _ring.cf)
|
|
1105
|
+
_ring.cf.cfDelete(&n1, _ring.cf)
|
|
1106
|
+
n1 = n2
|
|
1107
|
+
|
|
1108
|
+
apow2 = _ring.cf.cfMult(apow1, a,_ring.cf)
|
|
1109
|
+
_ring.cf.cfDelete(&apow1, _ring.cf)
|
|
1110
|
+
apow1 = apow2
|
|
1111
|
+
|
|
1112
|
+
_ring.cf.cfDelete(&coeff, _ring.cf)
|
|
1113
|
+
|
|
1114
|
+
_ring.cf.cfDelete(&apow1, _ring.cf)
|
|
1115
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
1116
|
+
else:
|
|
1117
|
+
n1 = _ring.cf.cfInit(int(elem), _ring.cf)
|
|
1118
|
+
|
|
1119
|
+
return n1
|
|
1120
|
+
|
|
1121
|
+
cdef number *sa2si_transext_QQ(object elem, ring *_ring) noexcept:
|
|
1122
|
+
"""
|
|
1123
|
+
Create a singular number from a sage element of a transcendental extension
|
|
1124
|
+
of the rationals.
|
|
1125
|
+
|
|
1126
|
+
INPUT:
|
|
1127
|
+
|
|
1128
|
+
- ``elem`` -- a sage element of a FractionField of polynomials over the rationals
|
|
1129
|
+
|
|
1130
|
+
- ``_ ring`` -- a (pointer to) a singular ring, where the result will live
|
|
1131
|
+
|
|
1132
|
+
OUTPUT:
|
|
1133
|
+
|
|
1134
|
+
- A (pointer to) a singular number
|
|
1135
|
+
|
|
1136
|
+
TESTS::
|
|
1137
|
+
|
|
1138
|
+
sage: F = PolynomialRing(QQ,'a,b').fraction_field()
|
|
1139
|
+
sage: F.inject_variables()
|
|
1140
|
+
Defining a, b
|
|
1141
|
+
sage: R.<x,y> = F[]
|
|
1142
|
+
sage: a*x
|
|
1143
|
+
a*x
|
|
1144
|
+
sage: I = R.ideal([a*x])
|
|
1145
|
+
sage: I
|
|
1146
|
+
Ideal (a*x) of Multivariate Polynomial Ring in x, y over Fraction Field of Multivariate Polynomial Ring in a, b over Rational Field
|
|
1147
|
+
sage: I.groebner_basis()
|
|
1148
|
+
[x]
|
|
1149
|
+
sage: I = R.ideal([a*x+b*y^2, (b+a)/(b-a)*x^3-3*y*x])
|
|
1150
|
+
sage: I.groebner_basis()
|
|
1151
|
+
[x^3 + (3*a - 3*b)/(a + b)*x*y, y^2 + a/b*x]
|
|
1152
|
+
sage: R.term_order()
|
|
1153
|
+
Degree reverse lexicographic term order
|
|
1154
|
+
|
|
1155
|
+
::
|
|
1156
|
+
|
|
1157
|
+
sage: F = PolynomialRing(QQ,'a').fraction_field()
|
|
1158
|
+
sage: R.<x,y> = F[]
|
|
1159
|
+
sage: F.inject_variables()
|
|
1160
|
+
Defining a
|
|
1161
|
+
sage: a*x
|
|
1162
|
+
a*x
|
|
1163
|
+
sage: I = R.ideal([a*x+5*y^2, (1+a)/(1-a)*x^3-3*y*x])
|
|
1164
|
+
sage: I
|
|
1165
|
+
Ideal (5*y^2 + a*x, (-a - 1)/(a - 1)*x^3 - 3*x*y) of Multivariate Polynomial Ring in x, y over Fraction Field of Univariate Polynomial Ring in a over Rational Field
|
|
1166
|
+
sage: I.groebner_basis()
|
|
1167
|
+
[x^3 + (3*a - 3)/(a + 1)*x*y, y^2 + a/5*x]
|
|
1168
|
+
|
|
1169
|
+
::
|
|
1170
|
+
|
|
1171
|
+
sage: F = PolynomialRing(QQ,'a,b').fraction_field()
|
|
1172
|
+
sage: R.<x,y> = PolynomialRing(F)
|
|
1173
|
+
sage: S.<x,y> = QQ[]
|
|
1174
|
+
sage: f = x + y + 1
|
|
1175
|
+
sage: R(f)
|
|
1176
|
+
x + y + 1
|
|
1177
|
+
"""
|
|
1178
|
+
cdef int j
|
|
1179
|
+
cdef number *n1
|
|
1180
|
+
cdef number *a
|
|
1181
|
+
cdef number *naCoeff
|
|
1182
|
+
cdef number *numerator
|
|
1183
|
+
cdef number *denominator
|
|
1184
|
+
cdef number *cfnum
|
|
1185
|
+
cdef number *cfden
|
|
1186
|
+
cdef number *aux1
|
|
1187
|
+
cdef number *aux2
|
|
1188
|
+
cdef number *power
|
|
1189
|
+
cdef int ngens
|
|
1190
|
+
cdef int ex
|
|
1191
|
+
cdef nMapFunc nMapFuncPtr = NULL
|
|
1192
|
+
|
|
1193
|
+
if _ring != currRing:
|
|
1194
|
+
rChangeCurrRing(_ring)
|
|
1195
|
+
|
|
1196
|
+
ngens = elem.parent().ngens()
|
|
1197
|
+
|
|
1198
|
+
nMapFuncPtr = naSetMap(_ring.cf, currRing.cf) # choose correct mapping function
|
|
1199
|
+
|
|
1200
|
+
if nMapFuncPtr is NULL:
|
|
1201
|
+
raise RuntimeError("Failed to determine nMapFuncPtr")
|
|
1202
|
+
|
|
1203
|
+
numerdic = elem.numerator().monomial_coefficients()
|
|
1204
|
+
denomdic = elem.denominator().monomial_coefficients()
|
|
1205
|
+
|
|
1206
|
+
if numerdic and not isinstance(list(numerdic)[0], (tuple, ETuple)):
|
|
1207
|
+
numerdic = {(k,):b for k,b in numerdic.items()}
|
|
1208
|
+
|
|
1209
|
+
if denomdic and not isinstance(list(denomdic)[0], (tuple, ETuple)):
|
|
1210
|
+
denomdic = {(k,):b for k,b in denomdic.items()}
|
|
1211
|
+
|
|
1212
|
+
if _ring != currRing:
|
|
1213
|
+
rChangeCurrRing(_ring)
|
|
1214
|
+
n1 = _ring.cf.cfInit(0, _ring.cf)
|
|
1215
|
+
numerator = _ring.cf.cfInit(0, _ring.cf)
|
|
1216
|
+
for (exponents, coef) in numerdic.items():
|
|
1217
|
+
numer = coef.numerator()
|
|
1218
|
+
cfnum = _ring.cf.cfInitMPZ((<Integer>numer).value, _ring.cf)
|
|
1219
|
+
denom = coef.denominator()
|
|
1220
|
+
cfden = _ring.cf.cfInitMPZ((<Integer>denom).value, _ring.cf)
|
|
1221
|
+
naCoeff = _ring.cf.cfDiv(cfnum, cfden, _ring.cf)
|
|
1222
|
+
_ring.cf.cfDelete(&cfnum, _ring.cf)
|
|
1223
|
+
_ring.cf.cfDelete(&cfden, _ring.cf)
|
|
1224
|
+
for (j, ex) in enumerate(exponents):
|
|
1225
|
+
a = _ring.cf.cfParameter(j+1, _ring.cf)
|
|
1226
|
+
_ring.cf.cfPower(a, ex, &power, _ring.cf)
|
|
1227
|
+
aux1 = naCoeff
|
|
1228
|
+
naCoeff = _ring.cf.cfMult(aux1, power, _ring.cf)
|
|
1229
|
+
_ring.cf.cfDelete(&aux1, _ring.cf)
|
|
1230
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
1231
|
+
_ring.cf.cfDelete(&power, _ring.cf)
|
|
1232
|
+
aux2 = numerator
|
|
1233
|
+
numerator = _ring.cf.cfAdd(aux2, naCoeff,_ring.cf)
|
|
1234
|
+
_ring.cf.cfDelete(&aux2, _ring.cf)
|
|
1235
|
+
|
|
1236
|
+
if elem.denominator() != 1:
|
|
1237
|
+
denominator = _ring.cf.cfInit(0, _ring.cf)
|
|
1238
|
+
|
|
1239
|
+
for (exponents, coef) in denomdic.items():
|
|
1240
|
+
numer = coef.numerator()
|
|
1241
|
+
cfnum = _ring.cf.cfInitMPZ((<Integer>numer).value, _ring.cf)
|
|
1242
|
+
denom = coef.denominator()
|
|
1243
|
+
cfden = _ring.cf.cfInitMPZ((<Integer>denom).value, _ring.cf)
|
|
1244
|
+
naCoeff = _ring.cf.cfDiv(cfnum, cfden, _ring.cf)
|
|
1245
|
+
_ring.cf.cfDelete(&cfnum, _ring.cf)
|
|
1246
|
+
_ring.cf.cfDelete(&cfden, _ring.cf)
|
|
1247
|
+
for (j, ex) in enumerate(exponents):
|
|
1248
|
+
a = _ring.cf.cfParameter(j+1, _ring.cf)
|
|
1249
|
+
_ring.cf.cfPower(a, ex, &power, _ring.cf)
|
|
1250
|
+
aux1 = naCoeff
|
|
1251
|
+
naCoeff = _ring.cf.cfMult(aux1, power, _ring.cf)
|
|
1252
|
+
_ring.cf.cfDelete(&aux1, _ring.cf)
|
|
1253
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
1254
|
+
_ring.cf.cfDelete(&power, _ring.cf)
|
|
1255
|
+
aux2 = denominator
|
|
1256
|
+
denominator = _ring.cf.cfAdd(aux2, naCoeff,_ring.cf)
|
|
1257
|
+
_ring.cf.cfDelete(&aux2, _ring.cf)
|
|
1258
|
+
|
|
1259
|
+
else:
|
|
1260
|
+
denominator = _ring.cf.cfInit(1, _ring.cf)
|
|
1261
|
+
|
|
1262
|
+
n1 = _ring.cf.cfDiv(numerator, denominator, _ring.cf)
|
|
1263
|
+
|
|
1264
|
+
_ring.cf.cfDelete(&numerator, _ring.cf)
|
|
1265
|
+
_ring.cf.cfDelete(&denominator, _ring.cf)
|
|
1266
|
+
_ring.cf.cfDelete(&naCoeff, _ring.cf)
|
|
1267
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
1268
|
+
|
|
1269
|
+
return n1
|
|
1270
|
+
|
|
1271
|
+
cdef number *sa2si_transext_FF(object elem, ring *_ring) noexcept:
|
|
1272
|
+
"""
|
|
1273
|
+
Create a singular number from a sage element of a transcendental extension
|
|
1274
|
+
of a prime field.
|
|
1275
|
+
|
|
1276
|
+
INPUT:
|
|
1277
|
+
|
|
1278
|
+
- ``elem`` -- a sage element of a FractionField of polynomials over the rationals
|
|
1279
|
+
|
|
1280
|
+
- ``_ ring`` -- a (pointer to) a singular ring, where the result will live
|
|
1281
|
+
|
|
1282
|
+
OUTPUT:
|
|
1283
|
+
|
|
1284
|
+
- A (pointer to) a singular number
|
|
1285
|
+
|
|
1286
|
+
TESTS::
|
|
1287
|
+
|
|
1288
|
+
sage: F = PolynomialRing(FiniteField(7),'a,b').fraction_field()
|
|
1289
|
+
sage: R.<x,y,z> = F[]
|
|
1290
|
+
sage: n = R(5)
|
|
1291
|
+
sage: n + n
|
|
1292
|
+
3
|
|
1293
|
+
sage: Integer(n)
|
|
1294
|
+
5
|
|
1295
|
+
"""
|
|
1296
|
+
cdef int j
|
|
1297
|
+
cdef number *n1
|
|
1298
|
+
cdef number *a
|
|
1299
|
+
cdef number *naCoeff
|
|
1300
|
+
cdef number *numerator
|
|
1301
|
+
cdef number *denominator
|
|
1302
|
+
cdef number *aux1
|
|
1303
|
+
cdef number *aux2
|
|
1304
|
+
cdef int ngens
|
|
1305
|
+
cdef int ex
|
|
1306
|
+
cdef nMapFunc nMapFuncPtr = NULL
|
|
1307
|
+
|
|
1308
|
+
if _ring != currRing:
|
|
1309
|
+
rChangeCurrRing(_ring)
|
|
1310
|
+
|
|
1311
|
+
ngens = elem.parent().ngens()
|
|
1312
|
+
|
|
1313
|
+
nMapFuncPtr = naSetMap(_ring.cf, currRing.cf) # choose correct mapping function
|
|
1314
|
+
|
|
1315
|
+
if nMapFuncPtr is NULL:
|
|
1316
|
+
raise RuntimeError("Failed to determine nMapFuncPtr")
|
|
1317
|
+
|
|
1318
|
+
numerdic = elem.numerator().monomial_coefficients()
|
|
1319
|
+
denomdic = elem.denominator().monomial_coefficients()
|
|
1320
|
+
|
|
1321
|
+
if numerdic and not isinstance(list(numerdic)[0], (tuple, ETuple)):
|
|
1322
|
+
numerdic = {(k,):b for k,b in numerdic.items()}
|
|
1323
|
+
|
|
1324
|
+
if denomdic and not isinstance(list(denomdic)[0], (tuple, ETuple)):
|
|
1325
|
+
denomdic = {(k,):b for k,b in denomdic.items()}
|
|
1326
|
+
|
|
1327
|
+
if _ring != currRing:
|
|
1328
|
+
rChangeCurrRing(_ring)
|
|
1329
|
+
numerator = _ring.cf.cfInit(0, _ring.cf)
|
|
1330
|
+
for (exponents, coef) in numerdic.items():
|
|
1331
|
+
naCoeff = _ring.cf.cfInit(<int>coef, _ring.cf)
|
|
1332
|
+
for (j, ex) in enumerate(exponents):
|
|
1333
|
+
a = _ring.cf.cfParameter(j+1, _ring.cf)
|
|
1334
|
+
for k in range(ex):
|
|
1335
|
+
aux1 = naCoeff
|
|
1336
|
+
naCoeff = _ring.cf.cfMult(aux1, a, _ring.cf)
|
|
1337
|
+
_ring.cf.cfDelete(&aux1, _ring.cf)
|
|
1338
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
1339
|
+
aux2 = numerator
|
|
1340
|
+
numerator = _ring.cf.cfAdd(aux2, naCoeff, _ring.cf)
|
|
1341
|
+
_ring.cf.cfDelete(&naCoeff, _ring.cf)
|
|
1342
|
+
_ring.cf.cfDelete(&aux2, _ring.cf)
|
|
1343
|
+
|
|
1344
|
+
if elem.denominator() != 1:
|
|
1345
|
+
denominator = _ring.cf.cfInit(0, _ring.cf)
|
|
1346
|
+
|
|
1347
|
+
for (exponents, coef) in denomdic.items():
|
|
1348
|
+
naCoeff = _ring.cf.cfInit(<int>coef, _ring.cf)
|
|
1349
|
+
for (j, ex) in enumerate(exponents):
|
|
1350
|
+
a = _ring.cf.cfParameter(j+1, _ring.cf)
|
|
1351
|
+
for k in range(ex):
|
|
1352
|
+
aux1 = naCoeff
|
|
1353
|
+
naCoeff = _ring.cf.cfMult(aux1, a, _ring.cf)
|
|
1354
|
+
_ring.cf.cfDelete(&aux1, _ring.cf)
|
|
1355
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
1356
|
+
aux2 = denominator
|
|
1357
|
+
denominator = _ring.cf.cfAdd(aux2, naCoeff,_ring.cf)
|
|
1358
|
+
_ring.cf.cfDelete(&naCoeff, _ring.cf)
|
|
1359
|
+
_ring.cf.cfDelete(&aux2, _ring.cf)
|
|
1360
|
+
|
|
1361
|
+
else:
|
|
1362
|
+
denominator = _ring.cf.cfInit(1, _ring.cf)
|
|
1363
|
+
|
|
1364
|
+
n1 = _ring.cf.cfDiv(numerator, denominator, _ring.cf)
|
|
1365
|
+
|
|
1366
|
+
_ring.cf.cfDelete(&numerator, _ring.cf)
|
|
1367
|
+
_ring.cf.cfDelete(&denominator, _ring.cf)
|
|
1368
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
1369
|
+
|
|
1370
|
+
return n1
|
|
1371
|
+
|
|
1372
|
+
cdef number *sa2si_NF(object elem, ring *_ring) noexcept:
|
|
1373
|
+
"""
|
|
1374
|
+
Create a singular number from a sage element of a number field.
|
|
1375
|
+
|
|
1376
|
+
INPUT:
|
|
1377
|
+
|
|
1378
|
+
- ``elem`` -- a sage element of a NumberField
|
|
1379
|
+
|
|
1380
|
+
- ``_ ring`` -- a (pointer to) a singular ring, where the result will live
|
|
1381
|
+
|
|
1382
|
+
OUTPUT:
|
|
1383
|
+
|
|
1384
|
+
- A (pointer to) a singular number
|
|
1385
|
+
|
|
1386
|
+
TESTS::
|
|
1387
|
+
|
|
1388
|
+
sage: x = polygen(ZZ, 'x')
|
|
1389
|
+
sage: F = NumberField(x^3 + x + 1, 'a')
|
|
1390
|
+
sage: type(F)
|
|
1391
|
+
<class 'sage.rings.number_field.number_field.NumberField_absolute_with_category'>
|
|
1392
|
+
sage: R.<x,y,z> = F[]
|
|
1393
|
+
sage: R(0) + 1
|
|
1394
|
+
1
|
|
1395
|
+
sage: R(1)
|
|
1396
|
+
1
|
|
1397
|
+
sage: R(F.gen()) + 1
|
|
1398
|
+
(a + 1)
|
|
1399
|
+
sage: R(F.gen()^5) + 1
|
|
1400
|
+
(-a^2 + a + 2)
|
|
1401
|
+
|
|
1402
|
+
Ensures :issue:`36101` is fixed::
|
|
1403
|
+
|
|
1404
|
+
sage: # needs sage.symbolic
|
|
1405
|
+
sage: RR.<x, y, r, s0, c0, s1, c1> = AA[]
|
|
1406
|
+
sage: f = -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r-2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2
|
|
1407
|
+
sage: f.change_ring( QuadraticField(3) )
|
|
1408
|
+
...
|
|
1409
|
+
"""
|
|
1410
|
+
cdef int i
|
|
1411
|
+
cdef number *n1
|
|
1412
|
+
cdef number *n2
|
|
1413
|
+
cdef number *a
|
|
1414
|
+
cdef number *nlCoeff
|
|
1415
|
+
cdef number *naCoeff
|
|
1416
|
+
cdef number *apow1
|
|
1417
|
+
cdef number *apow2
|
|
1418
|
+
|
|
1419
|
+
elem = list(elem)
|
|
1420
|
+
|
|
1421
|
+
if _ring != currRing:
|
|
1422
|
+
rChangeCurrRing(_ring)
|
|
1423
|
+
n1 = _ring.cf.cfInit(0, _ring.cf)
|
|
1424
|
+
a = _ring.cf.cfParameter(1, _ring.cf)
|
|
1425
|
+
apow1 = _ring.cf.cfInit(1, _ring.cf)
|
|
1426
|
+
|
|
1427
|
+
cdef char *_name
|
|
1428
|
+
|
|
1429
|
+
# the result of nlInit2gmp() is in a plain polynomial ring over QQ (not an extension ring!),
|
|
1430
|
+
# so we have to get/create one:
|
|
1431
|
+
#
|
|
1432
|
+
# todo: reuse qqr/ get an existing Singular polynomial ring over Q.
|
|
1433
|
+
_name = omStrDup("a")
|
|
1434
|
+
cdef char **_ext_names
|
|
1435
|
+
_ext_names = <char**>omAlloc0(sizeof(char*))
|
|
1436
|
+
_ext_names[0] = omStrDup(_name)
|
|
1437
|
+
qqr = rDefault( 0, 1, _ext_names)
|
|
1438
|
+
rComplete(qqr,1)
|
|
1439
|
+
qqr.ShortOut = 0
|
|
1440
|
+
|
|
1441
|
+
assert _ring.cf.type == n_algExt # if false naSetMap will segmentation fault (should never happen)
|
|
1442
|
+
cdef nMapFunc nMapFuncPtr = naSetMap(qqr.cf, _ring.cf) # choose correct mapping function
|
|
1443
|
+
if nMapFuncPtr is NULL:
|
|
1444
|
+
raise RuntimeError("Failed to determine nMapFuncPtr")
|
|
1445
|
+
cdef poly *_p
|
|
1446
|
+
for i from 0 <= i < len(elem):
|
|
1447
|
+
nlCoeff = nlInit2gmp( mpq_numref((<Rational>elem[i]).value), mpq_denref((<Rational>elem[i]).value), qqr.cf )
|
|
1448
|
+
naCoeff = nMapFuncPtr(nlCoeff, qqr.cf, _ring.cf)
|
|
1449
|
+
nlDelete(&nlCoeff, _ring.cf)
|
|
1450
|
+
|
|
1451
|
+
# faster would be to assign the coefficient directly
|
|
1452
|
+
apow2 = _ring.cf.cfMult(naCoeff, apow1,_ring.cf)
|
|
1453
|
+
n2 = _ring.cf.cfAdd(apow2, n1,_ring.cf)
|
|
1454
|
+
_ring.cf.cfDelete(&apow2, _ring.cf)
|
|
1455
|
+
_ring.cf.cfDelete(&n1, _ring.cf)
|
|
1456
|
+
_ring.cf.cfDelete(&naCoeff, _ring.cf)
|
|
1457
|
+
n1 = n2
|
|
1458
|
+
|
|
1459
|
+
apow2 = _ring.cf.cfMult(apow1, a,_ring.cf)
|
|
1460
|
+
_ring.cf.cfDelete(&apow1, _ring.cf)
|
|
1461
|
+
apow1 = apow2
|
|
1462
|
+
|
|
1463
|
+
_ring.cf.cfDelete(&apow1, _ring.cf)
|
|
1464
|
+
_ring.cf.cfDelete(&a, _ring.cf)
|
|
1465
|
+
|
|
1466
|
+
return n1
|
|
1467
|
+
|
|
1468
|
+
cdef number *sa2si_ZZ(Integer d, ring *_ring) noexcept:
|
|
1469
|
+
"""
|
|
1470
|
+
Create a singular number from a sage Integer.
|
|
1471
|
+
|
|
1472
|
+
INPUT:
|
|
1473
|
+
|
|
1474
|
+
- ``elem`` -- a sage Integer
|
|
1475
|
+
|
|
1476
|
+
- ``_ ring`` -- a (pointer to) a singular ring, where the result will live
|
|
1477
|
+
|
|
1478
|
+
OUTPUT:
|
|
1479
|
+
|
|
1480
|
+
- A (pointer to) a singular number
|
|
1481
|
+
|
|
1482
|
+
TESTS::
|
|
1483
|
+
|
|
1484
|
+
sage: P.<x,y,z> = ZZ[]
|
|
1485
|
+
sage: P(0) + 1 - 1
|
|
1486
|
+
0
|
|
1487
|
+
sage: P(1) + 1 - 1
|
|
1488
|
+
1
|
|
1489
|
+
sage: P(2) + 1 - 1
|
|
1490
|
+
2
|
|
1491
|
+
sage: P(12345678901234567890) + 2 - 2
|
|
1492
|
+
12345678901234567890
|
|
1493
|
+
"""
|
|
1494
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
1495
|
+
cdef number *n = nrzInit(0, _ring.cf)
|
|
1496
|
+
mpz_set(<mpz_ptr>n, d.value)
|
|
1497
|
+
return <number*>n
|
|
1498
|
+
|
|
1499
|
+
cdef inline number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring) noexcept:
|
|
1500
|
+
"""
|
|
1501
|
+
Create a singular number from a sage element of a IntegerModRing.
|
|
1502
|
+
|
|
1503
|
+
INPUT:
|
|
1504
|
+
|
|
1505
|
+
- ``elem`` -- a sage IntegerMod
|
|
1506
|
+
|
|
1507
|
+
- ``_ ring`` -- a (pointer to) a singular ring, where the result will live
|
|
1508
|
+
|
|
1509
|
+
TESTS::
|
|
1510
|
+
|
|
1511
|
+
sage: P.<x,y,z> = Integers(10)[]
|
|
1512
|
+
sage: P(3)
|
|
1513
|
+
3
|
|
1514
|
+
sage: P(13)
|
|
1515
|
+
3
|
|
1516
|
+
|
|
1517
|
+
sage: P.<x,y,z> = Integers(16)[]
|
|
1518
|
+
sage: P(3)
|
|
1519
|
+
3
|
|
1520
|
+
sage: P(19)
|
|
1521
|
+
3
|
|
1522
|
+
|
|
1523
|
+
sage: P.<x,y,z> = Integers(3^2)[]
|
|
1524
|
+
sage: P(3)
|
|
1525
|
+
3
|
|
1526
|
+
sage: P(12)
|
|
1527
|
+
3
|
|
1528
|
+
|
|
1529
|
+
sage: P.<x,y,z> = Integers(2^32)[]
|
|
1530
|
+
sage: P(2^32-1)
|
|
1531
|
+
-1
|
|
1532
|
+
|
|
1533
|
+
sage: P(3)
|
|
1534
|
+
3
|
|
1535
|
+
|
|
1536
|
+
sage: P.<x,y,z> = Integers(17^20)[]
|
|
1537
|
+
sage: P(17^19 + 3)
|
|
1538
|
+
239072435685151324847156
|
|
1539
|
+
|
|
1540
|
+
sage: P(3)
|
|
1541
|
+
3
|
|
1542
|
+
"""
|
|
1543
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
1544
|
+
|
|
1545
|
+
cdef number *nn
|
|
1546
|
+
|
|
1547
|
+
cdef int64_t _d
|
|
1548
|
+
cdef char *_name
|
|
1549
|
+
cdef char **_ext_names
|
|
1550
|
+
|
|
1551
|
+
cdef nMapFunc nMapFuncPtr = NULL
|
|
1552
|
+
|
|
1553
|
+
if _ring.cf.type == n_unknown:
|
|
1554
|
+
return n_Init(int(d), _ring.cf)
|
|
1555
|
+
|
|
1556
|
+
if _ring.cf.type == n_Z2m:
|
|
1557
|
+
_d = d
|
|
1558
|
+
return nr2mMapZp(<number *>_d, currRing.cf, _ring.cf)
|
|
1559
|
+
elif _ring.cf.type == n_Zn or _ring.cf.type == n_Znm:
|
|
1560
|
+
lift = d.lift()
|
|
1561
|
+
|
|
1562
|
+
# if I understand nrnMapGMP/nMapFuncPtr correctly we need first
|
|
1563
|
+
# a source value in ZZr
|
|
1564
|
+
# create ZZr, a plain polynomial ring over ZZ with one variable.
|
|
1565
|
+
#
|
|
1566
|
+
# todo (later): reuse ZZr
|
|
1567
|
+
_name = omStrDup("a")
|
|
1568
|
+
_ext_names = <char**>omAlloc0(sizeof(char*))
|
|
1569
|
+
_ext_names[0] = omStrDup(_name)
|
|
1570
|
+
_cf = nInitChar(n_Z, NULL) # integer coefficient ring
|
|
1571
|
+
ZZr = rDefault (_cf, 1, _ext_names)
|
|
1572
|
+
rComplete(ZZr, 1)
|
|
1573
|
+
ZZr.ShortOut = 0
|
|
1574
|
+
|
|
1575
|
+
nn = nrzInit(0, ZZr.cf)
|
|
1576
|
+
mpz_set(<mpz_ptr>nn, (<Integer>lift).value)
|
|
1577
|
+
nMapFuncPtr = nrnSetMap( ZZr.cf, _ring.cf)
|
|
1578
|
+
|
|
1579
|
+
return nMapFuncPtr(nn, ZZr.cf, _ring.cf)
|
|
1580
|
+
else:
|
|
1581
|
+
raise ValueError
|
|
1582
|
+
|
|
1583
|
+
cdef object si2sa(number *n, ring *_ring, object base):
|
|
1584
|
+
r"""
|
|
1585
|
+
Create a sage number from a singular one.
|
|
1586
|
+
|
|
1587
|
+
INPUT:
|
|
1588
|
+
|
|
1589
|
+
- ``n`` -- a (pointer to) a singular number
|
|
1590
|
+
|
|
1591
|
+
- ``_ring`` -- a (pointer to) the singular ring where ``n`` lives
|
|
1592
|
+
|
|
1593
|
+
- ``object`` -- the sage parent where the result will live
|
|
1594
|
+
|
|
1595
|
+
OUTPUT:
|
|
1596
|
+
|
|
1597
|
+
An element of ``base``
|
|
1598
|
+
"""
|
|
1599
|
+
if isinstance(base, FiniteField_prime_modn) and _ring.cf.type == n_Zp:
|
|
1600
|
+
return base(_ring.cf.cfInt(n, _ring.cf))
|
|
1601
|
+
|
|
1602
|
+
elif isinstance(base, RationalField):
|
|
1603
|
+
return si2sa_QQ(n,&n,_ring)
|
|
1604
|
+
|
|
1605
|
+
elif isinstance(base, IntegerRing_class):
|
|
1606
|
+
return si2sa_ZZ(n,_ring)
|
|
1607
|
+
|
|
1608
|
+
elif isinstance(base, FiniteField_givaro):
|
|
1609
|
+
return si2sa_GFqGivaro(n, _ring, base._cache)
|
|
1610
|
+
|
|
1611
|
+
elif isinstance(base, FiniteField_ntl_gf2e):
|
|
1612
|
+
return si2sa_GFqNTLGF2E(n, _ring, <Cache_ntl_gf2e>base._cache)
|
|
1613
|
+
|
|
1614
|
+
elif isinstance(base, FiniteField):
|
|
1615
|
+
return si2sa_GFq_generic(n, _ring, base)
|
|
1616
|
+
|
|
1617
|
+
elif isinstance(base, NumberField) and base.is_absolute():
|
|
1618
|
+
return si2sa_NF(n, _ring, base)
|
|
1619
|
+
|
|
1620
|
+
elif isinstance(base, FractionField_generic) and isinstance(base.base(), (MPolynomialRing_libsingular, PolynomialRing_field)) and isinstance(base.base_ring(), RationalField):
|
|
1621
|
+
return si2sa_transext_QQ(n, _ring, base)
|
|
1622
|
+
|
|
1623
|
+
elif isinstance(base, FractionField_generic) and isinstance(base.base(), (MPolynomialRing_libsingular, PolynomialRing_field)) and isinstance(base.base_ring(), FiniteField_prime_modn):
|
|
1624
|
+
return si2sa_transext_FF(n, _ring, base)
|
|
1625
|
+
|
|
1626
|
+
elif isinstance(base, IntegerModRing_generic):
|
|
1627
|
+
return si2sa_ZZmod(n, _ring, base)
|
|
1628
|
+
|
|
1629
|
+
else:
|
|
1630
|
+
raise ValueError("cannot convert from SINGULAR number")
|
|
1631
|
+
|
|
1632
|
+
cdef number *sa2si(Element elem, ring * _ring) noexcept:
|
|
1633
|
+
r"""
|
|
1634
|
+
Create a singular number from a sage one.
|
|
1635
|
+
|
|
1636
|
+
INPUT:
|
|
1637
|
+
|
|
1638
|
+
- ``elem`` -- a sage element from a parent; the parent must have a
|
|
1639
|
+
corresponding singular coefficient type
|
|
1640
|
+
|
|
1641
|
+
- ``_ring`` -- a (pointer to) the singular ring where the result will live
|
|
1642
|
+
|
|
1643
|
+
OUTPUT:
|
|
1644
|
+
|
|
1645
|
+
a (pointer to) a singular number
|
|
1646
|
+
"""
|
|
1647
|
+
cdef int i = 0
|
|
1648
|
+
|
|
1649
|
+
if isinstance(elem._parent, FiniteField_prime_modn) and _ring.cf.type == n_Zp:
|
|
1650
|
+
return n_Init(int(elem),_ring.cf)
|
|
1651
|
+
|
|
1652
|
+
elif isinstance(elem._parent, RationalField):
|
|
1653
|
+
return sa2si_QQ(elem, _ring)
|
|
1654
|
+
|
|
1655
|
+
elif isinstance(elem._parent, IntegerRing_class):
|
|
1656
|
+
return sa2si_ZZ(elem, _ring)
|
|
1657
|
+
|
|
1658
|
+
elif isinstance(elem._parent, FiniteField_givaro):
|
|
1659
|
+
return sa2si_GFqGivaro( (<FFgivE>elem)._cache.objectptr.convert(i, (<FFgivE>elem).element ), _ring )
|
|
1660
|
+
|
|
1661
|
+
elif isinstance(elem._parent, FiniteField_ntl_gf2e):
|
|
1662
|
+
return sa2si_GFqNTLGF2E(elem, _ring)
|
|
1663
|
+
|
|
1664
|
+
elif isinstance(elem._parent, FiniteField):
|
|
1665
|
+
return sa2si_GFq_generic(elem, _ring)
|
|
1666
|
+
|
|
1667
|
+
elif isinstance(elem._parent, NumberField) and elem._parent.is_absolute():
|
|
1668
|
+
return sa2si_NF(elem, _ring)
|
|
1669
|
+
elif isinstance(elem._parent, IntegerModRing_generic):
|
|
1670
|
+
return sa2si_ZZmod(elem, _ring)
|
|
1671
|
+
elif isinstance(elem._parent, FractionField_generic) and isinstance(elem._parent.base(), (MPolynomialRing_libsingular, PolynomialRing_field)):
|
|
1672
|
+
if isinstance(elem._parent.base().base_ring(), RationalField):
|
|
1673
|
+
return sa2si_transext_QQ(elem, _ring)
|
|
1674
|
+
elif isinstance(elem._parent.base().base_ring(), FiniteField_prime_modn):
|
|
1675
|
+
return sa2si_transext_FF(elem, _ring)
|
|
1676
|
+
|
|
1677
|
+
raise ValueError("cannot convert to SINGULAR number")
|
|
1678
|
+
|
|
1679
|
+
cdef object si2sa_intvec(intvec *v):
|
|
1680
|
+
r"""
|
|
1681
|
+
Create a sage tuple from a singular vector of integers.
|
|
1682
|
+
|
|
1683
|
+
INPUT:
|
|
1684
|
+
|
|
1685
|
+
- ``v`` -- a (pointer to) singular intvec
|
|
1686
|
+
|
|
1687
|
+
OUTPUT:
|
|
1688
|
+
|
|
1689
|
+
a sage tuple
|
|
1690
|
+
"""
|
|
1691
|
+
cdef int r
|
|
1692
|
+
cdef list l = list()
|
|
1693
|
+
for r in range(v.length()):
|
|
1694
|
+
l.append(v.get(r))
|
|
1695
|
+
return tuple(l)
|
|
1696
|
+
|
|
1697
|
+
cdef object si2sa_bigintvec(bigintmat *v):
|
|
1698
|
+
r"""
|
|
1699
|
+
Create a sage tuple from a singular vector of big integers.
|
|
1700
|
+
|
|
1701
|
+
INPUT:
|
|
1702
|
+
|
|
1703
|
+
- ``v`` -- a (pointer to) singular bigintmat
|
|
1704
|
+
|
|
1705
|
+
OUTPUT:
|
|
1706
|
+
|
|
1707
|
+
a sage tuple
|
|
1708
|
+
"""
|
|
1709
|
+
cdef int r
|
|
1710
|
+
cdef list l = list()
|
|
1711
|
+
for r in range(v.length()):
|
|
1712
|
+
n = v.get(r)
|
|
1713
|
+
l.append(si2sa_QQ(n, &n, currRing))
|
|
1714
|
+
return tuple(l)
|
|
1715
|
+
|
|
1716
|
+
# ==============
|
|
1717
|
+
# Initialisation
|
|
1718
|
+
# ==============
|
|
1719
|
+
|
|
1720
|
+
cdef extern from *: # hack to get at cython macro
|
|
1721
|
+
int unlikely(int)
|
|
1722
|
+
|
|
1723
|
+
from posix.dlfcn cimport dlopen, dlclose, dlerror, RTLD_LAZY, RTLD_GLOBAL
|
|
1724
|
+
|
|
1725
|
+
cdef int overflow_check(unsigned long e, ring *_ring) except -1:
|
|
1726
|
+
"""
|
|
1727
|
+
Raise an :exc:`OverflowError` if e is > max degree per variable.
|
|
1728
|
+
|
|
1729
|
+
INPUT:
|
|
1730
|
+
|
|
1731
|
+
- ``e`` -- some integer representing a degree
|
|
1732
|
+
|
|
1733
|
+
- ``_ring`` -- a pointer to some ring
|
|
1734
|
+
|
|
1735
|
+
Whether an overflow occurs or not partially depends
|
|
1736
|
+
|
|
1737
|
+
on the number of variables in the ring. See github issue
|
|
1738
|
+
:issue:`11856`. With Singular 4, it is by default optimized
|
|
1739
|
+
for at least 4 variables on 64-bit and 2 variables on 32-bit,
|
|
1740
|
+
which in both cases makes a maximal default exponent of
|
|
1741
|
+
2^16-1.
|
|
1742
|
+
|
|
1743
|
+
EXAMPLES::
|
|
1744
|
+
|
|
1745
|
+
sage: P.<x,y> = QQ[]
|
|
1746
|
+
sage: y^(2^30)
|
|
1747
|
+
Traceback (most recent call last): # 32-bit
|
|
1748
|
+
... # 32-bit
|
|
1749
|
+
OverflowError: exponent overflow (1073741824) # 32-bit
|
|
1750
|
+
y^1073741824 # 64-bit
|
|
1751
|
+
sage: y^2^32
|
|
1752
|
+
Traceback (most recent call last):
|
|
1753
|
+
...
|
|
1754
|
+
OverflowError: Python int too large to convert to C unsigned long # 32-bit
|
|
1755
|
+
OverflowError: exponent overflow (4294967296) # 64-bit
|
|
1756
|
+
"""
|
|
1757
|
+
if unlikely(e > _ring.bitmask):
|
|
1758
|
+
raise OverflowError("exponent overflow (%d)" % (e))
|
|
1759
|
+
|
|
1760
|
+
cdef init_libsingular():
|
|
1761
|
+
"""
|
|
1762
|
+
This initializes the SINGULAR library. This is a hack to some
|
|
1763
|
+
extent.
|
|
1764
|
+
|
|
1765
|
+
SINGULAR has a concept of compiled extension modules similar to
|
|
1766
|
+
Sage. For this, the compiled modules need to see the symbols from
|
|
1767
|
+
the main program. However, SINGULAR is a shared library in this
|
|
1768
|
+
context these symbols are not known globally. The work around so
|
|
1769
|
+
far is to load the library again and to specify ``RTLD_GLOBAL``.
|
|
1770
|
+
"""
|
|
1771
|
+
global singular_options
|
|
1772
|
+
global singular_verbose_options
|
|
1773
|
+
global WerrorS_callback
|
|
1774
|
+
global error_messages
|
|
1775
|
+
|
|
1776
|
+
cdef void *handle = NULL
|
|
1777
|
+
|
|
1778
|
+
# This is a workaround for https://github.com/Singular/Singular/issues/1113
|
|
1779
|
+
# and can be removed once that fix makes it into release of Singular that
|
|
1780
|
+
# is supported by sage.
|
|
1781
|
+
from sage.features import FeatureNotPresentError
|
|
1782
|
+
from sage.features.singular import Singular
|
|
1783
|
+
from os.path import dirname
|
|
1784
|
+
try:
|
|
1785
|
+
singular_executable = Singular().absolute_filename()
|
|
1786
|
+
except FeatureNotPresentError:
|
|
1787
|
+
pass
|
|
1788
|
+
else:
|
|
1789
|
+
os.environ["SINGULAR_BIN_DIR"] = dirname(singular_executable)
|
|
1790
|
+
|
|
1791
|
+
# reload the current module to force reload of libSingular (see #33446)
|
|
1792
|
+
lib = str_to_bytes(__loader__.path, FS_ENCODING, "surrogateescape")
|
|
1793
|
+
handle = dlopen(lib, RTLD_GLOBAL|RTLD_LAZY)
|
|
1794
|
+
if not handle:
|
|
1795
|
+
err = dlerror()
|
|
1796
|
+
raise RuntimeError(f"Could not reload Singular library with RTLD_GLOBAL ({err})")
|
|
1797
|
+
|
|
1798
|
+
# load SINGULAR
|
|
1799
|
+
siInit(lib)
|
|
1800
|
+
|
|
1801
|
+
if handle:
|
|
1802
|
+
dlclose(handle)
|
|
1803
|
+
|
|
1804
|
+
# we set and save some global Singular options
|
|
1805
|
+
singular_options = singular_options | Sy_bit(OPT_REDSB) | Sy_bit(OPT_INTSTRATEGY) | Sy_bit(OPT_REDTAIL) | Sy_bit(OPT_REDTHROUGH)
|
|
1806
|
+
global _saved_options
|
|
1807
|
+
global _saved_verbose_options
|
|
1808
|
+
_saved_options = (int(singular_options), 0, 0)
|
|
1809
|
+
_saved_verbose_options = int(singular_verbose_options)
|
|
1810
|
+
|
|
1811
|
+
#On(SW_USE_NTL)
|
|
1812
|
+
On(SW_USE_EZGCD)
|
|
1813
|
+
Off(SW_USE_NTL_SORT)
|
|
1814
|
+
|
|
1815
|
+
WerrorS_callback = libsingular_error_callback
|
|
1816
|
+
|
|
1817
|
+
error_messages = []
|
|
1818
|
+
|
|
1819
|
+
# Save/restore the PATH because libSingular clobbers it:
|
|
1820
|
+
# https://github.com/Singular/Singular/issues/1119
|
|
1821
|
+
saved_PATH = os.environ["PATH"]
|
|
1822
|
+
init_libsingular()
|
|
1823
|
+
os.environ["PATH"] = saved_PATH
|
|
1824
|
+
|
|
1825
|
+
cdef bint catching_error = False
|
|
1826
|
+
|
|
1827
|
+
cdef void libsingular_error_callback(const_char_ptr s) noexcept:
|
|
1828
|
+
_s = char_to_str(s)
|
|
1829
|
+
if catching_error:
|
|
1830
|
+
error_messages.append(_s)
|
|
1831
|
+
else:
|
|
1832
|
+
warn(f"error in Singular ignored: {_s}")
|
|
1833
|
+
|
|
1834
|
+
cdef int start_catch_error() except -1:
|
|
1835
|
+
"""
|
|
1836
|
+
Helper function to convert Singular errors to Python exceptions.
|
|
1837
|
+
|
|
1838
|
+
Must be used as follows::
|
|
1839
|
+
|
|
1840
|
+
start_catch_error()
|
|
1841
|
+
...
|
|
1842
|
+
s = check_error() # nonempty tuple[str, ...] (error messages) or None
|
|
1843
|
+
if s:
|
|
1844
|
+
# at this point global variable ``error_messages`` is cleared
|
|
1845
|
+
raise RuntimeError(...)
|
|
1846
|
+
|
|
1847
|
+
Return value is ignored, only used for exception handling.
|
|
1848
|
+
|
|
1849
|
+
Note that :func:`check_error` can only be called exactly once.
|
|
1850
|
+
|
|
1851
|
+
Note that this *must not* be used in conjunction with :func:`sig_on` as follows::
|
|
1852
|
+
|
|
1853
|
+
start_catch_error()
|
|
1854
|
+
sig_on()
|
|
1855
|
+
...
|
|
1856
|
+
sig_off()
|
|
1857
|
+
if check_error():
|
|
1858
|
+
raise RuntimeError(...)
|
|
1859
|
+
|
|
1860
|
+
because if the code is interrupted, then :func:`check_error` is never called.
|
|
1861
|
+
|
|
1862
|
+
Use the following instead::
|
|
1863
|
+
|
|
1864
|
+
start_catch_error()
|
|
1865
|
+
try:
|
|
1866
|
+
sig_on()
|
|
1867
|
+
... # long time
|
|
1868
|
+
sig_off()
|
|
1869
|
+
finally:
|
|
1870
|
+
if check_error():
|
|
1871
|
+
raise RuntimeError(...)
|
|
1872
|
+
|
|
1873
|
+
If the code inside (marked `# long time`) can also raise a Python exception,
|
|
1874
|
+
the above is still wrong --- :func:`sig_off` may not be called. In this case
|
|
1875
|
+
use a nested ``try`` as suggested in ``cysignals`` documentation::
|
|
1876
|
+
|
|
1877
|
+
start_catch_error()
|
|
1878
|
+
try:
|
|
1879
|
+
sig_on() # This must be OUTSIDE the inner try
|
|
1880
|
+
try:
|
|
1881
|
+
... # long time
|
|
1882
|
+
finally:
|
|
1883
|
+
sig_off()
|
|
1884
|
+
finally:
|
|
1885
|
+
if check_error():
|
|
1886
|
+
raise RuntimeError(...)
|
|
1887
|
+
"""
|
|
1888
|
+
global errorreported, catching_error, error_messages
|
|
1889
|
+
if catching_error:
|
|
1890
|
+
warn("internal error: previous start_catch_error not ended with check_error")
|
|
1891
|
+
catching_error = True
|
|
1892
|
+
|
|
1893
|
+
if errorreported:
|
|
1894
|
+
warn(f"error in Singular ignored: {', '.join(error_messages)}")
|
|
1895
|
+
errorreported = False
|
|
1896
|
+
error_messages.clear()
|
|
1897
|
+
else:
|
|
1898
|
+
assert not error_messages
|
|
1899
|
+
return 0
|
|
1900
|
+
|
|
1901
|
+
cdef object check_error():
|
|
1902
|
+
"""
|
|
1903
|
+
See :func:`start_catch_error`.
|
|
1904
|
+
"""
|
|
1905
|
+
global errorreported, catching_error, error_messages
|
|
1906
|
+
if not catching_error:
|
|
1907
|
+
warn("internal error: check_error not preceded with start_catch_error")
|
|
1908
|
+
catching_error = False
|
|
1909
|
+
|
|
1910
|
+
if errorreported:
|
|
1911
|
+
result = tuple(error_messages)
|
|
1912
|
+
assert result
|
|
1913
|
+
errorreported = False
|
|
1914
|
+
error_messages.clear()
|
|
1915
|
+
return result
|
|
1916
|
+
assert not error_messages
|
|
1917
|
+
return None
|
|
1918
|
+
|
|
1919
|
+
|
|
1920
|
+
def get_resource(id):
|
|
1921
|
+
"""
|
|
1922
|
+
Return a Singular "resource".
|
|
1923
|
+
|
|
1924
|
+
INPUT:
|
|
1925
|
+
|
|
1926
|
+
- ``id`` -- a single-character string; see
|
|
1927
|
+
https://github.com/Singular/Singular/blob/spielwiese/resources/feResource.cc
|
|
1928
|
+
|
|
1929
|
+
OUTPUT: string or ``None``
|
|
1930
|
+
|
|
1931
|
+
EXAMPLES::
|
|
1932
|
+
|
|
1933
|
+
sage: from sage.libs.singular.singular import get_resource
|
|
1934
|
+
sage: get_resource('D') # SINGULAR_DATA_DIR
|
|
1935
|
+
'...'
|
|
1936
|
+
sage: get_resource('i') # SINGULAR_INFO_FILE
|
|
1937
|
+
'.../singular...'
|
|
1938
|
+
sage: get_resource('7') is None # not defined
|
|
1939
|
+
True
|
|
1940
|
+
"""
|
|
1941
|
+
cdef char *result = feGetResource(<char>ord(id))
|
|
1942
|
+
if result == NULL:
|
|
1943
|
+
return None
|
|
1944
|
+
return bytes_to_str(result)
|