def create_spline(y, yp, x, h):
 from scipy.interpolate import PPoly
 (n, m) = y.shape
 c = np.empty((4, n, (m - 1)), dtype=y.dtype)
 slope = ((y[:, 1:] - y[:, :(-1)]) / h)
 t = (((yp[:, :(-1)] + yp[:, 1:]) - (2 * slope)) / h)
 c[0] = (t / h)
 c[1] = (((slope - yp[:, :(-1)]) / h) - t)
 c[2] = yp[:, :(-1)]
 c[3] = y[:, :(-1)]
 c = np.rollaxis(c, 1)
 return PPoly(c, x, extrapolate=True, axis=1)

def create_spline ( y , yp , x , h ) : from scipy . interpolate import PPoly ( n , m ) = y . shape c = np . empty ( ( 4 , n , ( m - 1 ) ) , dtype = y . dtype ) slope = ( ( y [ : , 1 : ] - y [ : , : ( - 1 ) ] ) / h ) t = ( ( ( yp [ : , : ( - 1 ) ] + yp [ : , 1 : ] ) - ( 2 * slope ) ) / h ) c [ 0 ] = ( t / h ) c [ 1 ] = ( ( ( slope - yp [ : , : ( - 1 ) ] ) / h ) - t ) c [ 2 ] = yp [ : , : ( - 1 ) ] c [ 3 ] = y [ : , : ( - 1 ) ] c = np . rollaxis ( c , 1 ) return PPoly ( c , x , extrapolate = True , axis = 1 )
create a cubic spline given values and derivatives .