scijit.interpolate.splantider

scijit.interpolate.splantider(t, c=None, k=None, n=1)

Spline representation of the n-th antiderivative of a spline.

Two argument spellings: splantider(t, c, k, n) passes the three components of the spline, splantider(tck, n) passes the (t, c, k) tuple.

Parameters:
t1-D float64 ndarray, tuple (t, c, k), or a BSpline

Knot vector of the input spline, the whole spline representation, or a spline object. A BSpline in gives a BSpline out. Under the tuple and object spellings k is not passed and the second positional argument is the antiderivative order.

cfloat64 ndarray, optional

B-spline coefficients; padded to len(t) internally, so both the FITPACK-padded and the bare form work, and any other length raises ValueError. A rank-2 c holds one column per curve. Under the tck and object spellings this slot carries n.

kint, optional

Degree of the input spline. Not passed under the tck spelling.

nint, optional

Antiderivative order. A NEGATIVE order gives the derivative of the opposite order, so splantider(tck, -1) is splder(tck, 1). There is no upper limit. Default 1.

Returns:
t21-D float64 ndarray, length len(t) + 2*n

Knot vector with the first and last knot repeated n more times.

c2float64 ndarray, first axis len(t2)

Coefficients of the antiderivative, carrying a rank-2 c’s columns.

k2int

Degree, k + n.

See also

scipy.interpolate.splantider

The scipy routine this mirrors.

Notes

  • Also exported under the name splantider.

  • scipy.interpolate.splantider is marked legacy in scipy’s own documentation, which points at BSpline.antiderivative for new code.

  • A BSpline argument returns a BSpline rather than the triple, as it does in scipy.

  • The integration constant is scipy’s: the antiderivative vanishes at the left edge of the knot vector.

  • The two spellings share one implementation, _splantider_core. See splder for how the first argument’s type selects between them, what a mixed call raises, and why a list reaches only the Python entry.

  • A c whose length is neither len(t) - k - 1 nor len(t) raises ValueError, where scipy validates nothing and reaches a numpy broadcast. Deliberate; see splder.

  • A c of rank 3 or more raises ValueError, where scipy carries any number of trailing dimensions.

  • A PARAMETRIC c, one coefficient array per dimension, which is what splprep returns, raises ValueError naming the two spellings that work: one dimension at a time, splantider(t, c[j], k, n), or a rank-2 c with one column per dimension, integrated in one call. scipy.interpolate.splantider raises AttributeError: 'list' object has no attribute 'shape' on its own splprep output, and refuses the rank-2 spelling with a broadcast error.

  • A c given as a flat list or tuple of numbers raises ValueError. scipy.interpolate.splantider raises AttributeError: 'list' object has no attribute 'shape' for it.

Accuracy vs scipy.interpolate.splantider on a random k=3 spline with 12 knots: knots, coefficients, degree and array lengths all match exactly (0.0) for n = 1 and n = 2, and the two spellings return the same bytes.

prange-safe: yes.

Examples

>>> import numpy as np
>>> from numba import njit
>>> from scijit.interpolate import splrep, splev, splantider
>>> x = np.linspace(0.0, np.pi, 60)
>>> tck = splrep(x, np.sin(x))
>>> @njit
... def running_area(tck, q):
...     return splev(q, splantider(tck, 1))
>>> np.round(running_area(tck, np.array([np.pi / 2, np.pi])), 6)
array([1., 2.])