コード例 #1
0
ファイル: test_galoistools.py プロジェクト: vperic/sympy
def test_gf_division():
    raises(ZeroDivisionError, lambda: gf_div([1,2,3], [], 11, ZZ))
    raises(ZeroDivisionError, lambda: gf_rem([1,2,3], [], 11, ZZ))
    raises(ZeroDivisionError, lambda: gf_quo([1,2,3], [], 11, ZZ))
    raises(ZeroDivisionError, lambda: gf_quo([1,2,3], [], 11, ZZ))

    assert gf_div([1], [1,2,3], 7, ZZ) == ([], [1])
    assert gf_rem([1], [1,2,3], 7, ZZ) == [1]
    assert gf_quo([1], [1,2,3], 7, ZZ) == []

    f, g, q, r = [5,4,3,2,1,0], [1,2,3], [5,1,0,6], [3,3]

    assert gf_div(f, g, 7, ZZ) == (q, r)
    assert gf_rem(f, g, 7, ZZ) == r
    assert gf_quo(f, g, 7, ZZ) == q

    raises(ExactQuotientFailed, lambda: gf_exquo(f, g, 7, ZZ))

    f, g, q, r = [5,4,3,2,1,0], [1,2,3,0], [5,1,0], [6,1,0]

    assert gf_div(f, g, 7, ZZ) == (q, r)
    assert gf_rem(f, g, 7, ZZ) == r
    assert gf_quo(f, g, 7, ZZ) == q

    raises(ExactQuotientFailed, lambda: gf_exquo(f, g, 7, ZZ))

    assert gf_quo([1,2,1], [1,1], 11, ZZ) == [1,1]