Exemplo n.º 1
0
def mp_cyl(x):
    f = mp.mpf
    theta = f(THETA) * mp.pi / f(180)
    qr = x * f(RADIUS) * mp.sin(theta)
    qh = x * f(LENGTH) / f(2) * mp.cos(theta)
    be = f(2) * mp.j1(qr) / qr
    si = mp.sin(qh) / qh
    background = f(0)
    #background = f(1)/f(1000)
    volume = mp.pi * f(RADIUS)**f(2) * f(LENGTH)
    contrast = f(5)
    units = f(1) / f(10000)
    #return be
    #return si
    return units * (volume * contrast * be * si)**f(2) / volume + background
Exemplo n.º 2
0
        "return sas_JN(3, q);", "sas_JN",
        ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", "lib/sas_JN.c"]),
    shortname="J3",
)
add_function(
    name="JN(2, x)",
    mp_function=lambda x: mp.besselj(2, x),
    np_function=lambda x: scipy.special.jn(2, x),
    ocl_function=make_ocl(
        "return sas_JN(2, q);", "sas_JN",
        ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", "lib/sas_JN.c"]),
    shortname="J2",
)
add_function(
    name="2 J1(x)/x",
    mp_function=lambda x: 2 * mp.j1(x) / x,
    np_function=lambda x: 2 * scipy.special.j1(x) / x,
    ocl_function=make_ocl("return sas_2J1x_x(q);", "sas_2J1x_x",
                          ["lib/polevl.c", "lib/sas_J1.c"]),
)
add_function(
    name="J1(x)",
    mp_function=mp.j1,
    np_function=scipy.special.j1,
    ocl_function=make_ocl("return sas_J1(q);", "sas_J1",
                          ["lib/polevl.c", "lib/sas_J1.c"]),
)
add_function(
    name="Si(x)",
    mp_function=mp.si,
    np_function=lambda x: scipy.special.sici(x)[0],
Exemplo n.º 3
0
def _mp_fn(x):
    """
    Actual function that gets evaluated.  The caller just vectorizes.
    """
    return mp.mpf(2)*mp.j1(x)/x