def splint(xa, ya, y2a, n, x, y):
    """
/*      CALCULATE CUBIC SPLINE INTERP VALUE
 *       ADAPTED FROM NUMERICAL RECIPES BY PRESS ET AL.
 *       XA,YA: ARRAYS OF TABULATED FUNCTION IN ASCENDING ORDER BY X
 *       Y2A: ARRAY OF SECOND DERIVATIVES
 *       N: SIZE OF ARRAYS XA,YA,Y2A
 *       X: ABSCISSA FOR INTERPOLATION
 *       Y: OUTPUT VALUE
 */
 """
    klo = 0
    khi = n - 1
    while khi - klo > 1:
        k = int((khi + klo) / 2)
        if xa[k] > x:
            khi = k
        else:
            klo = k
    h = xa[khi] - xa[klo]
    a = (xa[khi] - x) / h
    b = (x - xa[klo]) / h
    yi = a * ya[klo] + b * ya[khi] + ((a * a * a - a) * y2a[klo] + (b * b *
        b - b) * y2a[khi]) * h * h / 6.0
    y[0] = yi
    return
