scipy 1.8.0 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef

Parameters

t : ndarray, shape (nt + k + 1,)

sorted 1D array of knots

k : int

spline order

xval: float :

argument at which to evaluate the B-splines

m : int

index of the left edge of the evaluation interval, t[m] <= x < t[m+1]

nu : int, optional

Evaluate derivatives order :None:None:`nu`. Default is zero.

Returns

ndarray, shape (k+1,)

The values of B-splines $[B_{m-k}(xval), ..., B_{m}(xval)]$ if :None:None:`nu` is zero, otherwise the derivatives of order :None:None:`nu`.

Evaluate the k+1 B-splines which are non-zero on interval m .

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 spline

This example is valid syntax, but we were not able to check execution
>>> k = 3
... t = [0., 2., 2., 3., 4.] # internal knots
... a, b = t[0], t[-1] # base interval is [a, b)
... t = [a]*k + t + [b]*k # add boundary knots
This example is valid syntax, but we were not able to check execution
>>> import matplotlib.pyplot as plt
... xx = np.linspace(a, b, 100)
... plt.plot(xx, BSpline.basis_element(t[k:-k])(xx),
...  'r-', lw=5, alpha=0.5)
... c = ['b', 'g', 'c', 'k']

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:

This example is valid syntax, but we were not able to check execution
>>> 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, c[i] + '--', lw=3, label=str(i)) ...
This example is valid syntax, but we were not able to check execution
>>> plt.grid(True)
... plt.legend()
... plt.show()
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.interpolate._bspl.evaluate_all_bspl

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : None#None
type: <class 'builtin_function_or_method'>
Commit: