passagemath-singular 10.6.31rc3__cp314-cp314-musllinux_1_2_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of passagemath-singular might be problematic. Click here for more details.
- PySingular.cpython-314-x86_64-linux-musl.so +0 -0
- passagemath_singular-10.6.31rc3.dist-info/METADATA +183 -0
- passagemath_singular-10.6.31rc3.dist-info/RECORD +493 -0
- passagemath_singular-10.6.31rc3.dist-info/WHEEL +5 -0
- passagemath_singular-10.6.31rc3.dist-info/top_level.txt +3 -0
- passagemath_singular.libs/libSingular-4-67059f19.4.1.so +0 -0
- passagemath_singular.libs/libcddgmp-30166d29.so.0.1.3 +0 -0
- passagemath_singular.libs/libfactory-4-9d37bcf4.4.1.so +0 -0
- passagemath_singular.libs/libflint-fd6f12fc.so.21.0.0 +0 -0
- passagemath_singular.libs/libgcc_s-0cd532bd.so.1 +0 -0
- passagemath_singular.libs/libgf2x-9e30c3e3.so.3.0.0 +0 -0
- passagemath_singular.libs/libgfortran-2c33b284.so.5.0.0 +0 -0
- passagemath_singular.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
- passagemath_singular.libs/libgsl-42cda06f.so.28.0.0 +0 -0
- passagemath_singular.libs/libmpfr-aaecbfc0.so.6.2.1 +0 -0
- passagemath_singular.libs/libncursesw-9c9e32c3.so.6.5 +0 -0
- passagemath_singular.libs/libntl-26885ca2.so.44.0.1 +0 -0
- passagemath_singular.libs/libomalloc-0-e9ff96db.9.6.so +0 -0
- passagemath_singular.libs/libopenblasp-r0-905cb27d.3.29.so +0 -0
- passagemath_singular.libs/libpolys-4-8bcf8e7d.4.1.so +0 -0
- passagemath_singular.libs/libquadmath-bb76a5fc.so.0.0.0 +0 -0
- passagemath_singular.libs/libreadline-06542304.so.8.2 +0 -0
- passagemath_singular.libs/libsingular_resources-4-73bf7623.4.1.so +0 -0
- passagemath_singular.libs/libstdc++-5d72f927.so.6.0.33 +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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/algebras/quatalg/quaternion_algebra_cython.pyx +261 -0
- sage/algebras/quatalg/quaternion_algebra_element.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/libs/singular/option.pyx +671 -0
- sage/libs/singular/polynomial.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/singular/polynomial.pxd +39 -0
- sage/libs/singular/polynomial.pyx +661 -0
- sage/libs/singular/ring.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/singular/ring.pxd +58 -0
- sage/libs/singular/ring.pyx +893 -0
- sage/libs/singular/singular.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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,1901 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-singular
|
|
2
|
+
"""
|
|
3
|
+
libSingular: Functions
|
|
4
|
+
|
|
5
|
+
Sage implements a C wrapper around the Singular interpreter which
|
|
6
|
+
allows to call any function directly from Sage without string parsing
|
|
7
|
+
or interprocess communication overhead. Users who do not want to call
|
|
8
|
+
Singular functions directly, usually do not have to worry about this
|
|
9
|
+
interface, since it is handled by higher level functions in Sage.
|
|
10
|
+
|
|
11
|
+
EXAMPLES:
|
|
12
|
+
|
|
13
|
+
The direct approach for loading a Singular function is to call the
|
|
14
|
+
function :func:`singular_function` with the function name as
|
|
15
|
+
parameter::
|
|
16
|
+
|
|
17
|
+
sage: from sage.libs.singular.function import singular_function
|
|
18
|
+
sage: P.<a,b,c,d> = PolynomialRing(GF(7))
|
|
19
|
+
sage: std = singular_function('std')
|
|
20
|
+
sage: I = sage.rings.ideal.Cyclic(P)
|
|
21
|
+
sage: std(I)
|
|
22
|
+
[a + b + c + d,
|
|
23
|
+
b^2 + 2*b*d + d^2,
|
|
24
|
+
b*c^2 + c^2*d - b*d^2 - d^3,
|
|
25
|
+
b*c*d^2 + c^2*d^2 - b*d^3 + c*d^3 - d^4 - 1,
|
|
26
|
+
b*d^4 + d^5 - b - d,
|
|
27
|
+
c^3*d^2 + c^2*d^3 - c - d,
|
|
28
|
+
c^2*d^4 + b*c - b*d + c*d - 2*d^2]
|
|
29
|
+
|
|
30
|
+
If a Singular library needs to be loaded before a certain function is
|
|
31
|
+
available, use the :func:`lib` function as shown below::
|
|
32
|
+
|
|
33
|
+
sage: from sage.libs.singular.function import singular_function, lib as singular_lib
|
|
34
|
+
sage: primdecSY = singular_function('primdecSY')
|
|
35
|
+
Traceback (most recent call last):
|
|
36
|
+
...
|
|
37
|
+
NameError: Singular library function 'primdecSY' is not defined
|
|
38
|
+
|
|
39
|
+
sage: singular_lib('primdec.lib')
|
|
40
|
+
sage: primdecSY = singular_function('primdecSY')
|
|
41
|
+
|
|
42
|
+
There is also a short-hand notation for the above::
|
|
43
|
+
|
|
44
|
+
sage: import sage.libs.singular.function_factory
|
|
45
|
+
sage: primdecSY = sage.libs.singular.function_factory.ff.primdec__lib.primdecSY
|
|
46
|
+
|
|
47
|
+
The above line will load "primdec.lib" first and then load the
|
|
48
|
+
function ``primdecSY``.
|
|
49
|
+
|
|
50
|
+
TESTS::
|
|
51
|
+
|
|
52
|
+
sage: from sage.libs.singular.function import singular_function
|
|
53
|
+
sage: std = singular_function('std')
|
|
54
|
+
sage: loads(dumps(std)) == std
|
|
55
|
+
True
|
|
56
|
+
|
|
57
|
+
AUTHORS:
|
|
58
|
+
|
|
59
|
+
- Michael Brickenstein (2009-07): initial implementation, overall design
|
|
60
|
+
- Martin Albrecht (2009-07): clean up, enhancements, etc.
|
|
61
|
+
- Michael Brickenstein (2009-10): extension to more Singular types
|
|
62
|
+
- Martin Albrecht (2010-01): clean up, support for attributes
|
|
63
|
+
- Simon King (2011-04): include the documentation provided by Singular as a code block
|
|
64
|
+
- Burcin Erocal, Michael Brickenstein, Oleksandr Motsak, Alexander Dreyer, Simon King (2011-09): plural support
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
#*****************************************************************************
|
|
68
|
+
# Copyright (C) 2009 Michael Brickenstein <brickenstein@mfo.de>
|
|
69
|
+
# Copyright (C) 2009,2010 Martin Albrecht <M.R.Albrecht@rhul.ac.uk>
|
|
70
|
+
#
|
|
71
|
+
# This program is free software: you can redistribute it and/or modify
|
|
72
|
+
# it under the terms of the GNU General Public License as published by
|
|
73
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
74
|
+
# (at your option) any later version.
|
|
75
|
+
# http://www.gnu.org/licenses/
|
|
76
|
+
#*****************************************************************************
|
|
77
|
+
|
|
78
|
+
from libc.string cimport memcpy
|
|
79
|
+
from cysignals.signals cimport sig_on, sig_off
|
|
80
|
+
|
|
81
|
+
from sage.cpython.string cimport str_to_bytes, char_to_str
|
|
82
|
+
|
|
83
|
+
from sage.structure.sage_object cimport SageObject
|
|
84
|
+
from sage.structure.richcmp cimport richcmp
|
|
85
|
+
from sage.structure.sequence import Sequence, Sequence_generic
|
|
86
|
+
|
|
87
|
+
from sage.modules.free_module_element cimport FreeModuleElement_generic_dense
|
|
88
|
+
|
|
89
|
+
from sage.rings.integer cimport Integer
|
|
90
|
+
from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomial_libsingular, new_MP
|
|
91
|
+
from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomialRing_libsingular
|
|
92
|
+
from sage.rings.polynomial.plural cimport NCPolynomialRing_plural, NCPolynomial_plural, new_NCP
|
|
93
|
+
from sage.rings.polynomial.multi_polynomial_ideal import NCPolynomialIdeal
|
|
94
|
+
from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal
|
|
95
|
+
from sage.rings.polynomial.multi_polynomial_ideal_libsingular cimport sage_ideal_to_singular_ideal, singular_ideal_to_sage_sequence
|
|
96
|
+
from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence_generic
|
|
97
|
+
|
|
98
|
+
from sage.libs.singular.decl cimport *
|
|
99
|
+
from sage.libs.singular.option import opt_ctx
|
|
100
|
+
from sage.libs.singular.polynomial cimport singular_vector_maximal_component
|
|
101
|
+
from sage.libs.singular.singular cimport sa2si, si2sa, si2sa_intvec, si2sa_bigintvec, start_catch_error, check_error
|
|
102
|
+
from sage.libs.singular.singular import error_messages
|
|
103
|
+
|
|
104
|
+
from sage.interfaces.singular import get_docstring
|
|
105
|
+
|
|
106
|
+
from sage.misc.verbose import get_verbose
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
cdef poly* sage_vector_to_poly(v, ring *r) except <poly*> -1:
|
|
110
|
+
"""
|
|
111
|
+
Convert a vector or list of multivariate polynomials to a
|
|
112
|
+
polynomial by adding them all up.
|
|
113
|
+
"""
|
|
114
|
+
cdef poly *res = NULL
|
|
115
|
+
cdef poly *poly_component
|
|
116
|
+
cdef poly *p_iter
|
|
117
|
+
cdef int component
|
|
118
|
+
|
|
119
|
+
for (i, p) in enumerate(v):
|
|
120
|
+
component = <int>i+1
|
|
121
|
+
poly_component = copy_sage_polynomial_into_singular_poly(p)
|
|
122
|
+
p_iter = poly_component
|
|
123
|
+
while p_iter!=NULL:
|
|
124
|
+
p_SetComp(p_iter, component, r)
|
|
125
|
+
p_Setm(p_iter, r)
|
|
126
|
+
p_iter=pNext(p_iter)
|
|
127
|
+
res=p_Add_q(res, poly_component, r)
|
|
128
|
+
return res
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
cdef class RingWrap:
|
|
132
|
+
"""
|
|
133
|
+
A simple wrapper around Singular's rings.
|
|
134
|
+
"""
|
|
135
|
+
def __repr__(self):
|
|
136
|
+
"""
|
|
137
|
+
EXAMPLES::
|
|
138
|
+
|
|
139
|
+
sage: from sage.libs.singular.function import singular_function
|
|
140
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
141
|
+
sage: ringlist = singular_function("ringlist")
|
|
142
|
+
sage: l = ringlist(P)
|
|
143
|
+
sage: ring = singular_function("ring")
|
|
144
|
+
sage: ring(l, ring=P)
|
|
145
|
+
<RingWrap>
|
|
146
|
+
"""
|
|
147
|
+
if not self.is_commutative():
|
|
148
|
+
return "<noncommutative RingWrap>"
|
|
149
|
+
return "<RingWrap>"
|
|
150
|
+
|
|
151
|
+
def __dealloc__(self):
|
|
152
|
+
if self._ring != NULL:
|
|
153
|
+
self._ring.ref -= 1
|
|
154
|
+
|
|
155
|
+
def ngens(self):
|
|
156
|
+
"""
|
|
157
|
+
Get number of generators.
|
|
158
|
+
|
|
159
|
+
EXAMPLES::
|
|
160
|
+
|
|
161
|
+
sage: from sage.libs.singular.function import singular_function
|
|
162
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
163
|
+
sage: ringlist = singular_function("ringlist")
|
|
164
|
+
sage: l = ringlist(P)
|
|
165
|
+
sage: ring = singular_function("ring")
|
|
166
|
+
sage: ring(l, ring=P).ngens()
|
|
167
|
+
3
|
|
168
|
+
"""
|
|
169
|
+
return self._ring.N
|
|
170
|
+
|
|
171
|
+
def var_names(self):
|
|
172
|
+
"""
|
|
173
|
+
Get names of variables.
|
|
174
|
+
|
|
175
|
+
EXAMPLES::
|
|
176
|
+
|
|
177
|
+
sage: from sage.libs.singular.function import singular_function
|
|
178
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
179
|
+
sage: ringlist = singular_function("ringlist")
|
|
180
|
+
sage: l = ringlist(P)
|
|
181
|
+
sage: ring = singular_function("ring")
|
|
182
|
+
sage: ring(l, ring=P).var_names()
|
|
183
|
+
['x', 'y', 'z']
|
|
184
|
+
"""
|
|
185
|
+
return [char_to_str(self._ring.names[i]) for i in range(self.ngens())]
|
|
186
|
+
|
|
187
|
+
def npars(self):
|
|
188
|
+
"""
|
|
189
|
+
Get number of parameters.
|
|
190
|
+
|
|
191
|
+
EXAMPLES::
|
|
192
|
+
|
|
193
|
+
sage: from sage.libs.singular.function import singular_function
|
|
194
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
195
|
+
sage: ringlist = singular_function("ringlist")
|
|
196
|
+
sage: l = ringlist(P)
|
|
197
|
+
sage: ring = singular_function("ring")
|
|
198
|
+
sage: ring(l, ring=P).npars()
|
|
199
|
+
0
|
|
200
|
+
"""
|
|
201
|
+
return n_NumberOfParameters(self._ring.cf)
|
|
202
|
+
|
|
203
|
+
def ordering_string(self):
|
|
204
|
+
"""
|
|
205
|
+
Get Singular string defining monomial ordering.
|
|
206
|
+
|
|
207
|
+
EXAMPLES::
|
|
208
|
+
|
|
209
|
+
sage: from sage.libs.singular.function import singular_function
|
|
210
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
211
|
+
sage: ringlist = singular_function("ringlist")
|
|
212
|
+
sage: l = ringlist(P)
|
|
213
|
+
sage: ring = singular_function("ring")
|
|
214
|
+
sage: ring(l, ring=P).ordering_string()
|
|
215
|
+
'dp(3),C'
|
|
216
|
+
"""
|
|
217
|
+
return char_to_str(rOrderingString(self._ring))
|
|
218
|
+
|
|
219
|
+
def par_names(self):
|
|
220
|
+
"""
|
|
221
|
+
Get parameter names.
|
|
222
|
+
|
|
223
|
+
EXAMPLES::
|
|
224
|
+
|
|
225
|
+
sage: from sage.libs.singular.function import singular_function
|
|
226
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
227
|
+
sage: ringlist = singular_function("ringlist")
|
|
228
|
+
sage: l = ringlist(P)
|
|
229
|
+
sage: ring = singular_function("ring")
|
|
230
|
+
sage: ring(l, ring=P).par_names()
|
|
231
|
+
[]
|
|
232
|
+
"""
|
|
233
|
+
return [char_to_str(n_ParameterNames(self._ring.cf)[i])
|
|
234
|
+
for i in range(self.npars())]
|
|
235
|
+
|
|
236
|
+
def characteristic(self):
|
|
237
|
+
"""
|
|
238
|
+
Get characteristic.
|
|
239
|
+
|
|
240
|
+
EXAMPLES::
|
|
241
|
+
|
|
242
|
+
sage: from sage.libs.singular.function import singular_function
|
|
243
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
244
|
+
sage: ringlist = singular_function("ringlist")
|
|
245
|
+
sage: l = ringlist(P)
|
|
246
|
+
sage: ring = singular_function("ring")
|
|
247
|
+
sage: ring(l, ring=P).characteristic()
|
|
248
|
+
0
|
|
249
|
+
"""
|
|
250
|
+
return self._ring.cf.ch
|
|
251
|
+
|
|
252
|
+
def is_commutative(self):
|
|
253
|
+
"""
|
|
254
|
+
Determine whether a given ring is commutative.
|
|
255
|
+
|
|
256
|
+
EXAMPLES::
|
|
257
|
+
|
|
258
|
+
sage: from sage.libs.singular.function import singular_function
|
|
259
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
260
|
+
sage: ringlist = singular_function("ringlist")
|
|
261
|
+
sage: l = ringlist(P)
|
|
262
|
+
sage: ring = singular_function("ring")
|
|
263
|
+
sage: ring(l, ring=P).is_commutative()
|
|
264
|
+
True
|
|
265
|
+
"""
|
|
266
|
+
return not rIsPluralRing(self._ring)
|
|
267
|
+
|
|
268
|
+
def _output(self):
|
|
269
|
+
"""
|
|
270
|
+
Use Singular output.
|
|
271
|
+
|
|
272
|
+
EXAMPLES::
|
|
273
|
+
|
|
274
|
+
sage: from sage.libs.singular.function import singular_function
|
|
275
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
276
|
+
sage: ringlist = singular_function("ringlist")
|
|
277
|
+
sage: l = ringlist(P)
|
|
278
|
+
sage: ring = singular_function("ring")
|
|
279
|
+
sage: ring(l, ring=P)._output()
|
|
280
|
+
// coefficients: QQ...
|
|
281
|
+
// number of vars : 3
|
|
282
|
+
// block 1 : ordering dp
|
|
283
|
+
// : names x y z
|
|
284
|
+
// block 2 : ordering C
|
|
285
|
+
"""
|
|
286
|
+
rPrint(self._ring)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
cdef class Resolution:
|
|
290
|
+
"""
|
|
291
|
+
A simple wrapper around Singular's resolutions.
|
|
292
|
+
"""
|
|
293
|
+
def __init__(self, base_ring):
|
|
294
|
+
"""
|
|
295
|
+
EXAMPLES::
|
|
296
|
+
|
|
297
|
+
sage: from sage.libs.singular.function import singular_function
|
|
298
|
+
sage: mres = singular_function("mres")
|
|
299
|
+
sage: syz = singular_function("syz")
|
|
300
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
301
|
+
sage: I = P.ideal([x+y,x*y-y, y*2,x**2+1])
|
|
302
|
+
sage: M = syz(I)
|
|
303
|
+
sage: resolution = mres(M, 0)
|
|
304
|
+
"""
|
|
305
|
+
# FIXME: still not working noncommutative
|
|
306
|
+
assert is_sage_wrapper_for_singular_ring(base_ring)
|
|
307
|
+
self.base_ring = base_ring
|
|
308
|
+
|
|
309
|
+
def __repr__(self):
|
|
310
|
+
"""
|
|
311
|
+
EXAMPLES::
|
|
312
|
+
|
|
313
|
+
sage: from sage.libs.singular.function import singular_function
|
|
314
|
+
sage: mres = singular_function("mres")
|
|
315
|
+
sage: syz = singular_function("syz")
|
|
316
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
317
|
+
sage: I = P.ideal([x+y,x*y-y, y*2,x**2+1])
|
|
318
|
+
sage: M = syz(I)
|
|
319
|
+
sage: resolution = mres(M, 0)
|
|
320
|
+
sage: resolution
|
|
321
|
+
<Resolution>
|
|
322
|
+
"""
|
|
323
|
+
return "<Resolution>"
|
|
324
|
+
|
|
325
|
+
def __dealloc__(self):
|
|
326
|
+
"""
|
|
327
|
+
EXAMPLES::
|
|
328
|
+
|
|
329
|
+
sage: from sage.libs.singular.function import singular_function
|
|
330
|
+
sage: mres = singular_function("mres")
|
|
331
|
+
sage: syz = singular_function("syz")
|
|
332
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
333
|
+
sage: I = P.ideal([x+y,x*y-y, y*2,x**2+1])
|
|
334
|
+
sage: M = syz(I)
|
|
335
|
+
sage: resolution = mres(M, 0)
|
|
336
|
+
sage: del resolution
|
|
337
|
+
"""
|
|
338
|
+
if self._resolution != NULL:
|
|
339
|
+
self._resolution.references -= 1
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
cdef leftv* new_leftv(void *data, res_type) noexcept:
|
|
343
|
+
"""
|
|
344
|
+
INPUT:
|
|
345
|
+
|
|
346
|
+
- ``data`` -- some Singular data this interpreter object points to
|
|
347
|
+
- ``res_type`` -- the type of that data
|
|
348
|
+
"""
|
|
349
|
+
cdef leftv* res
|
|
350
|
+
res = <leftv*>omAllocBin(sleftv_bin)
|
|
351
|
+
res.Init()
|
|
352
|
+
res.data = data
|
|
353
|
+
res.rtyp = res_type
|
|
354
|
+
return res
|
|
355
|
+
|
|
356
|
+
cdef free_leftv(leftv *args, ring *r=NULL):
|
|
357
|
+
"""
|
|
358
|
+
Kills this ``leftv`` and all ``leftv``s in the tail.
|
|
359
|
+
|
|
360
|
+
INPUT:
|
|
361
|
+
|
|
362
|
+
- ``args`` -- list of Singular arguments
|
|
363
|
+
"""
|
|
364
|
+
args.CleanUp(r)
|
|
365
|
+
omFreeBin(args, sleftv_bin)
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
# =====================================
|
|
369
|
+
# = Singular/Plural Abstraction Layer =
|
|
370
|
+
# =====================================
|
|
371
|
+
|
|
372
|
+
def is_sage_wrapper_for_singular_ring(ring):
|
|
373
|
+
"""
|
|
374
|
+
Check whether wrapped ring arises from Singular or Singular/Plural.
|
|
375
|
+
|
|
376
|
+
EXAMPLES::
|
|
377
|
+
|
|
378
|
+
sage: from sage.libs.singular.function import is_sage_wrapper_for_singular_ring
|
|
379
|
+
sage: P.<x,y,z> = QQ[]
|
|
380
|
+
sage: is_sage_wrapper_for_singular_ring(P)
|
|
381
|
+
True
|
|
382
|
+
|
|
383
|
+
::
|
|
384
|
+
|
|
385
|
+
sage: # needs sage.combinat
|
|
386
|
+
sage: A.<x,y,z> = FreeAlgebra(QQ, 3)
|
|
387
|
+
sage: P = A.g_algebra(relations={y*x:-x*y}, order = 'lex')
|
|
388
|
+
sage: is_sage_wrapper_for_singular_ring(P)
|
|
389
|
+
True
|
|
390
|
+
"""
|
|
391
|
+
return isinstance(ring, (MPolynomialRing_libsingular,
|
|
392
|
+
NCPolynomialRing_plural))
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
cdef new_sage_polynomial(ring, poly *p):
|
|
396
|
+
if isinstance(ring, MPolynomialRing_libsingular):
|
|
397
|
+
return new_MP(ring, p)
|
|
398
|
+
else:
|
|
399
|
+
if isinstance(ring, NCPolynomialRing_plural):
|
|
400
|
+
return new_NCP(ring, p)
|
|
401
|
+
raise ValueError("not a singular or plural ring")
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
def is_singular_poly_wrapper(p):
|
|
405
|
+
"""
|
|
406
|
+
Check if ``p`` is some data type corresponding to some singular ``poly``.
|
|
407
|
+
|
|
408
|
+
EXAMPLES::
|
|
409
|
+
|
|
410
|
+
sage: # needs sage.combinat
|
|
411
|
+
sage: from sage.libs.singular.function import is_singular_poly_wrapper
|
|
412
|
+
sage: A.<x,y,z> = FreeAlgebra(QQ, 3)
|
|
413
|
+
sage: H.<x,y,z> = A.g_algebra({z*x:x*z+2*x, z*y:y*z-2*y})
|
|
414
|
+
sage: is_singular_poly_wrapper(x+y)
|
|
415
|
+
True
|
|
416
|
+
"""
|
|
417
|
+
return isinstance(p, (MPolynomial_libsingular, NCPolynomial_plural))
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def all_singular_poly_wrapper(s):
|
|
421
|
+
"""
|
|
422
|
+
Test for a sequence ``s``, whether it consists of
|
|
423
|
+
singular polynomials.
|
|
424
|
+
|
|
425
|
+
EXAMPLES::
|
|
426
|
+
|
|
427
|
+
sage: from sage.libs.singular.function import all_singular_poly_wrapper
|
|
428
|
+
sage: P.<x,y,z> = QQ[]
|
|
429
|
+
sage: all_singular_poly_wrapper([x+1, y])
|
|
430
|
+
True
|
|
431
|
+
sage: all_singular_poly_wrapper([x+1, y, 1])
|
|
432
|
+
False
|
|
433
|
+
"""
|
|
434
|
+
return all(is_singular_poly_wrapper(p) for p in s)
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
cdef poly* access_singular_poly(p) except <poly*> -1:
|
|
438
|
+
"""
|
|
439
|
+
Get the raw ``poly`` pointer from a wrapper object.
|
|
440
|
+
"""
|
|
441
|
+
if isinstance(p, MPolynomial_libsingular):
|
|
442
|
+
return (<MPolynomial_libsingular> p)._poly
|
|
443
|
+
else:
|
|
444
|
+
if isinstance(p, NCPolynomial_plural):
|
|
445
|
+
return (<NCPolynomial_plural> p)._poly
|
|
446
|
+
raise ValueError("not a singular polynomial wrapper")
|
|
447
|
+
|
|
448
|
+
cdef ring* access_singular_ring(r) except <ring*> -1:
|
|
449
|
+
"""
|
|
450
|
+
Get the singular ``ring`` pointer from a wrapper object.
|
|
451
|
+
"""
|
|
452
|
+
if isinstance(r, MPolynomialRing_libsingular):
|
|
453
|
+
return (<MPolynomialRing_libsingular> r )._ring
|
|
454
|
+
if isinstance(r, NCPolynomialRing_plural):
|
|
455
|
+
return (<NCPolynomialRing_plural> r )._ring
|
|
456
|
+
raise ValueError("not a singular polynomial ring wrapper")
|
|
457
|
+
|
|
458
|
+
cdef poly* copy_sage_polynomial_into_singular_poly(p) noexcept:
|
|
459
|
+
return p_Copy(access_singular_poly(p), access_singular_ring(p.parent()))
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
def all_vectors(s):
|
|
463
|
+
"""
|
|
464
|
+
Check if a sequence ``s`` consists of free module elements
|
|
465
|
+
over a singular ring.
|
|
466
|
+
|
|
467
|
+
EXAMPLES::
|
|
468
|
+
|
|
469
|
+
sage: from sage.libs.singular.function import all_vectors
|
|
470
|
+
sage: P.<x,y,z> = QQ[]
|
|
471
|
+
sage: M = P**2
|
|
472
|
+
sage: all_vectors([x])
|
|
473
|
+
False
|
|
474
|
+
sage: all_vectors([(x,y)])
|
|
475
|
+
False
|
|
476
|
+
sage: all_vectors([M(0), M((x,y))])
|
|
477
|
+
True
|
|
478
|
+
sage: all_vectors([M(0), M((x,y)),(0,0)])
|
|
479
|
+
False
|
|
480
|
+
"""
|
|
481
|
+
return all(isinstance(p, FreeModuleElement_generic_dense)
|
|
482
|
+
and is_sage_wrapper_for_singular_ring(p.parent().base_ring())
|
|
483
|
+
for p in s)
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
cdef class Converter(SageObject):
|
|
487
|
+
"""
|
|
488
|
+
A :class:`Converter` interfaces between Sage objects and Singular
|
|
489
|
+
interpreter objects.
|
|
490
|
+
"""
|
|
491
|
+
|
|
492
|
+
def __init__(self, args, ring, attributes=None):
|
|
493
|
+
"""
|
|
494
|
+
Create a new argument list.
|
|
495
|
+
|
|
496
|
+
INPUT:
|
|
497
|
+
|
|
498
|
+
- ``args`` -- list of Python objects
|
|
499
|
+
- ``ring`` -- a multivariate polynomial ring
|
|
500
|
+
- ``attributes`` -- an optional dictionary of Singular
|
|
501
|
+
attributes (default: ``None``)
|
|
502
|
+
|
|
503
|
+
EXAMPLES::
|
|
504
|
+
|
|
505
|
+
sage: from sage.libs.singular.function import Converter
|
|
506
|
+
sage: P.<a,b,c> = PolynomialRing(GF(127))
|
|
507
|
+
sage: Converter([a,b,c],ring=P)
|
|
508
|
+
Singular Converter in Multivariate Polynomial Ring in a, b, c over Finite Field of size 127
|
|
509
|
+
"""
|
|
510
|
+
cdef leftv *v
|
|
511
|
+
self.args = NULL
|
|
512
|
+
self._sage_ring = ring
|
|
513
|
+
if ring is not None:
|
|
514
|
+
self._singular_ring = access_singular_ring(ring)
|
|
515
|
+
|
|
516
|
+
from sage.matrix.matrix_mpolynomial_dense import Matrix_mpolynomial_dense
|
|
517
|
+
from sage.matrix.matrix_integer_dense import Matrix_integer_dense
|
|
518
|
+
from sage.matrix.matrix_generic_dense import Matrix_generic_dense
|
|
519
|
+
for a in args:
|
|
520
|
+
if is_singular_poly_wrapper(a):
|
|
521
|
+
v = self.append_polynomial(a)
|
|
522
|
+
|
|
523
|
+
elif is_sage_wrapper_for_singular_ring(a):
|
|
524
|
+
v = self.append_ring(a)
|
|
525
|
+
|
|
526
|
+
elif isinstance(a, (MPolynomialIdeal, NCPolynomialIdeal)):
|
|
527
|
+
v = self.append_ideal(a)
|
|
528
|
+
|
|
529
|
+
elif isinstance(a, int):
|
|
530
|
+
v = self.append_int(a)
|
|
531
|
+
|
|
532
|
+
elif isinstance(a, str):
|
|
533
|
+
v = self.append_str(a)
|
|
534
|
+
|
|
535
|
+
elif isinstance(a, Matrix_mpolynomial_dense):
|
|
536
|
+
v = self.append_matrix(a)
|
|
537
|
+
|
|
538
|
+
elif isinstance(a, Matrix_integer_dense):
|
|
539
|
+
v = self.append_intmat(a)
|
|
540
|
+
|
|
541
|
+
elif isinstance(a, Matrix_generic_dense) and\
|
|
542
|
+
is_sage_wrapper_for_singular_ring(a.parent().base_ring()):
|
|
543
|
+
v = self.append_matrix(a)
|
|
544
|
+
|
|
545
|
+
elif isinstance(a, Resolution):
|
|
546
|
+
v = self.append_resolution(a)
|
|
547
|
+
|
|
548
|
+
elif isinstance(a, FreeModuleElement_generic_dense)\
|
|
549
|
+
and is_sage_wrapper_for_singular_ring(
|
|
550
|
+
a.parent().base_ring()):
|
|
551
|
+
v = self.append_vector(a)
|
|
552
|
+
|
|
553
|
+
# as output ideals get converted to sequences
|
|
554
|
+
# sequences of polynomials should get converted to ideals
|
|
555
|
+
# this means, that Singular lists should not be converted to Sequences,
|
|
556
|
+
# as we do not want ambiguities
|
|
557
|
+
elif isinstance(a, Sequence_generic)\
|
|
558
|
+
and all_singular_poly_wrapper(a):
|
|
559
|
+
v = self.append_ideal(ring.ideal(a))
|
|
560
|
+
elif isinstance(a, PolynomialSequence_generic):
|
|
561
|
+
v = self.append_ideal(ring.ideal(a))
|
|
562
|
+
elif isinstance(a, Sequence_generic)\
|
|
563
|
+
and all_vectors(a):
|
|
564
|
+
v = self.append_module(a)
|
|
565
|
+
elif isinstance(a, list):
|
|
566
|
+
v = self.append_list(a)
|
|
567
|
+
|
|
568
|
+
elif isinstance(a, tuple):
|
|
569
|
+
is_intvec = True
|
|
570
|
+
for i in a:
|
|
571
|
+
if not isinstance(i, (int, Integer)):
|
|
572
|
+
is_intvec = False
|
|
573
|
+
break
|
|
574
|
+
if is_intvec:
|
|
575
|
+
v = self.append_intvec(a)
|
|
576
|
+
else:
|
|
577
|
+
v = self.append_list(a)
|
|
578
|
+
elif a.parent() is self._sage_ring.base_ring():
|
|
579
|
+
v = self.append_number(a)
|
|
580
|
+
|
|
581
|
+
elif isinstance(a, Integer):
|
|
582
|
+
v = self.append_int(a)
|
|
583
|
+
|
|
584
|
+
else:
|
|
585
|
+
raise TypeError("unknown argument type '%s'" % (type(a),))
|
|
586
|
+
|
|
587
|
+
if attributes and a in attributes:
|
|
588
|
+
for attrib in attributes[a]:
|
|
589
|
+
if attrib == "isSB":
|
|
590
|
+
val = <long>(attributes[a][attrib])
|
|
591
|
+
atSet(v, omStrDup("isSB"), <void*>val, INT_CMD)
|
|
592
|
+
setFlag(v, FLAG_STD)
|
|
593
|
+
else:
|
|
594
|
+
raise NotImplementedError("Support for attribute '%s' not implemented yet." % attrib)
|
|
595
|
+
|
|
596
|
+
def ring(self):
|
|
597
|
+
"""
|
|
598
|
+
Return the ring in which the arguments of this list live.
|
|
599
|
+
|
|
600
|
+
EXAMPLES::
|
|
601
|
+
|
|
602
|
+
sage: from sage.libs.singular.function import Converter
|
|
603
|
+
sage: P.<a,b,c> = PolynomialRing(GF(127))
|
|
604
|
+
sage: Converter([a,b,c],ring=P).ring()
|
|
605
|
+
Multivariate Polynomial Ring in a, b, c over Finite Field of size 127
|
|
606
|
+
"""
|
|
607
|
+
return self._sage_ring
|
|
608
|
+
|
|
609
|
+
def _repr_(self):
|
|
610
|
+
"""
|
|
611
|
+
EXAMPLES::
|
|
612
|
+
|
|
613
|
+
sage: from sage.libs.singular.function import Converter
|
|
614
|
+
sage: P.<a,b,c> = PolynomialRing(GF(127))
|
|
615
|
+
sage: Converter([a,b,c],ring=P) # indirect doctest
|
|
616
|
+
Singular Converter in Multivariate Polynomial Ring in a, b, c over Finite Field of size 127
|
|
617
|
+
"""
|
|
618
|
+
return "Singular Converter in %s" % (self._sage_ring)
|
|
619
|
+
|
|
620
|
+
def __dealloc__(self):
|
|
621
|
+
cdef ring *r = access_singular_ring(self._sage_ring)
|
|
622
|
+
if self.args:
|
|
623
|
+
free_leftv(self.args, r)
|
|
624
|
+
|
|
625
|
+
def __len__(self):
|
|
626
|
+
"""
|
|
627
|
+
EXAMPLES::
|
|
628
|
+
|
|
629
|
+
sage: from sage.libs.singular.function import Converter
|
|
630
|
+
sage: P.<a,b,c> = PolynomialRing(GF(127))
|
|
631
|
+
sage: len(Converter([a,b,c],ring=P))
|
|
632
|
+
3
|
|
633
|
+
"""
|
|
634
|
+
cdef leftv * v
|
|
635
|
+
v = self.args
|
|
636
|
+
cdef int l
|
|
637
|
+
l = 0
|
|
638
|
+
while v != NULL:
|
|
639
|
+
l += 1
|
|
640
|
+
v = v.next
|
|
641
|
+
return l
|
|
642
|
+
|
|
643
|
+
cdef leftv* pop_front(self) except NULL:
|
|
644
|
+
"""
|
|
645
|
+
Pop a Singular element from the front of the list.
|
|
646
|
+
"""
|
|
647
|
+
assert self.args != NULL
|
|
648
|
+
cdef leftv *res = self.args
|
|
649
|
+
self.args = self.args.next
|
|
650
|
+
res.next = NULL
|
|
651
|
+
return res
|
|
652
|
+
|
|
653
|
+
cdef leftv *_append_leftv(self, leftv *v) noexcept:
|
|
654
|
+
"""
|
|
655
|
+
Append a new Singular element to the list.
|
|
656
|
+
"""
|
|
657
|
+
cdef leftv* last
|
|
658
|
+
if not self.args == NULL:
|
|
659
|
+
last = self.args
|
|
660
|
+
while not last.next == NULL:
|
|
661
|
+
last=last.next
|
|
662
|
+
last.next=v
|
|
663
|
+
else:
|
|
664
|
+
self.args = v
|
|
665
|
+
return v
|
|
666
|
+
|
|
667
|
+
cdef leftv *_append(self, void* data, int res_type) noexcept:
|
|
668
|
+
"""
|
|
669
|
+
Create a new ``leftv`` and append it to the list.
|
|
670
|
+
|
|
671
|
+
INPUT:
|
|
672
|
+
|
|
673
|
+
- ``data`` -- the raw data
|
|
674
|
+
- ``res_type`` -- the type of the data
|
|
675
|
+
"""
|
|
676
|
+
return self._append_leftv( new_leftv(data, res_type) )
|
|
677
|
+
|
|
678
|
+
cdef to_sage_matrix(self, matrix* mat):
|
|
679
|
+
"""
|
|
680
|
+
Convert singular matrix to matrix over the polynomial ring.
|
|
681
|
+
"""
|
|
682
|
+
from sage.matrix.constructor import Matrix
|
|
683
|
+
ncols = mat.ncols
|
|
684
|
+
nrows = mat.nrows
|
|
685
|
+
result = Matrix(self._sage_ring, nrows, ncols)
|
|
686
|
+
for i in range(nrows):
|
|
687
|
+
for j in range(ncols):
|
|
688
|
+
p = new_sage_polynomial(self._sage_ring, mat.m[i*ncols+j])
|
|
689
|
+
mat.m[i*ncols+j]=NULL
|
|
690
|
+
result[i,j] = p
|
|
691
|
+
return result
|
|
692
|
+
|
|
693
|
+
cdef to_sage_vector_destructive(self, poly *p, free_module=None):
|
|
694
|
+
cdef int rank
|
|
695
|
+
if free_module:
|
|
696
|
+
rank = free_module.rank()
|
|
697
|
+
else:
|
|
698
|
+
rank = singular_vector_maximal_component(p, self._singular_ring)
|
|
699
|
+
free_module = self._sage_ring**rank
|
|
700
|
+
cdef poly *acc
|
|
701
|
+
cdef poly *p_iter
|
|
702
|
+
cdef poly *first
|
|
703
|
+
cdef poly *previous
|
|
704
|
+
cdef int i
|
|
705
|
+
result = []
|
|
706
|
+
for i from 1 <= i <= rank:
|
|
707
|
+
previous = NULL
|
|
708
|
+
acc = NULL
|
|
709
|
+
first = NULL
|
|
710
|
+
p_iter = p
|
|
711
|
+
while p_iter != NULL:
|
|
712
|
+
if p_GetComp(p_iter, self._singular_ring) == i:
|
|
713
|
+
p_SetComp(p_iter, 0, self._singular_ring)
|
|
714
|
+
p_Setm(p_iter, self._singular_ring)
|
|
715
|
+
if acc == NULL:
|
|
716
|
+
first = p_iter
|
|
717
|
+
else:
|
|
718
|
+
acc.next = p_iter
|
|
719
|
+
acc = p_iter
|
|
720
|
+
if p_iter == p:
|
|
721
|
+
p = pNext(p_iter)
|
|
722
|
+
if previous != NULL:
|
|
723
|
+
previous.next = pNext(p_iter)
|
|
724
|
+
p_iter = pNext(p_iter)
|
|
725
|
+
acc.next = NULL
|
|
726
|
+
else:
|
|
727
|
+
previous = p_iter
|
|
728
|
+
p_iter = pNext(p_iter)
|
|
729
|
+
|
|
730
|
+
result.append(new_sage_polynomial(self._sage_ring, first))
|
|
731
|
+
return free_module(result)
|
|
732
|
+
|
|
733
|
+
cdef object to_sage_module_element_sequence_destructive( self, ideal *i):
|
|
734
|
+
"""
|
|
735
|
+
Convert a SINGULAR module to a Sage Sequence (the format Sage
|
|
736
|
+
stores a Groebner basis in).
|
|
737
|
+
|
|
738
|
+
INPUT:
|
|
739
|
+
|
|
740
|
+
- ``i`` -- a SINGULAR ideal
|
|
741
|
+
- ``r`` -- a SINGULAR ring
|
|
742
|
+
- ``sage_ring`` -- a Sage ring matching r
|
|
743
|
+
"""
|
|
744
|
+
cdef int j
|
|
745
|
+
cdef int rank=i.rank
|
|
746
|
+
free_module = self._sage_ring ** rank
|
|
747
|
+
l = []
|
|
748
|
+
|
|
749
|
+
for j from 0 <= j < IDELEMS(i):
|
|
750
|
+
p = self.to_sage_vector_destructive(i.m[j], free_module)
|
|
751
|
+
i.m[j] = NULL # save it from getting freed
|
|
752
|
+
l.append( p )
|
|
753
|
+
|
|
754
|
+
return Sequence(l, check=False, immutable=True)
|
|
755
|
+
|
|
756
|
+
cdef to_sage_integer_matrix(self, intvec* mat):
|
|
757
|
+
"""
|
|
758
|
+
Convert Singular matrix to matrix over the polynomial ring.
|
|
759
|
+
"""
|
|
760
|
+
from sage.matrix.constructor import Matrix
|
|
761
|
+
from sage.rings.integer_ring import ZZ
|
|
762
|
+
|
|
763
|
+
ncols = mat.cols()
|
|
764
|
+
nrows = mat.rows()
|
|
765
|
+
|
|
766
|
+
result = Matrix(ZZ, nrows, ncols)
|
|
767
|
+
for i in range(nrows):
|
|
768
|
+
for j in range(ncols):
|
|
769
|
+
result[i,j] = mat.get(i*ncols+j)
|
|
770
|
+
return result
|
|
771
|
+
|
|
772
|
+
cdef leftv *append_polynomial(self, p) except NULL:
|
|
773
|
+
"""
|
|
774
|
+
Append the polynomial ``p`` to the list.
|
|
775
|
+
"""
|
|
776
|
+
cdef poly* _p
|
|
777
|
+
_p = copy_sage_polynomial_into_singular_poly(p)
|
|
778
|
+
|
|
779
|
+
return self._append(_p, POLY_CMD)
|
|
780
|
+
|
|
781
|
+
cdef leftv *append_ideal(self, i) except NULL:
|
|
782
|
+
"""
|
|
783
|
+
Append the ideal ``i`` to the list.
|
|
784
|
+
"""
|
|
785
|
+
cdef ideal* singular_ideal = sage_ideal_to_singular_ideal(i)
|
|
786
|
+
return self._append(singular_ideal, IDEAL_CMD)
|
|
787
|
+
|
|
788
|
+
cdef leftv *append_module(self, m) except NULL:
|
|
789
|
+
"""
|
|
790
|
+
Append sequence ``m`` of vectors over the polynomial ring to
|
|
791
|
+
the list
|
|
792
|
+
"""
|
|
793
|
+
rank = max([v.parent().rank() for v in m])
|
|
794
|
+
cdef ideal *result
|
|
795
|
+
cdef ring *r = self._singular_ring
|
|
796
|
+
cdef ideal *i
|
|
797
|
+
cdef int j = 0
|
|
798
|
+
|
|
799
|
+
i = idInit(len(m),rank)
|
|
800
|
+
for f in m:
|
|
801
|
+
i.m[j] = sage_vector_to_poly(f, r)
|
|
802
|
+
j+=1
|
|
803
|
+
return self._append(<void*> i, MODUL_CMD)
|
|
804
|
+
|
|
805
|
+
cdef leftv *append_number(self, n) except NULL:
|
|
806
|
+
"""
|
|
807
|
+
Append the number ``n`` to the list.
|
|
808
|
+
"""
|
|
809
|
+
cdef number *_n = sa2si(n, self._singular_ring)
|
|
810
|
+
return self._append(<void *>_n, NUMBER_CMD)
|
|
811
|
+
|
|
812
|
+
cdef leftv *append_ring(self, r) except NULL:
|
|
813
|
+
"""
|
|
814
|
+
Append the ring ``r`` to the list.
|
|
815
|
+
"""
|
|
816
|
+
cdef ring *_r = access_singular_ring(r)
|
|
817
|
+
_r.ref += 1
|
|
818
|
+
return self._append(<void *>_r, RING_CMD)
|
|
819
|
+
|
|
820
|
+
cdef leftv *append_matrix(self, mat) except NULL:
|
|
821
|
+
sage_ring = mat.base_ring()
|
|
822
|
+
cdef ring *r=<ring*> access_singular_ring(sage_ring)
|
|
823
|
+
|
|
824
|
+
cdef poly *p
|
|
825
|
+
ncols = mat.ncols()
|
|
826
|
+
nrows = mat.nrows()
|
|
827
|
+
cdef matrix* _m=mpNew(nrows, ncols)
|
|
828
|
+
for i in range(nrows):
|
|
829
|
+
for j in range(ncols):
|
|
830
|
+
#FIXME
|
|
831
|
+
p = copy_sage_polynomial_into_singular_poly(mat[i,j])
|
|
832
|
+
_m.m[ncols*i+j]=p
|
|
833
|
+
return self._append(_m, MATRIX_CMD)
|
|
834
|
+
|
|
835
|
+
cdef leftv *append_int(self, n) except NULL:
|
|
836
|
+
"""
|
|
837
|
+
Append the integer ``n`` to the list.
|
|
838
|
+
"""
|
|
839
|
+
cdef long _n = n
|
|
840
|
+
return self._append(<void*>_n, INT_CMD)
|
|
841
|
+
|
|
842
|
+
cdef leftv *append_list(self, l) except NULL:
|
|
843
|
+
"""
|
|
844
|
+
Append the list ``l`` to the list.
|
|
845
|
+
"""
|
|
846
|
+
|
|
847
|
+
cdef Converter c = Converter(l, self._sage_ring)
|
|
848
|
+
n = len(c)
|
|
849
|
+
|
|
850
|
+
cdef lists *singular_list=<lists*>omAlloc0Bin(slists_bin)
|
|
851
|
+
singular_list.Init(n)
|
|
852
|
+
cdef leftv* iv
|
|
853
|
+
for i in range(n):
|
|
854
|
+
iv=c.pop_front()
|
|
855
|
+
memcpy(&singular_list.m[i],iv,sizeof(leftv))
|
|
856
|
+
omFreeBin(iv, sleftv_bin)
|
|
857
|
+
|
|
858
|
+
return self._append(<void*>singular_list, LIST_CMD)
|
|
859
|
+
|
|
860
|
+
cdef leftv *append_intvec(self, a) except NULL:
|
|
861
|
+
"""
|
|
862
|
+
Append ``a`` to the list as intvec.
|
|
863
|
+
"""
|
|
864
|
+
s = len(a)
|
|
865
|
+
cdef intvec *iv = new intvec()
|
|
866
|
+
iv.resize(s)
|
|
867
|
+
|
|
868
|
+
for i in range(s):
|
|
869
|
+
iv.ivGetVec()[i]=<int>a[i]
|
|
870
|
+
return self._append(<void*>iv, INTVEC_CMD)
|
|
871
|
+
|
|
872
|
+
cdef leftv *append_vector(self, v) except NULL:
|
|
873
|
+
"""
|
|
874
|
+
Append vector ``v`` from free
|
|
875
|
+
module over polynomial ring.
|
|
876
|
+
"""
|
|
877
|
+
cdef ring *r = self._singular_ring
|
|
878
|
+
cdef poly *p = sage_vector_to_poly(v, r)
|
|
879
|
+
return self._append(<void*> p, VECTOR_CMD)
|
|
880
|
+
|
|
881
|
+
cdef leftv *append_resolution(self, Resolution resolution) except NULL:
|
|
882
|
+
"""
|
|
883
|
+
Append free resolution ``r`` to the list.
|
|
884
|
+
"""
|
|
885
|
+
resolution._resolution.references += 1
|
|
886
|
+
return self._append(<void*> resolution._resolution, RESOLUTION_CMD)
|
|
887
|
+
|
|
888
|
+
cdef leftv *append_intmat(self, a) except NULL:
|
|
889
|
+
"""
|
|
890
|
+
Append ``a`` to the list as intvec.
|
|
891
|
+
"""
|
|
892
|
+
cdef int nrows = <int> a.nrows()
|
|
893
|
+
cdef int ncols = <int> a.ncols()
|
|
894
|
+
cdef intvec *iv = new intvec(nrows, ncols, 0)
|
|
895
|
+
|
|
896
|
+
for i in range(nrows):
|
|
897
|
+
for j in range(ncols):
|
|
898
|
+
iv.ivGetVec()[i*ncols+j]=<int>a[i,j]
|
|
899
|
+
return self._append(<void*>iv, INTMAT_CMD)
|
|
900
|
+
|
|
901
|
+
cdef leftv *append_str(self, n) except NULL:
|
|
902
|
+
"""
|
|
903
|
+
Append the string ``n`` to the list.
|
|
904
|
+
"""
|
|
905
|
+
b = str_to_bytes(n)
|
|
906
|
+
return self._append(omStrDup(b), STRING_CMD)
|
|
907
|
+
|
|
908
|
+
cdef to_python(self, leftv* to_convert):
|
|
909
|
+
"""
|
|
910
|
+
Convert the ``leftv`` to a Python object.
|
|
911
|
+
|
|
912
|
+
INPUT:
|
|
913
|
+
|
|
914
|
+
- ``to_convert`` -- a Singular ``leftv``
|
|
915
|
+
|
|
916
|
+
TESTS:
|
|
917
|
+
|
|
918
|
+
Check that negative integers come through unscathed::
|
|
919
|
+
|
|
920
|
+
sage: # needs sage.schemes
|
|
921
|
+
sage: P.<x,y,z> = QQ[]
|
|
922
|
+
sage: C = Curve((x-y)*(y-z)*(z-x))
|
|
923
|
+
sage: I = C.defining_ideal()
|
|
924
|
+
sage: import sage.libs.singular.function_factory
|
|
925
|
+
sage: freerank = sage.libs.singular.function_factory.ff.polylib__lib.freerank
|
|
926
|
+
sage: freerank(I, true)
|
|
927
|
+
[-1, [x^2*y - x*y^2 - x^2*z + y^2*z + x*z^2 - y*z^2]]
|
|
928
|
+
|
|
929
|
+
Singular's genus function is prone to crashing, see :issue:`12851` and :issue:`19750` ::
|
|
930
|
+
|
|
931
|
+
sage: # needs sage.schemes
|
|
932
|
+
sage: sing_genus = sage.libs.singular.function_factory.ff.normal__lib.genus # known bug
|
|
933
|
+
sage: sing_genus(I) # known bug
|
|
934
|
+
-2
|
|
935
|
+
"""
|
|
936
|
+
# FIXME
|
|
937
|
+
cdef MPolynomial_libsingular res_poly
|
|
938
|
+
cdef int rtyp = to_convert.rtyp
|
|
939
|
+
cdef lists *singular_list
|
|
940
|
+
cdef Resolution res_resolution
|
|
941
|
+
|
|
942
|
+
if rtyp == IDEAL_CMD:
|
|
943
|
+
return singular_ideal_to_sage_sequence(<ideal*>to_convert.data, self._singular_ring, self._sage_ring)
|
|
944
|
+
elif rtyp == POLY_CMD:
|
|
945
|
+
# FIXME
|
|
946
|
+
res_poly = MPolynomial_libsingular(self._sage_ring)
|
|
947
|
+
res_poly._poly = <poly*>to_convert.data
|
|
948
|
+
to_convert.data = NULL # prevent it getting free, when cleaning the leftv
|
|
949
|
+
return res_poly
|
|
950
|
+
elif rtyp == INT_CMD:
|
|
951
|
+
return <int><long>to_convert.data
|
|
952
|
+
elif rtyp == NUMBER_CMD:
|
|
953
|
+
return si2sa(<number *>to_convert.data, self._singular_ring, self._sage_ring.base_ring())
|
|
954
|
+
elif rtyp == INTVEC_CMD:
|
|
955
|
+
return si2sa_intvec(<intvec *> to_convert.data)
|
|
956
|
+
elif rtyp == BIGINTVEC_CMD:
|
|
957
|
+
return si2sa_bigintvec(<bigintmat *> to_convert.data)
|
|
958
|
+
elif rtyp == STRING_CMD:
|
|
959
|
+
# TODO: Need to determine what kind of data can be returned by a
|
|
960
|
+
# STRING_CMD--is it just ASCII strings or can it be an arbitrary
|
|
961
|
+
# binary?
|
|
962
|
+
ret = char_to_str(<char *>to_convert.data)
|
|
963
|
+
return ret
|
|
964
|
+
elif rtyp == VECTOR_CMD:
|
|
965
|
+
result = self.to_sage_vector_destructive(<poly *> to_convert.data)
|
|
966
|
+
to_convert.data = NULL
|
|
967
|
+
return result
|
|
968
|
+
elif rtyp == RING_CMD or rtyp==QRING_CMD:
|
|
969
|
+
return new_RingWrap( <ring*> to_convert.data )
|
|
970
|
+
elif rtyp == MATRIX_CMD:
|
|
971
|
+
return self.to_sage_matrix(<matrix*> to_convert.data )
|
|
972
|
+
elif rtyp == LIST_CMD:
|
|
973
|
+
singular_list = <lists*> to_convert.data
|
|
974
|
+
ret = []
|
|
975
|
+
for i in range(singular_list.nr+1):
|
|
976
|
+
ret.append(self.to_python(&(singular_list.m[i])))
|
|
977
|
+
return ret
|
|
978
|
+
elif rtyp == MODUL_CMD:
|
|
979
|
+
return self.to_sage_module_element_sequence_destructive(<ideal*> to_convert.data)
|
|
980
|
+
elif rtyp == INTMAT_CMD:
|
|
981
|
+
return self.to_sage_integer_matrix(<intvec*> to_convert.data)
|
|
982
|
+
elif rtyp == RESOLUTION_CMD:
|
|
983
|
+
res_resolution = Resolution(self._sage_ring)
|
|
984
|
+
res_resolution._resolution = <syStrategy *> to_convert.data
|
|
985
|
+
res_resolution._resolution.references += 1
|
|
986
|
+
return res_resolution
|
|
987
|
+
elif rtyp == NONE:
|
|
988
|
+
return None
|
|
989
|
+
else:
|
|
990
|
+
raise NotImplementedError("rtyp %d not implemented." % (rtyp))
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
cdef class BaseCallHandler:
|
|
994
|
+
"""
|
|
995
|
+
A call handler is an abstraction which hides the details of the
|
|
996
|
+
implementation differences between kernel and library functions.
|
|
997
|
+
"""
|
|
998
|
+
cdef leftv* handle_call(self, Converter argument_list, ring *_ring=NULL) noexcept:
|
|
999
|
+
"""
|
|
1000
|
+
Actual function call.
|
|
1001
|
+
"""
|
|
1002
|
+
return NULL
|
|
1003
|
+
|
|
1004
|
+
cdef bint free_res(self) noexcept:
|
|
1005
|
+
"""
|
|
1006
|
+
Do we need to free the result object.
|
|
1007
|
+
"""
|
|
1008
|
+
return False
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
cdef class LibraryCallHandler(BaseCallHandler):
|
|
1012
|
+
"""
|
|
1013
|
+
A call handler is an abstraction which hides the details of the
|
|
1014
|
+
implementation differences between kernel and library functions.
|
|
1015
|
+
|
|
1016
|
+
This class implements calling a library function.
|
|
1017
|
+
|
|
1018
|
+
.. NOTE::
|
|
1019
|
+
|
|
1020
|
+
Do not construct this class directly, use
|
|
1021
|
+
:func:`singular_function` instead.
|
|
1022
|
+
"""
|
|
1023
|
+
def __init__(self):
|
|
1024
|
+
"""
|
|
1025
|
+
EXAMPLES::
|
|
1026
|
+
|
|
1027
|
+
sage: from sage.libs.singular.function import LibraryCallHandler
|
|
1028
|
+
sage: LibraryCallHandler()
|
|
1029
|
+
<sage.libs.singular.function.LibraryCallHandler object at 0x...>
|
|
1030
|
+
"""
|
|
1031
|
+
super().__init__()
|
|
1032
|
+
|
|
1033
|
+
cdef leftv* handle_call(self, Converter argument_list, ring *_ring=NULL) noexcept:
|
|
1034
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
1035
|
+
cdef bint error = iiMake_proc(self.proc_idhdl, NULL, argument_list.args)
|
|
1036
|
+
cdef leftv * res
|
|
1037
|
+
if not error:
|
|
1038
|
+
res = <leftv*> omAllocBin(sleftv_bin)
|
|
1039
|
+
res.Init()
|
|
1040
|
+
res.Copy(&iiRETURNEXPR)
|
|
1041
|
+
iiRETURNEXPR.Init()
|
|
1042
|
+
return res
|
|
1043
|
+
raise RuntimeError("Error raised calling singular function")
|
|
1044
|
+
|
|
1045
|
+
cdef bint free_res(self) noexcept:
|
|
1046
|
+
"""
|
|
1047
|
+
We do not need to free the result object for library
|
|
1048
|
+
functions.
|
|
1049
|
+
"""
|
|
1050
|
+
return False
|
|
1051
|
+
|
|
1052
|
+
# mapping int --> string for function arity
|
|
1053
|
+
arity_dict = {
|
|
1054
|
+
CMD_1: "CMD_1",
|
|
1055
|
+
CMD_2: "CMD_2",
|
|
1056
|
+
CMD_3: "CMD_3",
|
|
1057
|
+
CMD_12: "CMD_12",
|
|
1058
|
+
CMD_13: "CMD_13",
|
|
1059
|
+
CMD_23: "CMD_23",
|
|
1060
|
+
CMD_123: "CMD_123",
|
|
1061
|
+
CMD_M: "CMD_M"
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
cdef class KernelCallHandler(BaseCallHandler):
|
|
1065
|
+
"""
|
|
1066
|
+
A call handler is an abstraction which hides the details of the
|
|
1067
|
+
implementation differences between kernel and library functions.
|
|
1068
|
+
|
|
1069
|
+
This class implements calling a kernel function.
|
|
1070
|
+
|
|
1071
|
+
.. NOTE::
|
|
1072
|
+
|
|
1073
|
+
Do not construct this class directly, use
|
|
1074
|
+
:func:`singular_function` instead.
|
|
1075
|
+
"""
|
|
1076
|
+
def __init__(self, cmd_n, arity):
|
|
1077
|
+
"""
|
|
1078
|
+
EXAMPLES::
|
|
1079
|
+
|
|
1080
|
+
sage: from sage.libs.singular.function import KernelCallHandler
|
|
1081
|
+
sage: KernelCallHandler(0,0)
|
|
1082
|
+
<sage.libs.singular.function.KernelCallHandler object at 0x...>
|
|
1083
|
+
"""
|
|
1084
|
+
super().__init__()
|
|
1085
|
+
self.cmd_n = cmd_n
|
|
1086
|
+
self.arity = arity
|
|
1087
|
+
|
|
1088
|
+
cdef leftv* handle_call(self, Converter argument_list, ring *_ring=NULL) noexcept:
|
|
1089
|
+
cdef leftv * res
|
|
1090
|
+
res = <leftv*> omAllocBin(sleftv_bin)
|
|
1091
|
+
res.Init()
|
|
1092
|
+
cdef leftv *arg1
|
|
1093
|
+
cdef leftv *arg2
|
|
1094
|
+
cdef leftv *arg3
|
|
1095
|
+
|
|
1096
|
+
cdef Py_ssize_t number_of_arguments = len(argument_list)
|
|
1097
|
+
|
|
1098
|
+
# Handle functions with an arbitrary number of arguments, sent
|
|
1099
|
+
# by an argument list.
|
|
1100
|
+
if self.arity in [CMD_M, ROOT_DECL_LIST, RING_DECL_LIST]:
|
|
1101
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
1102
|
+
iiExprArithM(res, argument_list.args, self.cmd_n)
|
|
1103
|
+
return res
|
|
1104
|
+
|
|
1105
|
+
if number_of_arguments == 1:
|
|
1106
|
+
if self.arity in [CMD_1, CMD_12, CMD_13, CMD_123, RING_CMD]:
|
|
1107
|
+
arg1 = argument_list.pop_front()
|
|
1108
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
1109
|
+
iiExprArith1(res, arg1, self.cmd_n)
|
|
1110
|
+
free_leftv(arg1, _ring)
|
|
1111
|
+
return res
|
|
1112
|
+
|
|
1113
|
+
elif number_of_arguments == 2:
|
|
1114
|
+
if self.arity in [CMD_2, CMD_12, CMD_23, CMD_123]:
|
|
1115
|
+
arg1 = argument_list.pop_front()
|
|
1116
|
+
arg2 = argument_list.pop_front()
|
|
1117
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
1118
|
+
iiExprArith2(res, arg1, self.cmd_n, arg2, True)
|
|
1119
|
+
free_leftv(arg1, _ring)
|
|
1120
|
+
free_leftv(arg2, _ring)
|
|
1121
|
+
return res
|
|
1122
|
+
|
|
1123
|
+
elif number_of_arguments == 3:
|
|
1124
|
+
if self.arity in [CMD_3, CMD_13, CMD_23, CMD_123, RING_CMD]:
|
|
1125
|
+
arg1 = argument_list.pop_front()
|
|
1126
|
+
arg2 = argument_list.pop_front()
|
|
1127
|
+
arg3 = argument_list.pop_front()
|
|
1128
|
+
if _ring != currRing: rChangeCurrRing(_ring)
|
|
1129
|
+
iiExprArith3(res, self.cmd_n, arg1, arg2, arg3)
|
|
1130
|
+
free_leftv(arg1, _ring)
|
|
1131
|
+
free_leftv(arg2, _ring)
|
|
1132
|
+
free_leftv(arg3, _ring)
|
|
1133
|
+
return res
|
|
1134
|
+
|
|
1135
|
+
global errorreported
|
|
1136
|
+
global error_messages
|
|
1137
|
+
|
|
1138
|
+
errorreported += 1
|
|
1139
|
+
error_messages.append(
|
|
1140
|
+
"Wrong number of arguments (got {} arguments, arity is {})"
|
|
1141
|
+
.format(number_of_arguments,
|
|
1142
|
+
arity_dict.get(self.arity) or self.arity))
|
|
1143
|
+
return NULL
|
|
1144
|
+
|
|
1145
|
+
cdef bint free_res(self) noexcept:
|
|
1146
|
+
"""
|
|
1147
|
+
We need to free the result object for kernel functions.
|
|
1148
|
+
"""
|
|
1149
|
+
return True
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
# The Sage ring used as a dummy for singular function calls.
|
|
1153
|
+
cdef object dummy_ring
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
cdef class SingularFunction(SageObject):
|
|
1157
|
+
"""
|
|
1158
|
+
The base class for Singular functions either from the kernel or
|
|
1159
|
+
from the library.
|
|
1160
|
+
"""
|
|
1161
|
+
def __init__(self, name):
|
|
1162
|
+
"""
|
|
1163
|
+
INPUT:
|
|
1164
|
+
|
|
1165
|
+
- ``name`` -- the name of the function
|
|
1166
|
+
|
|
1167
|
+
EXAMPLES::
|
|
1168
|
+
|
|
1169
|
+
sage: from sage.libs.singular.function import SingularFunction
|
|
1170
|
+
sage: SingularFunction('foobar')
|
|
1171
|
+
foobar (singular function)
|
|
1172
|
+
"""
|
|
1173
|
+
self._name = name
|
|
1174
|
+
global currRingHdl
|
|
1175
|
+
if currRingHdl == NULL:
|
|
1176
|
+
currRingHdl = ggetid("my_awesome_sage_ring")
|
|
1177
|
+
if currRingHdl == NULL:
|
|
1178
|
+
currRingHdl = enterid("my_awesome_sage_ring", 0, RING_CMD, &IDROOT, 1)
|
|
1179
|
+
currRingHdl.data.uring = <ring *>omAlloc0Bin(sip_sring_bin)
|
|
1180
|
+
currRingHdl.data.uring.ref += 1
|
|
1181
|
+
|
|
1182
|
+
cdef BaseCallHandler get_call_handler(self):
|
|
1183
|
+
"""
|
|
1184
|
+
Return a call handler which does the actual work.
|
|
1185
|
+
"""
|
|
1186
|
+
raise NotImplementedError
|
|
1187
|
+
|
|
1188
|
+
cdef bint function_exists(self) noexcept:
|
|
1189
|
+
"""
|
|
1190
|
+
Return ``True`` if the function exists in this interface.
|
|
1191
|
+
"""
|
|
1192
|
+
raise NotImplementedError
|
|
1193
|
+
|
|
1194
|
+
def _repr_(self):
|
|
1195
|
+
"""
|
|
1196
|
+
EXAMPLES::
|
|
1197
|
+
|
|
1198
|
+
sage: from sage.libs.singular.function import SingularFunction
|
|
1199
|
+
sage: SingularFunction('foobar') # indirect doctest
|
|
1200
|
+
foobar (singular function)
|
|
1201
|
+
"""
|
|
1202
|
+
return "%s (singular function)" % (self._name)
|
|
1203
|
+
|
|
1204
|
+
def __call__(self, *args, ring=None, bint interruptible=True, attributes=None):
|
|
1205
|
+
"""
|
|
1206
|
+
Call this function with the provided arguments ``args`` in the
|
|
1207
|
+
``ring``.
|
|
1208
|
+
|
|
1209
|
+
INPUT:
|
|
1210
|
+
|
|
1211
|
+
- ``args`` -- list of arguments
|
|
1212
|
+
- ``ring`` -- a multivariate polynomial ring
|
|
1213
|
+
- ``interruptible`` -- if ``True`` pressing :kbd:`Ctrl` + :kbd:`C`
|
|
1214
|
+
during the execution of this function will interrupt the computation
|
|
1215
|
+
(default: ``True``)
|
|
1216
|
+
|
|
1217
|
+
- ``attributes`` -- dictionary of optional Singular
|
|
1218
|
+
attributes assigned to Singular objects (default: ``None``)
|
|
1219
|
+
|
|
1220
|
+
If ``ring`` is not specified, it is guessed from the given arguments.
|
|
1221
|
+
If this is not possible, then a dummy ring, univariate polynomial ring
|
|
1222
|
+
over ``QQ``, is used.
|
|
1223
|
+
|
|
1224
|
+
EXAMPLES::
|
|
1225
|
+
|
|
1226
|
+
sage: from sage.libs.singular.function import singular_function
|
|
1227
|
+
sage: size = singular_function('size')
|
|
1228
|
+
sage: P.<a,b,c> = PolynomialRing(QQ)
|
|
1229
|
+
sage: size(a, ring=P)
|
|
1230
|
+
1
|
|
1231
|
+
sage: size(2r,ring=P)
|
|
1232
|
+
1
|
|
1233
|
+
sage: size(2, ring=P)
|
|
1234
|
+
1
|
|
1235
|
+
sage: size(2)
|
|
1236
|
+
1
|
|
1237
|
+
sage: size(Ideal([a*b + c, a + 1]))
|
|
1238
|
+
2
|
|
1239
|
+
sage: size(Ideal([a*b + c, a + 1]))
|
|
1240
|
+
2
|
|
1241
|
+
sage: size(1,2)
|
|
1242
|
+
Traceback (most recent call last):
|
|
1243
|
+
...
|
|
1244
|
+
RuntimeError: error in Singular function call 'size':
|
|
1245
|
+
Wrong number of arguments (got 2 arguments, arity is CMD_1)
|
|
1246
|
+
sage: size('foobar', ring=P)
|
|
1247
|
+
6
|
|
1248
|
+
|
|
1249
|
+
Show the usage of the optional ``attributes`` parameter::
|
|
1250
|
+
|
|
1251
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
1252
|
+
sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
|
|
1253
|
+
sage: I = Ideal(I.groebner_basis())
|
|
1254
|
+
sage: hilb = sage.libs.singular.function_factory.ff.hilb
|
|
1255
|
+
sage: from sage.misc.sage_ostools import redirection
|
|
1256
|
+
sage: out = tmp_filename()
|
|
1257
|
+
sage: with redirection(sys.stdout, open(out, 'w')):
|
|
1258
|
+
....: hilb(I) # Singular will print // ** _ is no standard basis
|
|
1259
|
+
sage: with open(out) as f:
|
|
1260
|
+
....: 'is no standard basis' in f.read()
|
|
1261
|
+
True
|
|
1262
|
+
|
|
1263
|
+
So we tell Singular that ``I`` is indeed a Groebner basis::
|
|
1264
|
+
|
|
1265
|
+
sage: out = tmp_filename()
|
|
1266
|
+
sage: with redirection(sys.stdout, open(out, 'w')):
|
|
1267
|
+
....: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
|
|
1268
|
+
sage: with open(out) as f:
|
|
1269
|
+
....: 'is no standard basis' in f.read()
|
|
1270
|
+
False
|
|
1271
|
+
|
|
1272
|
+
|
|
1273
|
+
TESTS:
|
|
1274
|
+
|
|
1275
|
+
We show that the interface recovers gracefully from errors::
|
|
1276
|
+
|
|
1277
|
+
sage: P.<e,d,c,b,a> = PolynomialRing(QQ,5,order='lex')
|
|
1278
|
+
sage: I = sage.rings.ideal.Cyclic(P)
|
|
1279
|
+
|
|
1280
|
+
sage: triangL = sage.libs.singular.function_factory.ff.triang__lib.triangL
|
|
1281
|
+
sage: _ = triangL(I)
|
|
1282
|
+
Traceback (most recent call last):
|
|
1283
|
+
...
|
|
1284
|
+
RuntimeError: error in Singular function call 'triangL':
|
|
1285
|
+
The input is no groebner basis.
|
|
1286
|
+
leaving triang.lib::triangL (0)
|
|
1287
|
+
|
|
1288
|
+
Flush any stray output -- see :issue:`28622`::
|
|
1289
|
+
|
|
1290
|
+
sage: sys.stdout.flush()
|
|
1291
|
+
...
|
|
1292
|
+
|
|
1293
|
+
sage: G= Ideal(I.groebner_basis())
|
|
1294
|
+
sage: triangL(G,attributes={G:{'isSB':1}})
|
|
1295
|
+
[[e + d + c + b + a, ...]]
|
|
1296
|
+
"""
|
|
1297
|
+
global dummy_ring
|
|
1298
|
+
|
|
1299
|
+
if ring is None:
|
|
1300
|
+
ring = self.common_ring(args, ring)
|
|
1301
|
+
if ring is None:
|
|
1302
|
+
if dummy_ring is None:
|
|
1303
|
+
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
|
|
1304
|
+
from sage.rings.rational_field import QQ
|
|
1305
|
+
dummy_ring = PolynomialRing(QQ, "dummy", implementation='singular') # seems a reasonable default
|
|
1306
|
+
ring = dummy_ring
|
|
1307
|
+
if not isinstance(ring, (MPolynomialRing_libsingular,
|
|
1308
|
+
NCPolynomialRing_plural)):
|
|
1309
|
+
raise TypeError("cannot call Singular function '%s' with ring parameter of type '%s'" % (self._name, type(ring)))
|
|
1310
|
+
return call_function(self, args, ring, interruptible, attributes)
|
|
1311
|
+
|
|
1312
|
+
def _instancedoc_(self):
|
|
1313
|
+
"""
|
|
1314
|
+
EXAMPLES::
|
|
1315
|
+
|
|
1316
|
+
sage: from sage.libs.singular.function import singular_function
|
|
1317
|
+
sage: groebner = singular_function('groebner')
|
|
1318
|
+
sage: 'groebner' in groebner.__doc__ # needs info
|
|
1319
|
+
True
|
|
1320
|
+
"""
|
|
1321
|
+
|
|
1322
|
+
prefix = \
|
|
1323
|
+
"""
|
|
1324
|
+
This function is an automatically generated C wrapper around the Singular
|
|
1325
|
+
function '%s'.
|
|
1326
|
+
|
|
1327
|
+
This wrapper takes care of converting Sage datatypes to Singular
|
|
1328
|
+
datatypes and vice versa. In addition to whatever parameters the
|
|
1329
|
+
underlying Singular function accepts when called, this function also
|
|
1330
|
+
accepts the following keyword parameters:
|
|
1331
|
+
|
|
1332
|
+
INPUT:
|
|
1333
|
+
|
|
1334
|
+
- ``args`` -- list of arguments
|
|
1335
|
+
- ``ring`` -- a multivariate polynomial ring
|
|
1336
|
+
- ``interruptible`` -- if ``True`` pressing :kbd:`Ctrl` + :kbd:`C` during the
|
|
1337
|
+
execution of this function will interrupt the computation
|
|
1338
|
+
(default: ``True``)
|
|
1339
|
+
- ``attributes`` -- dictionary of optional Singular attributes
|
|
1340
|
+
assigned to Singular objects (default: ``None``)
|
|
1341
|
+
|
|
1342
|
+
If ``ring`` is not specified, it is guessed from the given arguments.
|
|
1343
|
+
If this is not possible, then a dummy ring, univariate polynomial ring
|
|
1344
|
+
over ``QQ``, is used.
|
|
1345
|
+
|
|
1346
|
+
EXAMPLES::
|
|
1347
|
+
|
|
1348
|
+
sage: groebner = sage.libs.singular.function_factory.ff.groebner
|
|
1349
|
+
sage: P.<x, y> = PolynomialRing(QQ)
|
|
1350
|
+
sage: I = P.ideal(x^2-y, y+x)
|
|
1351
|
+
sage: groebner(I)
|
|
1352
|
+
[x + y, y^2 - y]
|
|
1353
|
+
sage: triangL = sage.libs.singular.function_factory.ff.triang__lib.triangL
|
|
1354
|
+
sage: P.<x1, x2> = PolynomialRing(QQ, order='lex')
|
|
1355
|
+
sage: f1 = 1/2*((x1^2 + 2*x1 - 4)*x2^2 + 2*(x1^2 + x1)*x2 + x1^2)
|
|
1356
|
+
sage: f2 = 1/2*((x1^2 + 2*x1 + 1)*x2^2 + 2*(x1^2 + x1)*x2 - 4*x1^2)
|
|
1357
|
+
sage: I = Ideal(Ideal(f1,f2).groebner_basis()[::-1])
|
|
1358
|
+
sage: triangL(I, attributes={I:{'isSB':1}})
|
|
1359
|
+
[[x2^4 + 4*x2^3 - 6*x2^2 - 20*x2 + 5, 8*x1 - x2^3 + x2^2 + 13*x2 - 5],
|
|
1360
|
+
[x2, x1^2],
|
|
1361
|
+
[x2, x1^2],
|
|
1362
|
+
[x2, x1^2]]
|
|
1363
|
+
|
|
1364
|
+
""" % (self._name)
|
|
1365
|
+
from sage.interfaces.singular import get_docstring
|
|
1366
|
+
return prefix + get_docstring(self._name, prefix=True, code=True)
|
|
1367
|
+
|
|
1368
|
+
cdef common_ring(self, tuple args, ring=None):
|
|
1369
|
+
"""
|
|
1370
|
+
Return the common ring for the argument list ``args``.
|
|
1371
|
+
|
|
1372
|
+
If ``ring`` is not ``None`` this routine checks whether it is
|
|
1373
|
+
the parent/ring of all members of ``args`` instead.
|
|
1374
|
+
|
|
1375
|
+
If no common ring was found, None is returned.
|
|
1376
|
+
|
|
1377
|
+
INPUT:
|
|
1378
|
+
|
|
1379
|
+
- ``args`` -- list of Python objects
|
|
1380
|
+
- ``ring`` -- an optional ring to check
|
|
1381
|
+
"""
|
|
1382
|
+
from sage.matrix.matrix_mpolynomial_dense import Matrix_mpolynomial_dense
|
|
1383
|
+
from sage.matrix.matrix_integer_dense import Matrix_integer_dense
|
|
1384
|
+
ring2 = None
|
|
1385
|
+
for a in args:
|
|
1386
|
+
if isinstance(a, MPolynomialIdeal) or \
|
|
1387
|
+
isinstance(a, NCPolynomialIdeal):
|
|
1388
|
+
ring2 = a.ring()
|
|
1389
|
+
elif is_singular_poly_wrapper(a):
|
|
1390
|
+
ring2 = a.parent()
|
|
1391
|
+
elif is_sage_wrapper_for_singular_ring(a):
|
|
1392
|
+
ring2 = a
|
|
1393
|
+
elif isinstance(a, (int, str)):
|
|
1394
|
+
continue
|
|
1395
|
+
elif isinstance(a, Matrix_integer_dense):
|
|
1396
|
+
continue
|
|
1397
|
+
elif isinstance(a, Matrix_mpolynomial_dense):
|
|
1398
|
+
ring2 = a.base_ring()
|
|
1399
|
+
elif isinstance(a, (list, tuple, Sequence_generic)):
|
|
1400
|
+
#TODO: catch exception, if recursion finds no ring
|
|
1401
|
+
ring2 = self.common_ring(tuple(a), ring)
|
|
1402
|
+
elif isinstance(a, Resolution):
|
|
1403
|
+
ring2 = (<Resolution> a).base_ring
|
|
1404
|
+
elif isinstance(a, FreeModuleElement_generic_dense)\
|
|
1405
|
+
and is_sage_wrapper_for_singular_ring(
|
|
1406
|
+
a.parent().base_ring()):
|
|
1407
|
+
ring2 = a.parent().base_ring()
|
|
1408
|
+
elif ring is not None:
|
|
1409
|
+
a.parent() is ring
|
|
1410
|
+
continue
|
|
1411
|
+
|
|
1412
|
+
if ring is None:
|
|
1413
|
+
ring = ring2
|
|
1414
|
+
elif ring is not ring2:
|
|
1415
|
+
raise ValueError("Rings do not match up.")
|
|
1416
|
+
return ring
|
|
1417
|
+
|
|
1418
|
+
def __reduce__(self):
|
|
1419
|
+
"""
|
|
1420
|
+
EXAMPLES::
|
|
1421
|
+
|
|
1422
|
+
sage: from sage.libs.singular.function import singular_function
|
|
1423
|
+
sage: groebner = singular_function('groebner')
|
|
1424
|
+
sage: groebner == loads(dumps(groebner))
|
|
1425
|
+
True
|
|
1426
|
+
"""
|
|
1427
|
+
return singular_function, (self._name,)
|
|
1428
|
+
|
|
1429
|
+
def __richcmp__(self, other, op):
|
|
1430
|
+
"""
|
|
1431
|
+
EXAMPLES::
|
|
1432
|
+
|
|
1433
|
+
sage: from sage.libs.singular.function import singular_function
|
|
1434
|
+
sage: groebner = singular_function('groebner')
|
|
1435
|
+
sage: groebner == singular_function('groebner')
|
|
1436
|
+
True
|
|
1437
|
+
sage: groebner == singular_function('std')
|
|
1438
|
+
False
|
|
1439
|
+
sage: groebner == 1
|
|
1440
|
+
False
|
|
1441
|
+
sage: groebner == None
|
|
1442
|
+
False
|
|
1443
|
+
"""
|
|
1444
|
+
try:
|
|
1445
|
+
lx = <SingularFunction?>self
|
|
1446
|
+
rx = <SingularFunction?>other
|
|
1447
|
+
except TypeError:
|
|
1448
|
+
return NotImplemented
|
|
1449
|
+
return richcmp(lx._name, rx._name, op)
|
|
1450
|
+
|
|
1451
|
+
|
|
1452
|
+
cdef inline call_function(SingularFunction self, tuple args, object R, bint signal_handler=True, attributes=None):
|
|
1453
|
+
global currRingHdl
|
|
1454
|
+
global currentVoice
|
|
1455
|
+
global myynest
|
|
1456
|
+
|
|
1457
|
+
cdef ring *si_ring
|
|
1458
|
+
if isinstance(R, MPolynomialRing_libsingular):
|
|
1459
|
+
si_ring = (<MPolynomialRing_libsingular>R)._ring
|
|
1460
|
+
else:
|
|
1461
|
+
si_ring = (<NCPolynomialRing_plural>R)._ring
|
|
1462
|
+
|
|
1463
|
+
if si_ring != currRing: rChangeCurrRing(si_ring)
|
|
1464
|
+
|
|
1465
|
+
if currRingHdl.data.uring!= currRing:
|
|
1466
|
+
currRingHdl.data.uring.ref -= 1
|
|
1467
|
+
currRingHdl.data.uring = currRing # ref counting?
|
|
1468
|
+
currRingHdl.data.uring.ref += 1
|
|
1469
|
+
|
|
1470
|
+
cdef Converter argument_list = Converter(args, R, attributes)
|
|
1471
|
+
|
|
1472
|
+
cdef leftv * _res
|
|
1473
|
+
|
|
1474
|
+
currentVoice = NULL
|
|
1475
|
+
myynest = 0
|
|
1476
|
+
start_catch_error()
|
|
1477
|
+
|
|
1478
|
+
with opt_ctx: # we are preserving the global options state here
|
|
1479
|
+
if signal_handler:
|
|
1480
|
+
try:
|
|
1481
|
+
sig_on()
|
|
1482
|
+
_res = self.call_handler.handle_call(argument_list, si_ring)
|
|
1483
|
+
sig_off()
|
|
1484
|
+
finally:
|
|
1485
|
+
s = check_error()
|
|
1486
|
+
else:
|
|
1487
|
+
_res = self.call_handler.handle_call(argument_list, si_ring)
|
|
1488
|
+
s = check_error()
|
|
1489
|
+
|
|
1490
|
+
myynest = 0
|
|
1491
|
+
|
|
1492
|
+
if currentVoice:
|
|
1493
|
+
currentVoice = NULL
|
|
1494
|
+
|
|
1495
|
+
if s:
|
|
1496
|
+
raise RuntimeError("error in Singular function call %r:\n%s" %
|
|
1497
|
+
(self._name, "\n".join(s)))
|
|
1498
|
+
|
|
1499
|
+
res = argument_list.to_python(_res)
|
|
1500
|
+
|
|
1501
|
+
if self.call_handler.free_res():
|
|
1502
|
+
free_leftv(_res, si_ring)
|
|
1503
|
+
else:
|
|
1504
|
+
_res.CleanUp(si_ring)
|
|
1505
|
+
|
|
1506
|
+
return res
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
cdef class SingularLibraryFunction(SingularFunction):
|
|
1510
|
+
"""
|
|
1511
|
+
EXAMPLES::
|
|
1512
|
+
|
|
1513
|
+
sage: from sage.libs.singular.function import SingularLibraryFunction
|
|
1514
|
+
sage: R.<x,y> = PolynomialRing(QQ, order='lex')
|
|
1515
|
+
sage: I = R.ideal(x, x+1)
|
|
1516
|
+
sage: f = SingularLibraryFunction("groebner")
|
|
1517
|
+
sage: f(I)
|
|
1518
|
+
[1]
|
|
1519
|
+
"""
|
|
1520
|
+
def __init__(self, name):
|
|
1521
|
+
"""
|
|
1522
|
+
Construct a new Singular library function.
|
|
1523
|
+
|
|
1524
|
+
EXAMPLES::
|
|
1525
|
+
|
|
1526
|
+
sage: from sage.libs.singular.function import SingularLibraryFunction
|
|
1527
|
+
sage: R.<x,y> = PolynomialRing(QQ, order='lex')
|
|
1528
|
+
sage: I = R.ideal(x + 1, x*y + 1)
|
|
1529
|
+
sage: f = SingularLibraryFunction("groebner")
|
|
1530
|
+
sage: f(I)
|
|
1531
|
+
[y - 1, x + 1]
|
|
1532
|
+
"""
|
|
1533
|
+
super().__init__(name)
|
|
1534
|
+
self.call_handler = self.get_call_handler()
|
|
1535
|
+
|
|
1536
|
+
cdef BaseCallHandler get_call_handler(self):
|
|
1537
|
+
cdef idhdl* singular_idhdl = ggetid(str_to_bytes(self._name))
|
|
1538
|
+
if singular_idhdl==NULL:
|
|
1539
|
+
raise NameError("Singular library function {!r} is not defined".format(self._name))
|
|
1540
|
+
if singular_idhdl.typ!=PROC_CMD:
|
|
1541
|
+
raise ValueError("Not a procedure")
|
|
1542
|
+
|
|
1543
|
+
cdef LibraryCallHandler res = LibraryCallHandler()
|
|
1544
|
+
res.proc_idhdl = singular_idhdl
|
|
1545
|
+
return res
|
|
1546
|
+
|
|
1547
|
+
cdef bint function_exists(self) noexcept:
|
|
1548
|
+
cdef idhdl* singular_idhdl = ggetid(str_to_bytes(self._name))
|
|
1549
|
+
return singular_idhdl!=NULL
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
cdef class SingularKernelFunction(SingularFunction):
|
|
1553
|
+
"""
|
|
1554
|
+
EXAMPLES::
|
|
1555
|
+
|
|
1556
|
+
sage: from sage.libs.singular.function import SingularKernelFunction
|
|
1557
|
+
sage: R.<x,y> = PolynomialRing(QQ, order='lex')
|
|
1558
|
+
sage: I = R.ideal(x, x+1)
|
|
1559
|
+
sage: f = SingularKernelFunction("std")
|
|
1560
|
+
sage: f(I)
|
|
1561
|
+
[1]
|
|
1562
|
+
"""
|
|
1563
|
+
def __init__(self, name):
|
|
1564
|
+
"""
|
|
1565
|
+
Construct a new Singular kernel function.
|
|
1566
|
+
|
|
1567
|
+
EXAMPLES::
|
|
1568
|
+
|
|
1569
|
+
sage: from sage.libs.singular.function import SingularKernelFunction
|
|
1570
|
+
sage: R.<x,y> = PolynomialRing(QQ, order='lex')
|
|
1571
|
+
sage: I = R.ideal(x + 1, x*y + 1)
|
|
1572
|
+
sage: f = SingularKernelFunction("std")
|
|
1573
|
+
sage: f(I)
|
|
1574
|
+
[y - 1, x + 1]
|
|
1575
|
+
sage: SingularKernelFunction("no_such_function")
|
|
1576
|
+
Traceback (most recent call last):
|
|
1577
|
+
...
|
|
1578
|
+
NameError: Singular kernel function 'no_such_function' is not defined
|
|
1579
|
+
"""
|
|
1580
|
+
super().__init__(name)
|
|
1581
|
+
self.call_handler = self.get_call_handler()
|
|
1582
|
+
|
|
1583
|
+
cdef BaseCallHandler get_call_handler(self):
|
|
1584
|
+
cdef int cmd_n = 0
|
|
1585
|
+
arity = IsCmd(str_to_bytes(self._name), cmd_n) # call by reverence for CMD_n
|
|
1586
|
+
if not cmd_n:
|
|
1587
|
+
raise NameError("Singular kernel function {!r} is not defined".format(self._name))
|
|
1588
|
+
|
|
1589
|
+
return KernelCallHandler(cmd_n, arity)
|
|
1590
|
+
|
|
1591
|
+
cdef bint function_exists(self) noexcept:
|
|
1592
|
+
cdef int cmd_n = -1
|
|
1593
|
+
arity = IsCmd(str_to_bytes(self._name), cmd_n) # call by reverence for CMD_n
|
|
1594
|
+
return cmd_n != -1
|
|
1595
|
+
|
|
1596
|
+
|
|
1597
|
+
def singular_function(name):
|
|
1598
|
+
"""
|
|
1599
|
+
Construct a new libSingular function object for the given
|
|
1600
|
+
``name``.
|
|
1601
|
+
|
|
1602
|
+
This function works both for interpreter and built-in functions.
|
|
1603
|
+
|
|
1604
|
+
INPUT:
|
|
1605
|
+
|
|
1606
|
+
- ``name`` -- the name of the function
|
|
1607
|
+
|
|
1608
|
+
EXAMPLES::
|
|
1609
|
+
|
|
1610
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
1611
|
+
sage: f = 3*x*y + 2*z + 1
|
|
1612
|
+
sage: g = 2*x + 1/2
|
|
1613
|
+
sage: I = Ideal([f,g])
|
|
1614
|
+
|
|
1615
|
+
::
|
|
1616
|
+
|
|
1617
|
+
sage: from sage.libs.singular.function import singular_function
|
|
1618
|
+
sage: std = singular_function("std")
|
|
1619
|
+
sage: std(I)
|
|
1620
|
+
[3*y - 8*z - 4, 4*x + 1]
|
|
1621
|
+
sage: size = singular_function("size")
|
|
1622
|
+
sage: size([2, 3, 3])
|
|
1623
|
+
3
|
|
1624
|
+
sage: size("sage")
|
|
1625
|
+
4
|
|
1626
|
+
sage: size(["hello", "sage"])
|
|
1627
|
+
2
|
|
1628
|
+
sage: factorize = singular_function("factorize")
|
|
1629
|
+
sage: factorize(f)
|
|
1630
|
+
[[1, 3*x*y + 2*z + 1], (1, 1)]
|
|
1631
|
+
sage: factorize(f, 1)
|
|
1632
|
+
[3*x*y + 2*z + 1]
|
|
1633
|
+
|
|
1634
|
+
We give a wrong number of arguments::
|
|
1635
|
+
|
|
1636
|
+
sage: factorize()
|
|
1637
|
+
Traceback (most recent call last):
|
|
1638
|
+
...
|
|
1639
|
+
RuntimeError: error in Singular function call 'factorize':
|
|
1640
|
+
Wrong number of arguments (got 0 arguments, arity is CMD_12)
|
|
1641
|
+
sage: factorize(f, 1, 2)
|
|
1642
|
+
Traceback (most recent call last):
|
|
1643
|
+
...
|
|
1644
|
+
RuntimeError: error in Singular function call 'factorize':
|
|
1645
|
+
Wrong number of arguments (got 3 arguments, arity is CMD_12)
|
|
1646
|
+
sage: factorize(f, 1, 2, 3)
|
|
1647
|
+
Traceback (most recent call last):
|
|
1648
|
+
...
|
|
1649
|
+
RuntimeError: error in Singular function call 'factorize':
|
|
1650
|
+
Wrong number of arguments (got 4 arguments, arity is CMD_12)
|
|
1651
|
+
|
|
1652
|
+
The Singular function ``list`` can be called with any number of
|
|
1653
|
+
arguments::
|
|
1654
|
+
|
|
1655
|
+
sage: singular_list = singular_function("list")
|
|
1656
|
+
sage: singular_list(2, 3, 6)
|
|
1657
|
+
[2, 3, 6]
|
|
1658
|
+
sage: singular_list()
|
|
1659
|
+
[]
|
|
1660
|
+
sage: singular_list(1)
|
|
1661
|
+
[1]
|
|
1662
|
+
sage: singular_list(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
|
|
1663
|
+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
1664
|
+
|
|
1665
|
+
We try to define a non-existing function::
|
|
1666
|
+
|
|
1667
|
+
sage: number_foobar = singular_function('number_foobar')
|
|
1668
|
+
Traceback (most recent call last):
|
|
1669
|
+
...
|
|
1670
|
+
NameError: Singular library function 'number_foobar' is not defined
|
|
1671
|
+
|
|
1672
|
+
::
|
|
1673
|
+
|
|
1674
|
+
sage: from sage.libs.singular.function import lib as singular_lib
|
|
1675
|
+
sage: singular_lib('general.lib')
|
|
1676
|
+
sage: number_e = singular_function('number_e')
|
|
1677
|
+
sage: number_e(10r)
|
|
1678
|
+
67957045707/25000000000
|
|
1679
|
+
sage: RR(number_e(10r))
|
|
1680
|
+
2.71828182828000
|
|
1681
|
+
|
|
1682
|
+
::
|
|
1683
|
+
|
|
1684
|
+
sage: singular_lib('primdec.lib')
|
|
1685
|
+
sage: primdecGTZ = singular_function("primdecGTZ")
|
|
1686
|
+
sage: primdecGTZ(I)
|
|
1687
|
+
[[[y - 8/3*z - 4/3, x + 1/4], [y - 8/3*z - 4/3, x + 1/4]]]
|
|
1688
|
+
sage: singular_list((1,2,3),3,[1,2,3], ring=P)
|
|
1689
|
+
[(1, 2, 3), 3, [1, 2, 3]]
|
|
1690
|
+
sage: ringlist=singular_function("ringlist")
|
|
1691
|
+
sage: l = ringlist(P)
|
|
1692
|
+
sage: l[3].__class__
|
|
1693
|
+
<class 'sage.rings.polynomial.multi_polynomial_sequence.PolynomialSequence_generic'>
|
|
1694
|
+
sage: l
|
|
1695
|
+
[0, ['x', 'y', 'z'], [['dp', (1, 1, 1)], ['C', (0,)]], [0]]
|
|
1696
|
+
sage: ring=singular_function("ring")
|
|
1697
|
+
sage: ring(l)
|
|
1698
|
+
<RingWrap>
|
|
1699
|
+
sage: matrix = Matrix(P,2,2)
|
|
1700
|
+
sage: matrix.randomize(terms=1)
|
|
1701
|
+
sage: det = singular_function("det")
|
|
1702
|
+
sage: det(matrix) == matrix[0, 0] * matrix[1, 1] - matrix[0, 1] * matrix[1, 0]
|
|
1703
|
+
True
|
|
1704
|
+
sage: coeffs = singular_function("coeffs")
|
|
1705
|
+
sage: coeffs(x*y+y+1,y)
|
|
1706
|
+
[ 1]
|
|
1707
|
+
[x + 1]
|
|
1708
|
+
sage: intmat = Matrix(ZZ, 2,2, [100,2,3,4])
|
|
1709
|
+
sage: det(intmat)
|
|
1710
|
+
394
|
|
1711
|
+
sage: random = singular_function("random")
|
|
1712
|
+
sage: A = random(10,2,3); A.nrows(), max(A.list()) <= 10
|
|
1713
|
+
(2, True)
|
|
1714
|
+
sage: P.<x,y,z> = PolynomialRing(QQ)
|
|
1715
|
+
sage: M=P**3
|
|
1716
|
+
sage: leadcoef = singular_function("leadcoef")
|
|
1717
|
+
sage: v=M((100*x,5*y,10*z*x*y))
|
|
1718
|
+
sage: leadcoef(v)
|
|
1719
|
+
10
|
|
1720
|
+
sage: v = M([x+y,x*y+y**3,z])
|
|
1721
|
+
sage: lead = singular_function("lead")
|
|
1722
|
+
sage: lead(v)
|
|
1723
|
+
(0, y^3)
|
|
1724
|
+
sage: jet = singular_function("jet")
|
|
1725
|
+
sage: jet(v, 2)
|
|
1726
|
+
(x + y, x*y, z)
|
|
1727
|
+
sage: syz = singular_function("syz")
|
|
1728
|
+
sage: I = P.ideal([x+y,x*y-y, y*2,x**2+1])
|
|
1729
|
+
sage: M = syz(I)
|
|
1730
|
+
sage: M
|
|
1731
|
+
[(-2*y, 2, y + 1, 0), (0, -2, x - 1, 0), (x*y - y, -y + 1, 1, -y), (x^2 + 1, -x - 1, -1, -x)]
|
|
1732
|
+
sage: singular_lib("mprimdec.lib")
|
|
1733
|
+
sage: syz(M)
|
|
1734
|
+
[(-x - 1, y - 1, 2*x, -2*y)]
|
|
1735
|
+
sage: GTZmod = singular_function("GTZmod")
|
|
1736
|
+
sage: GTZmod(M)
|
|
1737
|
+
[[[(-2*y, 2, y + 1, 0), (0, x + 1, 1, -y), (0, -2, x - 1, 0), (x*y - y, -y + 1, 1, -y), (x^2 + 1, 0, 0, -x - y)], [0]]]
|
|
1738
|
+
sage: mres = singular_function("mres")
|
|
1739
|
+
sage: resolution = mres(M, 0)
|
|
1740
|
+
sage: resolution
|
|
1741
|
+
<Resolution>
|
|
1742
|
+
sage: singular_list(resolution)
|
|
1743
|
+
[[(-2*y, 2, y + 1, 0), (0, -2, x - 1, 0), (x*y - y, -y + 1, 1, -y), (x^2 + 1, -x - 1, -1, -x)], [(-x - 1, y - 1, 2*x, -2*y)], [(0)]]
|
|
1744
|
+
|
|
1745
|
+
sage: # needs sage.combinat
|
|
1746
|
+
sage: A.<x,y> = FreeAlgebra(QQ, 2)
|
|
1747
|
+
sage: P.<x,y> = A.g_algebra({y*x:-x*y})
|
|
1748
|
+
sage: I= Sequence([x*y,x+y], check=False, immutable=True)
|
|
1749
|
+
sage: twostd = singular_function("twostd")
|
|
1750
|
+
sage: twostd(I)
|
|
1751
|
+
[x + y, y^2]
|
|
1752
|
+
sage: M=syz(I)
|
|
1753
|
+
doctest...
|
|
1754
|
+
sage: M
|
|
1755
|
+
[(x + y, x*y)]
|
|
1756
|
+
sage: syz(M)
|
|
1757
|
+
[(0)]
|
|
1758
|
+
sage: mres(I, 0)
|
|
1759
|
+
<Resolution>
|
|
1760
|
+
sage: M=P**3
|
|
1761
|
+
sage: v=M((100*x,5*y,10*y*x*y))
|
|
1762
|
+
sage: leadcoef(v)
|
|
1763
|
+
-10
|
|
1764
|
+
sage: v = M([x+y,x*y+y**3,x])
|
|
1765
|
+
sage: lead(v)
|
|
1766
|
+
(0, y^3)
|
|
1767
|
+
sage: jet(v, 2)
|
|
1768
|
+
(x + y, x*y, x)
|
|
1769
|
+
sage: l = ringlist(P)
|
|
1770
|
+
sage: len(l)
|
|
1771
|
+
6
|
|
1772
|
+
sage: ring(l)
|
|
1773
|
+
<noncommutative RingWrap>
|
|
1774
|
+
sage: I=twostd(I)
|
|
1775
|
+
sage: l[3]=I
|
|
1776
|
+
sage: ring(l)
|
|
1777
|
+
<noncommutative RingWrap>
|
|
1778
|
+
"""
|
|
1779
|
+
try:
|
|
1780
|
+
return SingularKernelFunction(name)
|
|
1781
|
+
except NameError:
|
|
1782
|
+
return SingularLibraryFunction(name)
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
def lib(name):
|
|
1786
|
+
"""
|
|
1787
|
+
Load the Singular library ``name``.
|
|
1788
|
+
|
|
1789
|
+
INPUT:
|
|
1790
|
+
|
|
1791
|
+
- ``name`` -- a Singular library name
|
|
1792
|
+
|
|
1793
|
+
EXAMPLES::
|
|
1794
|
+
|
|
1795
|
+
sage: from sage.libs.singular.function import singular_function
|
|
1796
|
+
sage: from sage.libs.singular.function import lib as singular_lib
|
|
1797
|
+
sage: singular_lib('general.lib')
|
|
1798
|
+
sage: primes = singular_function('primes')
|
|
1799
|
+
sage: primes(2,10, ring=GF(127)['x,y,z'])
|
|
1800
|
+
(2, 3, 5, 7)
|
|
1801
|
+
"""
|
|
1802
|
+
global si_opt_2
|
|
1803
|
+
|
|
1804
|
+
cdef int vv = si_opt_2
|
|
1805
|
+
|
|
1806
|
+
if get_verbose() <= 0:
|
|
1807
|
+
si_opt_2 &= ~Sy_bit(V_LOAD_LIB)
|
|
1808
|
+
si_opt_2 &= ~Sy_bit(V_REDEFINE)
|
|
1809
|
+
|
|
1810
|
+
cdef char* cname = omStrDup(str_to_bytes(name))
|
|
1811
|
+
sig_on()
|
|
1812
|
+
cdef bint failure = iiLibCmd(cname, 1, 1, 1)
|
|
1813
|
+
sig_off()
|
|
1814
|
+
si_opt_2 = vv
|
|
1815
|
+
|
|
1816
|
+
if failure:
|
|
1817
|
+
raise NameError("Singular library {!r} not found".format(name))
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
def get_printlevel():
|
|
1821
|
+
"""
|
|
1822
|
+
Return the value of the variable ``printlevel``.
|
|
1823
|
+
|
|
1824
|
+
This is useful to switch off and back the comments.
|
|
1825
|
+
|
|
1826
|
+
EXAMPLES::
|
|
1827
|
+
|
|
1828
|
+
sage: from sage.libs.singular.function import get_printlevel, set_printlevel
|
|
1829
|
+
sage: l = get_printlevel()
|
|
1830
|
+
sage: set_printlevel(-1)
|
|
1831
|
+
sage: get_printlevel()
|
|
1832
|
+
-1
|
|
1833
|
+
sage: set_printlevel(l)
|
|
1834
|
+
"""
|
|
1835
|
+
global printlevel
|
|
1836
|
+
cdef int pl = printlevel
|
|
1837
|
+
return pl
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
def set_printlevel(l):
|
|
1841
|
+
"""
|
|
1842
|
+
Set the value of the variable ``printlevel``.
|
|
1843
|
+
|
|
1844
|
+
This is useful to switch off and back the comments.
|
|
1845
|
+
|
|
1846
|
+
EXAMPLES::
|
|
1847
|
+
|
|
1848
|
+
sage: from sage.libs.singular.function import get_printlevel, set_printlevel
|
|
1849
|
+
sage: l = get_printlevel()
|
|
1850
|
+
sage: set_printlevel(2)
|
|
1851
|
+
sage: get_printlevel()
|
|
1852
|
+
2
|
|
1853
|
+
sage: set_printlevel(l)
|
|
1854
|
+
"""
|
|
1855
|
+
global printlevel
|
|
1856
|
+
printlevel = <int>l
|
|
1857
|
+
|
|
1858
|
+
|
|
1859
|
+
def list_of_functions(packages=False):
|
|
1860
|
+
"""
|
|
1861
|
+
Return a list of all function names currently available.
|
|
1862
|
+
|
|
1863
|
+
INPUT:
|
|
1864
|
+
|
|
1865
|
+
- ``packages`` -- include local functions in packages
|
|
1866
|
+
|
|
1867
|
+
EXAMPLES::
|
|
1868
|
+
|
|
1869
|
+
sage: from sage.libs.singular.function import list_of_functions
|
|
1870
|
+
sage: 'groebner' in list_of_functions()
|
|
1871
|
+
True
|
|
1872
|
+
"""
|
|
1873
|
+
cdef list l = []
|
|
1874
|
+
cdef idhdl *h=IDROOT
|
|
1875
|
+
cdef idhdl *ph = NULL
|
|
1876
|
+
while h!=NULL:
|
|
1877
|
+
if PROC_CMD == IDTYP(h):
|
|
1878
|
+
l.append(char_to_str(h.id))
|
|
1879
|
+
if PACKAGE_CMD == IDTYP(h):
|
|
1880
|
+
if packages:
|
|
1881
|
+
ph = IDPACKAGE(h).idroot
|
|
1882
|
+
while ph != NULL:
|
|
1883
|
+
if PROC_CMD == IDTYP(ph):
|
|
1884
|
+
l.append(char_to_str(ph.id))
|
|
1885
|
+
ph = IDNEXT(ph)
|
|
1886
|
+
h = IDNEXT(h)
|
|
1887
|
+
return l
|
|
1888
|
+
|
|
1889
|
+
|
|
1890
|
+
cdef inline RingWrap new_RingWrap(ring* r):
|
|
1891
|
+
cdef RingWrap ring_wrap_result = RingWrap.__new__(RingWrap)
|
|
1892
|
+
ring_wrap_result._ring = r
|
|
1893
|
+
ring_wrap_result._ring.ref += 1
|
|
1894
|
+
|
|
1895
|
+
return ring_wrap_result
|
|
1896
|
+
|
|
1897
|
+
# Add support for _instancedoc_
|
|
1898
|
+
from sage.misc.instancedoc import instancedoc
|
|
1899
|
+
instancedoc(SingularFunction)
|
|
1900
|
+
instancedoc(SingularLibraryFunction)
|
|
1901
|
+
instancedoc(SingularKernelFunction)
|