예제 #1
0
def test_element():
    from pyeantic import eantic
    from sage.all import ZZ, QQ
    K = eantic.renf('x^2 - 2', 'x', '[1.4142 +/- 0.0001]')

    assert str(eantic.renf_elem(K, [ZZ(2), ZZ(3)])) == "(3*x+2 ~ 6.2426407)"
    assert str(eantic.renf_elem(K, [1/ZZ(2), 1/ZZ(3)])) == "(1/3*x+1/2 ~ 0.97140452)"
예제 #2
0
def test_eantic():
    from pyeantic import eantic
    L = eantic.renf("a^3 - a^2 - a - 1", "a", "[1.84 +/- 0.01]")
    lengths = []
    lengths.append(eantic.renf_elem(L, "a"))
    lengths.append(eantic.renf_elem(L, "2*a^2 - 3"))
    iet = IntervalExchangeTransformation(lengths, [1, 0])
    iet_10_check(iet)
예제 #3
0
def test_construct():
    K = eantic.renf("A^3 - 3", "A", "1.44 +/- 0.1")
    zero = K.zero()
    one = K.one()
    A = K.gen()
    assert eantic.renf_elem(K) == zero
    assert eantic.renf_elem(K, "A") == A
    assert eantic.renf_elem(K, "A - 3") == A - 3
    assert eantic.renf_elem(K, "1") == one
    assert eantic.renf_elem(A) == A
    assert eantic.renf_elem(K, 1) == one
    assert eantic.renf_elem(K, [0, 0, 0]) == zero
    assert eantic.renf_elem(K, [1, 0, 0]) == one
    assert eantic.renf_elem(K, [0, 1, 0]) == A
예제 #4
0
def lengths(coefficients, permutation):
    r"""
    Produces lengths for the given permutation in a ring represented by coefficients.
    """
    if len(permutation) == 2:
        lengths = [18, 3]
    elif len(permutation) == 7:
        lengths = [4, 56, 23, 11, 21, 9, 65]
    else:
        lengths = [1] * len(permutation)

    if coefficients == "mpz":
        from gmpxxyy import mpz
        return [mpz(l) for l in lengths]
    elif coefficients == "mpq":
        from gmpxxyy import mpq
        return [mpq(l) for l in lengths]
    elif coefficients == "renf_elem":
        from pyeantic import eantic
        L = eantic.renf("a^3 - a^2 - a - 1", "a", "[1.84 +/- 0.01]")
        return [eantic.renf_elem(L, l) for l in lengths]
    else:
        raise NotImplementedError(
            f"Cannot create lengths for {coefficients} yet.")
예제 #5
0
def test_construct_no_parent():
    assert eantic.renf_elem(1) == 1