interpax.PPoly

class interpax.PPoly(c: Num[Array, 'k m ...'] | Num[ndarray, 'k m ...'], x: Real[Array, 'm+1'] | Real[ndarray, 'm+1'], extrapolate: bool | str | None = None, axis: int = 0, check: bool = True)Source

Piecewise polynomial in terms of coefficients and breakpoints.

The polynomial between x[i] and x[i + 1] is written in the local power basis:

S = sum(c[m, i] * (xp - x[i])**(k-m) for m in range(k+1))

where k is the degree of the polynomial.

Parameters:
  • c (ndarray, shape (k, m, ...)) – Polynomial coefficients, order k and m intervals.

  • x (ndarray, shape (m+1,)) – Polynomial breakpoints. Must be sorted in either increasing or decreasing order.

  • extrapolate (bool or 'periodic', optional) – If bool, determines whether to extrapolate to out-of-bounds points based on first and last intervals, or to return NaNs. If ‘periodic’, periodic extrapolation is used. Default is True.

  • axis (int, optional) – Interpolation axis. Default is zero.

  • check (bool) – Whether to perform checks on the input. Should be False if used under JIT.

Notes

High-order polynomials in the power basis can be numerically unstable. Precision problems can start to appear for orders larger than 20-30.

Methods

__call__(x[, nu, extrapolate])

Evaluate the piecewise polynomial or its derivative.

antiderivative([nu])

Construct a new piecewise polynomial representing the antiderivative.

construct_fast(c, x[, extrapolate, axis])

Construct the piecewise polynomial without making checks.

derivative([nu])

Construct a new piecewise polynomial representing the derivative.

extend(c, x[, right])

Not currently implemented.

from_bernstein_basis(bp[, extrapolate])

Not currently implemented.

from_spline(tck[, extrapolate])

Not currently implemented.

integrate(a, b[, extrapolate])

Compute a definite integral over a piecewise polynomial.

roots([discontinuity, extrapolate])

Not currently implemented.

solve([y, discontinuity, extrapolate])

Not currently implemented.

Attributes

axis

Axis along which to interpolate.

c

Array of spline coefficients, shape(order, knots-1, ...).

extrapolate

Whether to extrapolate beyond domain of known values.

x

Array of knot values, shape(knots).