Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/sage/rings/polynomial/multi_polynomial.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,10 @@ cdef class MPolynomial(CommutativePolynomial):
Given an ideal `I = (f_1,\dots,f_r)` that contains ``self``,
find `s_1,\dots,s_r` such that ``self`` `= s_1 f_1 + ... + s_r f_r`.

INPUT:

- ``I`` -- an ideal in ``self.parent()``, or tuple of generators of that ideal

EXAMPLES::

sage: # needs sage.rings.real_mpfr
Expand Down Expand Up @@ -2891,6 +2895,45 @@ cdef class MPolynomial(CommutativePolynomial):

return result(True)

def crt(self, y, m, n):
"""
Return a polynomial congruent to ``self`` modulo ``m`` and
to ``y`` modulo ``n``.

INPUT:

- ``y`` -- a polynomial in the same ring as ``self``
- ``m``, ``n`` -- polynomials or ideals in the same ring as ``self``. Ideals
may also be specified as a list/tuple of generators.

EXAMPLES::

sage: R.<x> = PolynomialRing(QQ, implementation="singular")
sage: f = R(3)
sage: g = f.crt(5, x-1, x-2); g # random (up to addition by multiples of (x-1)*(x-2))
2*x + 1
sage: g(1)
3
sage: g(2)
5
sage: g = f.crt(5, R.ideal(x-1), [x-2])
sage: g(1)
3
sage: g(2)
5
"""
# could be moved up to ModuleElement as long as lift() is defined
# the current definition of lift() requires ideal(), so maybe only RingElement
R = self._parent
y = R(y)
m = R.ideal(m).gens()
n = R.ideal(n).gens()
# result == self - sum a_i * m_i == y + sum b_i * n_i
# self - y == sum b_i * n_i + sum a_i * m_i
ab_values = (self - y).lift(m + n)
return R.sum([y] + [bi * ni for bi, ni in zip(ab_values[len(m):], n)])



def _is_M_convex_(points) -> bool:
r"""
Expand Down
4 changes: 4 additions & 0 deletions src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4546,7 +4546,7 @@
Traceback (most recent call last):
...
AlarmInterrupt
sage: alarm(0.5); h = (x^2^n-y^2^n).factor()

Check failure on line 4549 in src/sage/rings/polynomial/multi_polynomial_libsingular.pyx

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Timed out (and interrupt failed)

/home/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/cysignals/signals.cpython-312-x86_64-linux-gnu.so(+0x8ecc)[0x7fe660caaecc] /home/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/cysignals/signals.cpython-312-x86_64-linux-gnu.so(+0x8f99)[0x7fe660caaf99] /home/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/cysignals/signals.cpython-312-x86_64-linux-gnu.so(+0xb8e6)[0x7fe660cad8e6] /lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x7fe661445330] /lib/x86_64-linux-gnu/libc.so.6(__lll_lock_wait_private+0x2b)[0x7fe661498f0b] /lib/x86_64-linux-gnu/libc.so.6(malloc+0x2d0)[0x7fe6614ad920] python3(PyObject_Malloc+0x10c)[0x556c7b134d8c] python3(PyBytes_FromStringAndSize+0x75)[0x556c7b14afd5] python3(+0x2e1ff6)[0x556c7b229ff6] python3(+0x207a80)[0x556c7b14fa80] python3(+0x34d74c)[0x556c7b29574c] python3(+0x2e1a3f)[0x556c7b229a3f] python3(+0x2c60c0)[0x556c7b20e0c0] python3(PyObject_VectorcallMethod+0x88)[0x556c7b151698] python3(+0x310238)[0x556c7b258238] python3(+0x1165b6)[0x556c7b05e5b6] python3(_PyObject_FastCallDictTstate+0x292)[0x556c7b14f852] python3(_PyObject_Call_Prepend+0x69)[0x556c7b17aa99] python3(+0x3041cb)[0x556c7b24c1cb] python3(_PyObject_MakeTpCall+0x2c3)[0x556c7b14cc23] python3(+0x1127e4)[0x556c7b05a7e4] python3(_PyObject_FastCallDictTstate+0x1ee)[0x556c7b14f7ae] python3(+0x23267c)[0x556c7b17a67c] python3(_PyObject_MakeTpCall+0x274)[0x556c7b14cbd4] python3(+0x1127e4)[0x556c7b05a7e4] python3(PyEval_EvalCode+0xa1)[0x556c7b203341] python3(+0x2df9ba)[0x556c7b2279ba] python3(+0x2da9c5)[0x556c7b2229c5] python3(+0x2f32d0)[0x556c7b23b2d0] python3(_PyRun_SimpleFileObject+0x1ce)[0x556c7b23a94e] python3(_PyRun_AnyFileObject+0x44)[0x556c7b23a614] python3(Py_RunMain+0x2fe)[0x556c7b23389e] python3(Py_BytesMain+0x37)[0x556c7b1ed477] /lib/x86_64-linux-gnu/libc.so.6(+0x2a1ca)[0x7fe66142a1ca] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x8b)[0x7fe66142a28b] python3(+0x2a5321)[0x556c7b1ed321] ------------------------------------------------------------------------
Traceback (most recent call last):
...
AlarmInterrupt
Expand Down Expand Up @@ -4610,6 +4610,10 @@

A :exc:`ValueError` exception is raised if ``g (== self)`` does not belong to ``I``.

INPUT:

- ``I`` -- an ideal in ``self.parent()``, or tuple of generators of that ideal

EXAMPLES::

sage: A.<x,y> = PolynomialRing(QQ,2,order='degrevlex')
Expand Down
Loading