scijit.interpolate.sproot¶
- scijit.interpolate.sproot(tck, mest=10)¶
Find the roots of a cubic spline.
- Parameters:
- tcktuple of (t, c, k)
Spline representation: knot vector, B-spline coefficients, degree.
kmust be 3.len(c)must be at leastlen(t) - 4; a longer c is accepted and the excess ignored.- mestint, optional
Size of the root buffer, and therefore the maximum number of roots returned. Default 10.
mest=0returns an empty array. A NEGATIVE mest means3 * (len(t) - 7), FITPACK’s own worst case (len(t) - 7knot intervals, each holding at most 3 roots of a cubic), so it never truncates.
- Returns:
- zero1-D float64 ndarray
The roots in
[t[3], t[n-4]], ascending; possibly empty. Truncated to mest entries when the spline has more roots than that.
- Raises:
- ValueError
k != 3, orlen(c) < len(t) - 4.- TypeError
len(t) < 8, or a knot vector failing FITPACK’s data checkt1<=..<=t4<t5<..<tn-3<=..<=tn.
- Warns:
- RuntimeWarning
The number of zeros exceeds mest, when mest binds and roots were dropped. The warning is issued through anumba.objmodeblock, which runs its body in the interpreter, sowarnings.catch_warningsand-Wsee it from compiled and uncompiled callers alike.
See also
scipy.interpolate.sprootThe scipy routine this mirrors.
Notes
A
BSplineinstance is a valid tck in scipy. This unpacks a 3-tuple.
A root that coincides with a knot is missed, and a tangential (double) root is not found. Both are FITPACK properties.
prange-safe: yes.
Examples
>>> import numpy as np >>> from numba import njit >>> from scijit.interpolate import splrep, sproot >>> x = np.linspace(0, 4, 60) >>> tck = splrep(x, np.sin(x)) >>> @njit ... def zeros(tck): ... return sproot(tck) >>> np.round(zeros(tck), 8) array([3.14159265])