コード例 #1
0
def test_zzX_values():
    assert zzX_zero(0) == 0
    assert zzX_zero(1) == []
    assert zzX_zero(3) == [[[]]]
    assert zzX_const(1, 7) == [7]
    assert zzX_const(3, 7) == [[[7]]]

    assert zzX_const(0, 3) == 3
    assert zzX_const(3, 0) == [[[]]]

    assert zzX_zero_of(f_0, 1) == [[]]
    assert zzX_zero_of(f_6, 1) == [[[]]]
    assert zzX_const_of(f_0, 7, 1) == [[7]]
    assert zzX_const_of(f_6, 7, 1) == [[[7]]]

    assert zzX_value(3, 1) == [[[1]]]

    assert zzX_value(0, [[1]]) == [[1]]
    assert zzX_value(1, [[1]]) == [[[1]]]
    assert zzX_value(2, [[1]]) == [[[[1]]]]

    assert zzX_zeros_of([1,2,3], 4) == [0,0,0,0]

    assert zzX_zeros_of(f_0, 0, 0) == []
    assert zzX_zeros_of(f_0, 2, 0) == [[[[]]], [[[]]]]
    assert zzX_zeros_of(f_0, 3, 1) == [[[]],[[]],[[]]]

    assert zzX_consts_of([1,2,3], 7, 4) == [7,7,7,7]

    assert zzX_consts_of(f_0, 7, 0, 0) == []
    assert zzX_consts_of(f_0, 7, 2, 0) == [[[[7]]], [[[7]]]]
    assert zzX_consts_of(f_0, 7, 3, 1) == [[[7]],[[7]],[[7]]]

    assert zzX_lift(2, []) == [[[]]]
    assert zzX_lift(2, [[1,2,3], [], [2,3]]) == \
        [[[[1]],[[2]],[[3]]], [[[]]], [[[2]],[[3]]]]

    assert zzX_zero_p([]) == True
    assert zzX_zero_p([[]]) == True
    assert zzX_zero_p([[[]]]) == True
    assert zzX_zero_p([[[1]]]) == False

    assert zzX_one_p([1]) == True
    assert zzX_one_p([[1]]) == True
    assert zzX_one_p([[[1]]]) == True
    assert zzX_one_p([[[12]]]) == False
コード例 #2
0
def test_zzX_values():
    assert zzX_zero(0) == 0
    assert zzX_zero(1) == []
    assert zzX_zero(3) == [[[]]]
    assert zzX_const(1, 7) == [7]
    assert zzX_const(3, 7) == [[[7]]]

    assert zzX_const(0, 3) == 3
    assert zzX_const(3, 0) == [[[]]]

    assert zzX_zero_of(f_0, 1) == [[]]
    assert zzX_zero_of(f_6, 1) == [[[]]]
    assert zzX_const_of(f_0, 7, 1) == [[7]]
    assert zzX_const_of(f_6, 7, 1) == [[[7]]]

    assert zzX_value(3, 1) == [[[1]]]

    assert zzX_value(0, [[1]]) == [[1]]
    assert zzX_value(1, [[1]]) == [[[1]]]
    assert zzX_value(2, [[1]]) == [[[[1]]]]

    assert zzX_zeros_of([1, 2, 3], 4) == [0, 0, 0, 0]

    assert zzX_zeros_of(f_0, 0, 0) == []
    assert zzX_zeros_of(f_0, 2, 0) == [[[[]]], [[[]]]]
    assert zzX_zeros_of(f_0, 3, 1) == [[[]], [[]], [[]]]

    assert zzX_consts_of([1, 2, 3], 7, 4) == [7, 7, 7, 7]

    assert zzX_consts_of(f_0, 7, 0, 0) == []
    assert zzX_consts_of(f_0, 7, 2, 0) == [[[[7]]], [[[7]]]]
    assert zzX_consts_of(f_0, 7, 3, 1) == [[[7]], [[7]], [[7]]]

    assert zzX_lift(2, []) == [[[]]]
    assert zzX_lift(2, [[1,2,3], [], [2,3]]) == \
        [[[[1]],[[2]],[[3]]], [[[]]], [[[2]],[[3]]]]

    assert zzX_zero_p([]) == True
    assert zzX_zero_p([[]]) == True
    assert zzX_zero_p([[[]]]) == True
    assert zzX_zero_p([[[1]]]) == False

    assert zzX_one_p([1]) == True
    assert zzX_one_p([[1]]) == True
    assert zzX_one_p([[[1]]]) == True
    assert zzX_one_p([[[12]]]) == False
コード例 #3
0
def zzX_fateman_poly_F_1(n):
    """Fateman's GCD benchmark: trivial GCD """
    u = [1, 0]

    for i in xrange(1, n+1):
        u = [zzX_const(i, 1), u]

    v = [1, 0, 0]

    for i in xrange(1, n+1):
        v = [zzX_const(i, 1), zzX_zero(i), v]

    U = zzX_add_term(u, zzX_const(n, 1))
    V = zzX_add_term(u, zzX_const(n, 2))

    W = zzX_add_term(v, zzX_const(n, 1))
    Y = zzX_lift(n-1, [[-3, 0], [], [1, 0, -1]])

    F = zzX_mul(U, V)
    G = zzX_mul(W, Y)

    H = zzX_const(n+1, 1)

    return F, G, H
コード例 #4
0
def zzX_fateman_poly_F_1(n):
    """Fateman's GCD benchmark: trivial GCD """
    u = [1, 0]

    for i in xrange(1, n + 1):
        u = [zzX_const(i, 1), u]

    v = [1, 0, 0]

    for i in xrange(1, n + 1):
        v = [zzX_const(i, 1), zzX_zero(i), v]

    U = zzX_add_term(u, zzX_const(n, 1))
    V = zzX_add_term(u, zzX_const(n, 2))

    W = zzX_add_term(v, zzX_const(n, 1))
    Y = zzX_lift(n - 1, [[-3, 0], [], [1, 0, -1]])

    F = zzX_mul(U, V)
    G = zzX_mul(W, Y)

    H = zzX_const(n + 1, 1)

    return F, G, H