예제 #1
0
def test_create_psi():

    x = psi(x=sg.vector(sg.ZZ, [5, 6, 7]), k=10, prec=20)
    assert 1.2247830486256163744e-7 == pytest.approx(x, 1e-10)

    x = psi(x=sg.vector(sg.ZZ, [5, 6, 7]), k=300, prec=20)
    assert x == sg.Rational(0)

    x = psi(x=[], k=200, prec=20)
    assert x == sg.Rational(0)
예제 #2
0
def Psi_matrix(matrix, digits, cutoff=30, extrapolation = 100, prec=None):
    # create explicitly the sets S for up to d digits.
    S = create_S(matrix.values, digits=digits)

    Psi = {k: S.applymap(partial(psi, k=k, prec=prec)) for k in range(1, cutoff)}

    # append zero rows...
    for k in Psi.keys():
        Psi[k] = Psi[k].append(pd.DataFrame(columns=Psi[k].columns, data=sg.Rational(0),
                                            index=list(range(digits, extrapolation)))).values

    limit = 10 ** (prec * (-1))

    # digits!!!
    for i in range(digits, extrapolation):
        for k in Psi.keys():
            if Psi[k][i - 1, 0] > 0:
                for index, www in np.ndenumerate(matrix):
                    if www > 0:
                        for w in range(extrapolation - k):
                            p = Psi[k+w][i-1,index[0]]
                            if p > limit:
                                a = a_coeff(k, w, index[1], prec=prec, base=matrix.shape[1])
                                Psi[k][i, www-1] += a * p
                            else:
                                if k+w==2:
                                    print("********************************")
                                    print(limit, i, p)
                                    print("********************************")

                                break

    return Psi
예제 #3
0
def psi(x, k, prec):
    if len(x) == 0 or (x[0]**k) > 10**prec:
        return sg.Rational(0.0)

    x_power = x.apply_map(lambda y: y**k)
    return sg.sum(
        x_power.apply_map(lambda y: sg.numerical_approx(1 / y, digits=prec)))
예제 #4
0
def a_coeff(k, w, m, prec=None, base=10):
    #print(k,w,m)
    if m + w == 0:
        mw = sg.Rational(1)
    else:
        mw = __power(m, w)

    y = __power(1.0 / base, k + w) * mw * __power(-1, w) * __binomial(
        k + w - 1, w)

    if prec:
        y = sg.numerical_approx(y, digits=prec)

    return y
예제 #5
0
def experiment():
    rank = 5
    level = 4
    num_points = 11

    client = cbc.CBClient()
    liealg = cbd.TypeALieAlgebra(rank, store_fusion=True, exact=True)
    rays = []
    wts = []
    ranks = []
    for wt in liealg.get_weights(level):
        if wt == tuple([0 for x in range(0, rank)]):
            continue
        cbb = cbd.SymmetricConformalBlocksBundle(client, liealg, wt,
                                                 num_points, level)
        if cbb.get_rank() == 0:
            continue
        divisor = cbb.get_symmetrized_divisor()
        if divisor == [
                sage.Rational(0) for x in range(0, num_points // 2 - 1)
        ]:
            continue
        rays = rays + [divisor]
        wts = wts + [wt]
        ranks = ranks + [cbb.get_rank()]
        #print(wt, cbb.get_rank(), divisor)

    p = Polyhedron(rays=rays, base_ring=RationalField(), backend="cdd")
    extremal_rays = [list(v.vector()) for v in p.Vrepresentation()]
    c = Cone(p)
    print("Extremal rays:")
    for i in range(0, len(rays)):
        ray = rays[i]
        wt = wts[i]
        rk = ranks[i]
        if ray in extremal_rays:
            print(rk, wt, ray)
예제 #6
0
 def Fraction(x, y):
     try:
         return sage.Rational((x, y))
     except TypeError:
         return x / y
예제 #7
0
def __power(a, b):
    return sg.Rational(a)**b