Beispiel #1
0
def eval_qspline(x, y, z):
    n = len(x)
    h = qspline(x, y)[0]
    p = qspline(x, y)[1]
    c = qspline(x, y)[2]
    b = qspline(x, y)[3]
    assert (n > 1 and z >= x[0] and z <= x[n - 1])
    m = half_int(n, x, z)  # Search
    dx = z - x[m]

    return (y[m] + b[m] * dx + c[m] * dx**2)
Beispiel #2
0
def deriv_qspline(x, y, z):
    n = len(x)
    h = qspline(x, y)[0]
    p = qspline(x, y)[1]
    c = qspline(x, y)[2]
    b = qspline(x, y)[3]
    assert (n > 1 and z >= x[0] and z <= x[n - 1])
    m = half_int(n, x, z)  # Search
    dx = z - x[m]

    return (b[m] + 2 * c[m] * dx)
Beispiel #3
0
def deriv_cspline(x, y, z):
    n = len(x)
    #h = cspline(x, y)[0]
    #p = cspline(x, y)[1]
    b = cspline(x, y)[2]
    c = cspline(x, y)[3]
    d = cspline(x, y)[4]
    assert (n > 1 and z >= x[0] and z <= x[n - 1])
    m = half_int(n, x, z)  # Search
    dx = z - x[m]

    return (b[m] + 2 * c[m] * dx + 3 * d[m] * dx**2)
Beispiel #4
0
def eval_cspline(x, y, z):
    n = len(x)
    #h = cspline(x, y)[0]
    #p = cspline(x, y)[1]
    b = cspline(x, y)[2]
    c = cspline(x, y)[3]
    d = cspline(x, y)[4]
    assert (n > 1 and z >= x[0] and z <= x[n - 1])
    m = half_int(n, x, z)  # Search
    dx = z - x[m]

    return (y[m] + b[m] * dx + c[m] * dx**2 + d[m] * dx**3)
Beispiel #5
0
def integ_linterp(n, x, y, z):
    integ = 0
    end_integ = search.half_int(n, x, z)

    for i in range(end_integ):
        dx = x[i + 1] - x[i]
        p = (y[i + 1] - y[i]) / dx
        integ = integ + y[i] * dx + 0.5 * p * dx**2

    dx = z - x[end_integ]
    p = (y[end_integ + 1] - y[end_integ]) / (x[end_integ + 1] - x[end_integ])
    integ = integ + y[end_integ] * dx + 0.5 * p * dx**2

    return integ
Beispiel #6
0
def integ_qspline(x, y, z):
    n = len(x)
    h = qspline(x, y)[0]
    p = qspline(x, y)[1]
    c = qspline(x, y)[2]
    b = qspline(x, y)[3]
    assert (n > 1 and z >= x[0] and z <= x[n - 1])
    m = half_int(n, x, z)  # Search

    integ_qspline = 0
    for l in range(m):
        dx = x[l + 1] - x[l]
        integ_qspline = integ_qspline + y[l] * dx + 0.5 * b[l] * dx**2 + (
            c[l] * dx**3) / 3.0

    dx = z - x[m]
    integ_qspline = integ_qspline + y[m] * dx + 0.5 * b[m] * dx**2 + (
        c[m] * dx**3) / 3.0

    return integ_qspline
Beispiel #7
0
def integ_cspline(x, y, z):
    n = len(x)
    #h = cspline(x, y)[0]
    #p = cspline(x, y)[1]
    b = cspline(x, y)[2]
    c = cspline(x, y)[3]
    d = cspline(x, y)[4]
    assert (n > 1 and z >= x[0] and z <= x[n - 1])
    m = half_int(n, x, z)  # Search

    integ_cspline = 0
    for l in range(m):
        dx = x[l + 1] - x[l]
        integ_cspline = integ_cspline + y[l] * dx + 0.5 * b[l] * dx**2 + (
            c[l] * dx**3) / 3.0 + (d[l] * dx**4) / 4.0

    dx = z - x[m]
    integ_cspline = integ_cspline + y[m] * dx + 0.5 * b[m] * dx**2 + (
        c[m] * dx**3) / 3.0 + (d[m] * dx**4) / 4.0

    return integ_cspline
Beispiel #8
0
def linterp(n, x, y, z):
    i = search.half_int(n, x, z)  #z is a point in the list x
    p = (y[i + 1] - y[i]) / (x[i + 1] - x[i])
    dx = z - x[i]
    res = y[i] + p * dx
    return res