Ejemplo n.º 1
0
def test_euclid():
    h = Polynomial(GF, [1, 1])
    f1 = Polynomial(GF, [1, 0, 2]) * h
    f2 = Polynomial(GF, [1, 3]) * h
    gcd, (s, t) = list(euclid(f1, f2))[-1]
    assert s*f1 + t*f2 == gcd

    zero = Polynomial(GF, [0])
    assert divmod_slow(f1, gcd)[1] == zero
    assert divmod_slow(f2, gcd)[1] == zero
Ejemplo n.º 2
0
def test_euclid():
    h = Polynomial(GF, [1, 1])
    f1 = Polynomial(GF, [1, 0, 2]) * h
    f2 = Polynomial(GF, [1, 3]) * h
    gcd, (s, t) = list(euclid(f1, f2))[-1]
    assert s * f1 + t * f2 == gcd

    zero = Polynomial(GF, [0])
    assert divmod_slow(f1, gcd)[1] == zero
    assert divmod_slow(f2, gcd)[1] == zero
Ejemplo n.º 3
0
def test_mod():
    p1 = Polynomial(GF, [8, 3, 5, 2, 4, 6, 9, 7, 1])
    p2 = Polynomial(GF, [10, 11, 12])
    assert divmod_slow(p1, p2)[1] == modulo(p1, p2)
Ejemplo n.º 4
0
def test_div():
    p1 = Polynomial(GF, [1, 0, 0, 2])
    p2 = Polynomial(GF, [1])
    assert divmod_slow(p1, p2) == (p1, Polynomial(GF, [0]))
Ejemplo n.º 5
0
def test_mod():
    p1 = Polynomial(GF, [8, 3, 5, 2, 4, 6, 9, 7, 1])
    p2 = Polynomial(GF, [10, 11, 12])
    assert divmod_slow(p1, p2)[1] == modulo(p1, p2)
Ejemplo n.º 6
0
def test_div():
    p1 = Polynomial(GF, [1, 0, 0, 2])
    p2 = Polynomial(GF, [1])
    assert divmod_slow(p1, p2) == (p1, Polynomial(GF, [0]))