1-D spline class

class cubicmultispline.Spline1D(interval, yv, boundary_condition_type=('not-a-knot', 'not-a-knot'), boundary_condition_value=(0.0, 0.0))

One-dimensional cubic spline interpolation using B-spline basis functions.

This class implements cubic spline interpolation with various boundary conditions. The spline is represented using B-spline basis functions and supports evaluation of the function value and its first three derivatives.

_interval

Tuple of (start, end) values for the interpolation domain

_boundary_condition_type

Tuple of boundary condition types for start and end

_boundary_condition_value

Tuple of boundary condition values for start and end

_coeff

Array of spline coefficients

_h

Step size between knots

_a

Start value of the interval

property coeff: ndarray

Get the spline coefficients.

Returns:

Array of spline coefficients of length n+3, where n is the number of intervals (len(yv) - 1)

Return type:

np.ndarray

eval_spline(x)

Evaluate the spline and its derivatives at given point(s).

Computes the spline value and its first three derivatives at the specified evaluation point(s). The evaluation is performed using a vectorized approach for efficiency.

Parameters:

x (float | ndarray) – Point(s) at which to evaluate the spline. Can be a single value or an array of values.

Return type:

Union[Tuple[float, float, float, float], Tuple[ndarray, ndarray, ndarray, ndarray]]

Returns:

  • Tuple containing four elements

  • - spline value(s)

  • - first derivative(s)

  • - second derivative(s)

  • - third derivative(s)

  • For single point input (returns (float, float, float, float))

  • For array input (returns (np.ndarray, np.ndarray, np.ndarray, np.ndarray))