scijit.interpolate.splint¶
- scijit.interpolate.splint(a, b, tck, full_output=0)¶
Evaluate the definite integral of a spline.
- Parameters:
- a, bfloat
Integration limits, the limits first and tck last. They may lie outside the knot range, where the spline is extrapolated;
b < agives the negated integral.- tcktuple of (t, c, k)
Spline representation.
- full_outputint, optional
Non-zero also returns wrk, the per-B-spline integrals. Default 0. Must be a compile-time constant inside
@njit, since it selects the return type.
- Returns:
- resfloat
The integral of the spline over
[a, b].- wrk1-D float64 ndarray, length
len(t) - k - 1 The integral of each normalised B-spline over
[a, b], so thatres == sum(c[:len(wrk)] * wrk). Returned only when full_output is non-zero.
- Raises:
- ValueError
If c holds fewer than
len(t) - k - 1coefficients.
See also
scipy.interpolate.splintThe scipy routine this mirrors.
Notes
full_output must be a compile-time constant inside
@njit: it selects between a bare float and a 2-tuple, and numba compiles one return type per specialization. A bool, an int, a string and the default are read while the call compiles; a float, a container and a runtime variable are not, and raiseTypingErrornaming the argument. From Python every object is read by its truthiness.full_output=1returns the wrk array, holding the integrals of the normalized B-splines. scipy 1.18 returns(res, None)there.A parametric c, the coefficient list
scipy.interpolate.splprepreturns, makes scipy return a list of integrals. This takes one coefficient array at a time.tck is a 3-tuple. scipy also accepts a
BSplineinstance.
prange-safe: yes.
Examples
>>> import numpy as np >>> from numba import njit >>> from scijit.interpolate import splrep, splint >>> x = np.linspace(0, np.pi, 60) >>> tck = splrep(x, np.sin(x)) >>> @njit ... def area(tck): ... return splint(0.0, np.pi, tck) >>> float(np.round(area(tck), 10)) 1.9999999783 >>> @njit ... def area_and_parts(tck): ... res, wrk = splint(0.0, np.pi, tck, 1) ... return res, len(wrk) >>> res, nwrk = area_and_parts(tck) >>> float(np.round(res, 10)), nwrk (1.9999999783, 60)