Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 36 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 @@ -2899,6 +2903,37 @@ 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: f.crt(5, x-1, x-2) % ((x-1)*(x-2))
2*x + 1
sage: f.crt(5, R.ideal(x-1), [x-2]) % ((x-1)*(x-2))
2*x + 1
"""
# 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 canonical_associate(self):
"""
Return a canonical associate.
Expand All @@ -2916,6 +2951,7 @@ cdef class MPolynomial(CommutativePolynomial):
n, u = lc.canonical_associate()
return (u.inverse_of_unit() * self, u)


def _is_M_convex_(points) -> bool:
r"""
Return whether ``points`` represents a set of integer lattice points
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 @@ -4610,6 +4610,10 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):

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