예제 #1
0
def test_dmp_div():
    f, g, q, r = [5,4,3,2,1], [1,2,3], [5,-6,0], [20,1]

    assert dmp_div(f, g, 0, ZZ) == (q, r)
    assert dmp_quo(f, g, 0, ZZ) == q
    assert dmp_rem(f, g, 0, ZZ) == r

    raises(ExactQuotientFailed, lambda: dmp_exquo(f, g, 0, ZZ))

    f, g, q, r = [[[1]]], [[[2]],[1]], [[[]]], [[[1]]]

    assert dmp_div(f, g, 2, ZZ) == (q, r)
    assert dmp_quo(f, g, 2, ZZ) == q
    assert dmp_rem(f, g, 2, ZZ) == r

    raises(ExactQuotientFailed, lambda: dmp_exquo(f, g, 2, ZZ))
예제 #2
0
def dmp_trunc(f, p, u, K):
    """
    Reduce ``K[X]`` polynomial modulo a polynomial ``p`` in ``K[Y]``.

    **Examples**

    >>> from sympy.polys.domains import ZZ
    >>> from sympy.polys.densetools import dmp_trunc

    >>> f = ZZ.map([[3, 8], [5, 6], [2, 3]])
    >>> g = ZZ.map([1, -1])

    >>> dmp_trunc(f, g, 1, ZZ)
    [[11], [11], [5]]

    """
    return dmp_strip([dmp_rem(c, p, u - 1, K) for c in f], u)
예제 #3
0
파일: densetools.py 프로젝트: Jerryy/sympy
def dmp_trunc(f, p, u, K):
    """
    Reduce ``K[X]`` polynomial modulo a polynomial ``p`` in ``K[Y]``.

    **Examples**

    >>> from sympy.polys.domains import ZZ
    >>> from sympy.polys.densetools import dmp_trunc

    >>> f = ZZ.map([[3, 8], [5, 6], [2, 3]])
    >>> g = ZZ.map([1, -1])

    >>> dmp_trunc(f, g, 1, ZZ)
    [[11], [11], [5]]

    """
    return dmp_strip([ dmp_rem(c, p, u-1, K) for c in f ], u)
예제 #4
0
파일: densetools.py 프로젝트: msgoff/sympy
def dmp_trunc(f, p, u, K):
    """
    Reduce a ``K[X]`` polynomial modulo a polynomial ``p`` in ``K[Y]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x,y = ring("x,y", ZZ)

    >>> f = 3*x**2*y + 8*x**2 + 5*x*y + 6*x + 2*y + 3
    >>> g = (y - 1).drop(x)

    >>> R.dmp_trunc(f, g)
    11*x**2 + 11*x + 5

    """
    return dmp_strip([dmp_rem(c, p, u - 1, K) for c in f], u)
예제 #5
0
def dmp_trunc(f, p, u, K):
    """
    Reduce a ``K[X]`` polynomial modulo a polynomial ``p`` in ``K[Y]``.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x,y = ring("x,y", ZZ)

    >>> f = 3*x**2*y + 8*x**2 + 5*x*y + 6*x + 2*y + 3
    >>> g = (y - 1).drop(x)

    >>> R.dmp_trunc(f, g)
    11*x**2 + 11*x + 5

    """
    return dmp_strip([ dmp_rem(c, p, u - 1, K) for c in f ], u)
예제 #6
0
파일: polyclasses.py 프로젝트: fxkr/sympy
 def rem(f, g):
     """Computes polynomial remainder of `f` and `g`. """
     lev, dom, per, F, G = f.unify(g)
     return per(dmp_rem(F, G, lev, dom))
예제 #7
0
 def rem(f, g):
     """Computes polynomial remainder of `f` and `g`. """
     lev, dom, per, F, G = f.unify(g)
     return per(dmp_rem(F, G, lev, dom))