示例#1
0
def selection(method='python', it=10000000):
    import lognormal
    import lognormal_cy

    mu = np.array([1.0, 2.0, 3.0], dtype=DTYPE)
    sigma = np.array([2.0, 2.0, 2.0], dtype=DTYPE)
    x = 0.1
    y = 3.0
    k = np.array([0.1, 0.2, 0.3], dtype=DTYPE)
    args = [mu, sigma]

    python_res = lognormal.selectionfunc(x, k, *args)

    cython_res = lognormal_cy.selectionfunc(x, k, args)

    assert python_res == cython_res, 'Values not match'

    if method == 'python':
        total = 0
        for i in range(it):
            tic = time.time()
            res = lognormal.selectionfunc(x, k, *args)
            toc = time.time()
            total += toc - tic
        aver_time = total / it * 1e6
        print('breakage function takes %5.2f \u03BCs.' % aver_time)

    elif method == 'cython':
        total = 0
        for i in range(it):
            tic = time.time()
            res = lognormal_cy.selectionfunc(x, k, args)
            toc = time.time()
            total += toc - tic
        aver_time = total / it * 1e6
        print('breakage function takes %5.2f \u03BCs.' % aver_time)
示例#2
0
def den_integrand(x, k, *args):
    return x**3 * selectionfunc(x, k, args)
示例#3
0
def selection_integrand(x, k, *args):
    return (particle_number(x, k, *args) - 1) * selectionfunc(x, k, args)
示例#4
0
def num_integrand(x, y, k, *args):
    return x**3 * selectionfunc(y, k, args) * breakagefunc(x, y, k, args)