NDSpline

class ndsplines.NDSpline(knots, coefficients, degrees, periodic=False, extrapolate=True)

Multivariate tensor-product spline in the B-spline basis. A general N dimensional tensor product B-spline is given by

\[S(x_1, ..., x_N) = \sum_{i_1=0}^{n_1-1} \cdots \sum_{i_N=0}^{n_N-1} c_{i_1, ..., i_N} \prod_{j = i}^{N} B_{i_j;k_j,t_j}(x_j)\]

where \(B_{i_j;k_j,t_j}\) is the \(i_j\)-th B-spline basis function of degree \(k_j\) over the knots \({t_j}\) with coefficients \(c_{i_1, ..., i_N}\)

Parameters:
  • knots (list of ndarrays, shapes=[n_0+degrees[i]+1, .., n_ndim+degrees[-1]+1], dtype=np.float_) – List of knots in each dimension, \([t_1, t_2, \ldots, t_N]\).
  • coefficients (ndarray, shape=(n_1, n_2, .., n_xdim) + yshape, dtype=np.float_) – N-D array of coefficients, \(c_{i_1, ..., i_N}\).
  • degrees (ndarray, shape=(xdim,), dtype=np.int_) – Array of the degree of each dimension, \([k_1, k_2, \ldots, k_N]\).
  • periodic (ndarray, shape=(xdim,), dtype=np.bool_) – Array of periodicity flags for each dimension.
  • extrapolate (ndarray, shape=(xdim,2), dtype=np.bool_) – Array of extrapolation flags for each side in each dimension.
knots

List of knots in each dimension, \([t_1, t_2, \ldots, t_N]\).

Type:list of ndarrays, shapes=[n_0+degrees[i]+1, .., n_ndim+degrees[-1]+1], dtype=np.float_
xdim

Dimension of spline input space.

Type:int
coefficients

N-D array of coefficients, \(c_{i_1, ..., i_N}\).

Type:ndarray, shape=(n_1, n_2, .., n_xdim, ydim), dtype=np.float_
ydim

Dimension of spline output space.

Type:int
yshape

Shape of spline output.

Type:tuple of ints

Methods

allocate_workspace_arrays(num_points) Allocate workspace arrays for the N-dimensional B-spline evaluation.
compute_basis_coefficient_selector(x[, nus]) Evaluate the N-dimensional B-spline basis functions and coefficient selectors.
__call__(x[, nus]) Evaluate the N-dimensional B-spline.
derivative(dim[, nu]) Return NDSpline representing the nu-th derivative in the dim-th dimension.
antiderivative(dim[, nu]) Return NDSpline representing the nu-th antiderivative in the dim-th dimension.
to_file(file[, compress]) Save attributes of NDSpline object to binary file in NumPy .npz format so that the object can be re-created.
copy() Return a deep copy of this NDSpline object.
__eq__(other) Check equality with another spline.