scijit.interpolate.bispev

scijit.interpolate.bispev(x, y, tx, ty, c, kx, ky)

Evaluate a bivariate spline on a grid, FITPACK bispev.

The evaluator that backs bivariate spline evaluation on the full cross product of two axes.

Parameters:
x1-D array_like of float

Grid abscissae, ascending.

y1-D array_like of float

Grid ordinates, ascending. The spline is evaluated on the full CROSS PRODUCT x x y – use bispeu for scattered points.

tx1-D array_like of float

Knots in x, length nx.

ty1-D array_like of float

Knots in y, length ny.

c1-D array_like of float, length (nx-kx-1)*(ny-ky-1)

Coefficients in FITPACK’s flat layout c[(ny-ky-1)*i + j], equal to np.outer(cx, cy).ravel().

kxint

Degree in x, 1 <= kx <= 5.

kyint

Degree in y, 1 <= ky <= 5.

Returns:
z(len(x), len(y)) float64 ndarray

Spline values on the grid.

Raises:
ValueError

If tx, ty, c, x or y has a rank other than 1, or len(c) != (nx-kx-1)*(ny-ky-1). The coefficient test is an equality, so a c padded to nx*ny is rejected as well as a short one. Tested in that order.

Notes

scipy.interpolate publishes no name for this routine. It reaches the same computation only through bisplev(x, y, tck) and RectBivariateSpline.__call__.

Workspace: lwrk = mx*(kx+1) + my*(ky+1), kwrk = mx + my; the integer workspace must be int32.

Points outside the knot range are extrapolated. There is no e/ext flag on this routine, unlike splev.

prange-safe: yes.

Examples

Evaluate a bilinear spline for f(x, y) = x + 2*y at the grid centre, from inside @njit:

>>> import numpy as np
>>> from numba import njit
>>> from scijit.interpolate import bispev
>>> @njit
... def go():
...     tx = np.array([0., 0., 1., 1.])
...     ty = np.array([0., 0., 1., 1.])
...     c = np.array([0., 2., 1., 3.])  # corner values of x + 2*y
...     return bispev(np.array([0.5]), np.array([0.5]), tx, ty, c, 1, 1)
>>> go()
array([[1.5]])