bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / interpolate / _dierckx / evaluate_all_bspl
built-in
scipy.interpolate._dierckx:evaluate_all_bspl
Summary
Evaluate the k+1 B-splines which are non-zero on interval m.
Parameters
t: ndarray, shape (nt + k + 1,)sorted 1D array of knots
k: intspline order
xval: floatargument at which to evaluate the B-splines
m: intindex of the left edge of the evaluation interval,
t[m] <= x < t[m+1]nu: int, optionalEvaluate derivatives order nu. Default is zero.
Returns
: ndarray, shape (k+1,)The values of B-splines if nu is zero, otherwise the derivatives of order nu.
Examples
A textbook use of this sort of routine is plotting the ``k+1`` polynomial pieces which make up a B-spline of order `k`. Consider a cubic splinek = 3 t = [0., 1., 2., 3., 4.] # internal knots a, b = t[0], t[-1] # base interval is [a, b) t = np.array([a]*k + t + [b]*k) # add boundary knots✓
import matplotlib.pyplot as plt xx = np.linspace(a, b, 100)✓
plt.plot(xx, BSpline.basis_element(t[k:-k])(xx), lw=3, alpha=0.5, label='basis_element')⚠
Traceback (most recent call last):
File "<doctest scipy.interpolate._dierckx:evaluate_all_bspl[0]>", line 1, in <module>
plt.plot(xx, BSpline.basis_element(t[k:-k])(xx),
^^^^^^^
NameError: name 'BSpline' is not defined
Now we use slide an interval ``t[m]..t[m+1]`` along the base interval
``a..b`` and use `evaluate_all_bspl` to compute the restriction of
the B-spline of interest to this interval:
for i in range(k+1): x1, x2 = t[2*k - i], t[2*k - i + 1] xx = np.linspace(x1 - 0.5, x2 + 0.5) yy = [evaluate_all_bspl(t, k, x, 2*k - i)[i] for x in xx] plt.plot(xx, yy, '--', label=str(i))✗
[<matplotlib.lines.Line2D object at 0x7f3f433be120>] [<matplotlib.lines.Line2D object at 0x7f3f433be3c0>] [<matplotlib.lines.Line2D object at 0x7f3f433bd550>] [<matplotlib.lines.Line2D object at 0x7f3f433bdd30>]
plt.grid(True)
✓plt.legend()
✗<matplotlib.legend.Legend object at 0x7f3f433be660>
plt.show()
✓
Aliases
scipy.interpolate._dierckx.evaluate_all_bspl