bundles / scipy 1.17.1 / scipy / interpolate / _fitpack_py / insert
function
scipy.interpolate._fitpack_py:insert
Signature
def insert ( x , tck , m = 1 , per = 0 ) Summary
Insert knots into a B-spline.
Extended Summary
Given the knots and coefficients of a B-spline representation, create a new B-spline with a knot inserted m times at point x. This is a wrapper around the FORTRAN routine insert of FITPACK.
Parameters
x (u): floatA knot value at which to insert a new knot. If
tckwas returned fromsplprep, then the parameter values, u should be given.tck: a `BSpline` instance or a tupleIf tuple, then it is expected to be a tuple (t,c,k) containing the vector of knots, the B-spline coefficients, and the degree of the spline.
m: int, optionalThe number of times to insert the given knot (its multiplicity). Default is 1.
per: int, optionalIf non-zero, the input spline is considered periodic.
Returns
: BSpline instance or a tupleA new B-spline with knots t, coefficients c, and degree k.
t(k+1) <= x <= t(n-k), where k is the degree of the spline. In case of a periodic spline (per != 0) there must be either at least k interior knots t(j) satisfyingt(k+1)<t(j)<=xor at least k interior knots t(j) satisfyingx<=t(j)<t(n-k). A tuple is returned iff the input argumenttckis a tuple, otherwise a BSpline object is constructed and returned.
Notes
Based on algorithms from [1] and [2].
Manipulating the tck-tuples directly is not recommended. In new code, prefer using the BSpline objects, in particular BSpline.insert_knot method.
Array API Standard Support
insert is not in-scope for support of Python Array API Standard compatible backends other than NumPy.
See dev-arrayapi for more information.
Examples
You can insert knots into a B-spline.from scipy.interpolate import splrep, insert import numpy as np x = np.linspace(0, 10, 5) y = np.sin(x) tck = splrep(x, y) tck[0]✓
tck_inserted = insert(3, tck) tck_inserted[0]✓
tck_inserted2 = insert(8, tck, m=3) tck_inserted2[0]✓
See also
- BSpline.insert_knot
Aliases
-
scipy.interpolate.insert