B-Splines [module]

Here are the methods of the module splinekit.bsplines.

splinekit.bsplines.polynomial_simple_element(x: float, degree: int) float

Polynomial simple element \(\varsigma^{n}.\)

Returns the value of a polynomial simple element of integer degree \(n\) evaluated at \(x.\) It is defined as

\[\begin{split}\varsigma^{n}(x)=\left\{\begin{array}{ll} \delta^{\left(\left|n-1\right|\right)}(x),& n\in{\mathbb{Z}}\setminus{\mathbb{N}}\\ \frac{1}{2\,\left(n!\right)}\,{\mathrm{sgn}}(x)\,x^{n},& n\in{\mathbb{N}},\end{array}\right.\end{split}\]

where \(\delta^{\left(m\right)}\) is the \(m\)-th derivative of the Dirac delta distribution and where \({\mathrm{sgn}}\) is the signum function.

Parameters:
  • x (float) – Argument.

  • degree (int) – Degree of the polynomial simple element.

Returns:

The value of the polynomial simple element at \(x.\)

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Polynomial simple elements of positive degrees always vanish at 0.0.
>>> sk.polynomial_simple_element(0.0, 2)
0.0
>>> sk.polynomial_simple_element(0.0, 1)
0.0
The polynomial simple element of degree zero vanishes at 0.0 as well.
>>> sk.polynomial_simple_element(0.0, 0)
0.0
Polynomial simple elements of negative degrees are not real numbers at 0.0.
>>> sk.polynomial_simple_element(0.0, -1)
nan
Polynomial simple elements of negative degrees vanish everywhere except at the origin.
>>> sk.polynomial_simple_element(1.0, -5)
0.0

splinekit.bsplines.b_spline(x: float, degree: int) float

B-spline \(\beta^{n}.\)

Returns the value of the polynomial B-spline \(\beta^{n}\) of nonnegative degree \(n\) evaluated at the argument \(x.\) For the degree \(n=0,\) this function is defined as

\[\beta^{0}(x)=\varsigma^{0}(x+\frac{1}{2})-\varsigma^{0}(x-\frac{1}{2}),\]

with \(\varsigma^{0}\) a polynomial simple element of degree \(0.\) B-splines of positive degree \(n\) are computed as

\[\begin{split}\beta^{n}(x)=\left\{\begin{array}{ll}\left(w^{n}[r][\cdot]\right)^ {{\mathsf{T}}}\,{\mathbf{v}}^{n}(\chi),&\left|x\right|<\frac{n+1}{2}\\ 0,&\frac{n+1}{2}\leq\left|x\right|,\end{array}\right.\end{split}\]

with \(\xi=\left(\frac{n-1}{2}-x\right),\) \(r=\left\lceil\xi\right\rceil\in{\mathbb{Z}},\) and \(\chi=\left(r-\xi\right)\in[0,1).\) Moreover, \(\left(w^{n}[r][\cdot]\right)^{{\mathsf{T}}}\) is the \((r+1)\)-th row of the B-spline evaluation matrix, and \({\mathbf{v}}^{n}(\chi)\) is the Vandermonde vector of argument \(\chi\) and degree \(n.\)

As computed above, the fact that the Vandermonde vector has the domain \([0,1)\) greatly favors numerical stability since the image of each of its components is also \([0,1).\)

Parameters:
  • x (float) – Argument.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

Returns:

The value of a B-spline.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Value of the cubic B-spline at the origin.
>>> sk.b_spline(0.0, 3)
0.6666666666666666
The B-spline of degree 0 is even-symmetric, also at its discontinuity.
>>> sk.b_spline(-0.5, 0) == sk.b_spline(0.5, 0)
True
The B-spline of degree 0 satisfies the partition of unity, also at its discontinuity.
>>> 1.0 == sk.b_spline(-0.5, 0) + sk.b_spline(0.5, 0)
True

splinekit.bsplines.b_spline_support(degree: int) Interval

Support \({\mathrm{supp}}\,\beta^{n}.\)

Returns the support of the polynomial B-spline of nonnegative degree \(n.\) For the degree \(n=0,\) the support is the closed interval

\[[-\frac{1}{2},\frac{1}{2}].\]

B-splines of positive degree \(n\) have as support the open interval

\[(-\frac{n+1}{2},\frac{n+1}{2}).\]
Parameters:

degree (int) – Nonnegative degree of the polynomial B-spline.

Returns:

The support of a B-spline.

Return type:

Interval

Examples

Load the library.
>>> import splinekit as sk
Support of the cubic B-spline.
>>> sk.b_spline_support(3)
Open((-2.0, 2.0))

splinekit.bsplines.b_spline_variance(degree: int) float

Variance \(\int\,\left(\cdot\right)^{2}\,\beta^{n}.\)

Returns the variance \(\sigma_{n}^{2}\) of the polynomial B-spline \(\beta^{n}\) of nonnegative degree \(n.\) It is defined as

\[\sigma_{n}^{2}=\int_{-\infty}^{\infty}\,x^{2}\,\beta^{n}(x)\, {\mathrm{d}}x.\]
Parameters:

degree (int) – Nonnegative degree of the polynomial B-spline.

Returns:

The variance of a B-spline.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Variance of the cubic B-spline.
>>> sk.b_spline_variance(3)
0.3333333333333333

splinekit.bsplines.pole(degree: int) ndarray[tuple[int], dtype[float64]]

Poles of the B-spline \(\beta^{n}.\)

Returns the numpy vector \({\mathbf{z}}^{n}\in {\mathbb{R}}^{\left\lfloor n/2\right\rfloor}\) of the poles of the reciprocal of the z-transform of the sequence made of the samples at the integers of the polynomial B-spline \(\beta^{n}\) of nonnegative degree \(n.\) The components of \({\mathbf{z}}^{n}\) are sorted in increasing order (i.e., in decreasing absolute order); only those poles that are in the interval \((-1,0)\) are provided. For every pole \(z,\) it holds that

\[0=\sum_{k\in{\mathbb{Z}}}\,\beta^{n}(k)\,z^{-k}.\]
Parameters:

degree (int) – Nonnegative degree of the B-spline.

Returns:

The poles.

Return type:

np.ndarray[tuple[int], np.dtype[np.float64]]

Examples

Load the library.
>>> import splinekit as sk
The linear B-spline has no pole.
>>> sk.pole(1)
array([], dtype=float64)
The B-spline of degree 5 has 2 poles.
>>> sk.pole(5)
array([-0.43057535, -0.04309629])

Notes

The results of this method are cached. If the returned results are mutated, the cache gets modified and the next call will return corrupted values.


splinekit.bsplines.integrated_b_spline(x: float, degree: int) float

Integrated B-spline \(\int\beta^{n}.\)

Returns the value of the integral \(\int_{-\infty}^{x}\,\beta^{n}(y)\,{\mathrm{d}}y\) of the polynomial B-spline \(\beta^{n}\) of nonnegative degree \(n\) evaluated at the argument \(x.\) It is computed as

\[\begin{split}\int_{-\infty}^{x}\,\beta^{n}(y)\,{\mathrm{d}}y= \left\{\begin{array}{ll}0,&x\leq-\frac{n+1}{2}\\ \left(w_{{\mathrm{int}}}^{n}[r][\cdot]\right)^ {{\mathsf{T}}}\,{\mathbf{v}}^{n+1}(\chi), &-\frac{n+1}{2}<x<\frac{n+1}{2}\\ 1,&\frac{n+1}{2}\leq x,\end{array}\right.\end{split}\]

with \(\xi=\left(\frac{n-1}{2}-x\right),\) \(r=\left\lceil\xi\right\rceil\in{\mathbb{Z}},\) and \(\chi=\left(r-\xi\right)\in[0,1).\) Moreover, \(\left(w_{{\mathrm{int}}}^{n}[r][\cdot]\right)^{{\mathsf{T}}}\) is the \((r+1)\)-th row of the integrated-B-spline evaluation matrix, and \({\mathbf{v}}^{n+1}(\chi)\) is the Vandermonde vector of argument \(\chi\) and degree \(n+1.\)

As computed above, the fact that the Vandermonde vector has the domain \([0,1)\) greatly favors numerical stability since the image of each of its components is also \([0,1).\)

Parameters:
  • x (float) – Argument.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

Returns:

The value of an integrated B-spline.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Value of the integrated B-spline of degree 11 at the origin.
>>> sk.integrated_b_spline(0.0, 11)
0.5

splinekit.bsplines.grad_b_spline(x: float, degree: int) float

Differentiated B-spline \(\dot{\beta}^{n}.\)

Returns the value \(\dot{\beta}^{n}(x)\) of the gradient of the polynomial B-spline \(\beta^{n}\) of nonnegative degree \(n\) evaluated at the argument \(x.\) It is computed as

\[\begin{split}\dot{\beta}^{n}(x)=\left\{\begin{array}{ll} \sum_{k=0}^{n+1}\,\left(-1\right)^{k}\,{n+1\choose k}\, \varsigma^{n-1}(x+\frac{n+1}{2}-k),& n\leq1\wedge\left|x\right|\leq\frac{n+1}{2}\\ \left(w_{{\mathrm{d}}}^{n}[r][\cdot]\right)^ {{\mathsf{T}}}\,{\mathbf{v}}^{n-1}(\chi), &1<n\wedge\left|x\right|<\frac{n+1}{2}\\ 0,&1<n\wedge\left|x\right|=\frac{n+1}{2}\\ 0,&\left|x\right|>\frac{n+1}{2},\end{array}\right.\end{split}\]

with \(\varsigma^{n-1}\) a polynomial simple element of degree \(\left(n-1\right),\) with \(\xi=\left(\frac{n-1}{2}-x\right),\) \(r=\left\lceil\xi\right\rceil\in{\mathbb{Z}},\) and \(\chi=\left(r-\xi\right)\in[0,1).\) Moreover, \(\left(w_{{\mathrm{d}}}^{n}[r][\cdot]\right)^{{\mathsf{T}}}\) is the \((r+1)\)-th row of the differentiated-B-spline evaluation matrix, and \({\mathbf{v}}^{n-1}(\chi)\) is the Vandermonde vector of argument \(\chi\) and degree \(\left(n-1\right).\)

As computed above, the fact that the Vandermonde vector has the domain \([0,1)\) greatly favors numerical stability since the image of each of its components is also \([0,1).\)

Parameters:
  • x (float) – Argument.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

Returns:

The value of the gradient of a B-spline.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Value of the differentiated linear B-spline at the origin.
>>> sk.grad_b_spline(0.0, 1)
0.0
Value of the differentiated linear B-spline at -0.01.
>>> sk.grad_b_spline(-0.01, 1)
1.0
Value of the differentiated linear B-spline at 0.01.
>>> sk.grad_b_spline(0.01, 1)
-1.0
Value of the differentiated B-spline of degree 0 at 0.5.
>>> sk.grad_b_spline(0.5, 0)
nan

splinekit.bsplines.diff_b_spline(x: float, *, degree: int, differentiation_order: int) float

Differentiated B-spline \({\mathrm{D}}^{d}\beta^{n}.\)

Returns the value \(\frac{{\mathrm{d}}^{d}{\beta}^{n}(x)}{{\mathrm{d}}x^{d}}\) of the \(d\)-th derivative of the polynomial B-spline \(\beta^{n}\) of nonnegative degree \(n\) evaluated at the argument \(x.\) Its general case is computed as

\[\frac{{\mathrm{d}}^{d}{\beta}^{n}(x)}{{\mathrm{d}}x^{d}}= d!\,w^{n}[r][d]+\sum_{c=d+1}^{n}\,\frac{c!}{\left(c-d\right)!}\, w^{n}[r][c]\,\chi^{c-d},\]

with \(\xi=\left(\frac{n-1}{2}-x\right),\) \(r=\left\lceil\xi\right\rceil\in{\mathbb{Z}},\) and \(\chi=\left(r-\xi\right)\in[0,1).\) Moreover, \(w^{n}[r][c]\) is the \((r+1)\)-th row and \((c+1)\)-th column component of the B-spline evaluation matrix.

The \(d\)-th derivative of a B-spline of nonnegative degree
  • is discontinuous for \(d=n;\)

  • vanishes almost everywhere for \(d\geq n+1;\)

  • is undefined at the knots of the B-spline for \(d\geq n+1.\)

The \(d\)-th derivative of a B-spline of positive degree
  • is continuous and non-differentiable for \(d=\left(n-1\right).\)

The \(d\)-th derivative of a B-spline of degree \(n\geq2\)
  • is continuously differentiable for \(d\in[0\ldots n-2].\)

As computed above, the fact that the variable \(\chi\) has the domain \([0,1)\) greatly favors numerical stability.

Parameters:
  • x (float) – Argument.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

  • differentiation_order (int) – Nonnegative order of differentiation.

Returns:

The value of a differentiated B-spline.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Value of the Hessian of the linear B-spline at the origin.
>>> sk.diff_b_spline(0.0, degree = 1, differentiation_order = 2)
nan
Value of the Hessian of the quadratic B-spline at the origin.
>>> sk.diff_b_spline(0.0, degree = 2, differentiation_order = 2)
-2.0
Value of the Hessian of the cubic B-spline at the origin.
>>> sk.diff_b_spline(0.0, degree = 3, differentiation_order = 2)
-2.0
Value of the Hessian of the quartic B-spline at the origin.
>>> sk.diff_b_spline(0.0, degree = 4, differentiation_order = 2)
-1.25

splinekit.bsplines.mscale_filter(*, degree: int, scale: int) ndarray[tuple[int], dtype[float64]]

M-scale filter of the B-spline \(\beta^{n}.\)

Returns a numpy one-dimensional array of the nonzero taps of the filter \(h^{n}_{M}\) that appears in the M-scale relation of B-splines expressed as

\[\beta^{n}(x)=\frac{1}{M^{n}}\,\sum_{k=0}^{\left(M-1\right)\, \left(n+1\right)}\,h^{n}_{M}[k]\,\beta^{n}(M\,x+ \frac{\left(M-1\right)\,\left(n+1\right)}{2}-k),\]

where \(\beta^{n}\) is the polynomial B-spline of nonnegative degree \(n\) and \(M\) is the positive scale.

Parameters:
  • degree (int) – Nonnegative degree of the B-spline.

  • scale (int) – Positive scale.

Returns:

The nonzero taps of the M-scale filter.

Return type:

np.ndarray[tuple[int], np.dtype[np.float64]]

Examples

Load the library.
>>> import splinekit as sk
A linear B-spline is a sum of three linear B-splines of half the size.
>>> sk.mscale_filter(degree = 1, scale = 2)
array([1., 2., 1.])
A quadratic B-spline is a sum of thirteen quadratic B-splines of fifth the size.
>>> sk.mscale_filter(degree = 2, scale = 5)
array([ 1., 3., 6., 10., 15., 18., 19., 18., 15., 10., 6., 3., 1.])

Notes

The results of this method are cached. If the returned results are mutated, the cache gets modified and the next call will return corrupted values.


splinekit.bsplines.ib_coeff(k: int, degree: int) float

Inverse B-spline sequence \(\left(b^{n}\right)^{-1}.\)

Returns the \(k\)-th component of the sequence \(\left(b^{n}\right)^{-1}\) such that

\[{\mathbf{[\![}}q=0\,{\mathbf{]\!]}}=\sum_{k\in{\mathbb{Z}}}\, \left(b^{n}\right)^{-1}[k]\,\beta^{n}(q-k),\]

where the notation \({\mathbf{[\![}}\cdot\,{\mathbf{]\!]}}\) is that of the Iverson bracket and where \(\beta^{n}\) is the polynomial B-spline of nonnegative degree \(n\).

For \(n\in\{0,1\},\) one has that

\[\left(b^{n}\right)^{-1}[k]={\mathbf{[\![}}k=0\,{\mathbf{]\!]}}.\]

For \(n>1,\) the inverse sequence \(\left(b^{n}\right)^{-1}\) is computed as

\[\left(b^{n}\right)^{-1}[k]= \left({\mathbf{i}}^{n}\right)^{{\mathsf{T}}}\, \left({\mathbf{z}}^{n}\right)^{\left|k\right|},\]

where the vector \({\mathbf{i}}^{n}\) is defined here, and where the absolute \(k\)-th power \(\left({\mathbf{z}}^{n}\right)^{\left|k\right|}\) of the vector \({\mathbf{z}}^{n}\) of poles must be understood component-wise.

Parameters:
  • k (int) – Index of the coefficient.

  • degree (int) – Nonnegative degree of the B-spline.

Returns:

A component of the inverse B-spline sequence.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
The inverse quadratic B-spline sequence at the origin is the square root of two.
>>> sk.ib_coeff(0, 2) * sk.ib_coeff(0, 2)
2.0000000000000004

Notes

The results of this method are cached. If the returned results are mutated, the cache gets modified and the next call will return corrupted values.


splinekit.bsplines.cardinal_b_spline(x: float, degree: int) float

Cardinal B-spline \(\eta^{n}.\)

Returns the value of the cardinal polynomial B-spline \(\eta^{n}\) of nonnegative degree \(n\) evaluated at the argument \(x.\) This function is defined as

\[\eta^{n}(x)=\sum_{k\in{\mathbb{Z}}}\,\left(b^{n}\right)^{-1}[k]\, \beta^{n}(x-k),\]

with \(\left(b^{n}\right)^{-1}\) a B-spline inverse sequence and \(\beta^{n}\) a polynomial B-spline.

Parameters:
  • x (float) – Argument.

  • degree (int) – Nonnegative degree of the cardinal polynomial B-spline.

Returns:

The value of a cardinal B-spline.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Values of the cardinal quadratic B-spline at a few integers.
>>> [sk.cardinal_b_spline(k, 2) for k in range(-3, 3)]
[-3.230922474006803e-17,
 1.9949319973733282e-16,
 1.0000000000000002,
 1.9949319973733282e-16,
 -3.230922474006803e-17]
Values of the cardinal quadratic B-spline at a few half integers.
>>> [sk.cardinal_b_spline(k + 0.5, 2) for k in range(-3, 3)]
[0.017243942703102966,
 -0.10050506338833456,
 0.5857864376269051,
 0.5857864376269051,
 -0.10050506338833456,
 0.017243942703102966]

splinekit.bsplines.dual_b_spline(x: float, *, dual_degree: int, primal_degree: int) float

Dual B-spline \(\mathring{\beta}^{m,n}.\)

Returns the value of the polynomial dual B-spline \(\mathring{\beta}^{m,n}\) of nonnegative dual degree \(m\) and nonnegative primal degree \(n,\) evaluated at the argument \(x.\) This function is computed as

\[\mathring{\beta}^{m,n}(x)=\sum_{k\in{\mathbb{Z}}}\, \left(b^{m+n+1}\right)^{-1}[k]\,\beta^{m}(x-k),\]

with \(\left(b^{m+n+1}\right)^{-1}\) a B-spline inverse sequence and \(\beta^{m}\) a polynomial B-spline.

Parameters:
  • x (float) – Argument.

  • dual_degree (int) – Nonnegative dual degree of the polynomial dual B-spline.

  • primal_degree (int) – Nonnegative primal degree of the polynomial dual B-spline.

Returns:

The value of a dual B-spline.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Value of the (dual-five, primal-two) B-spline at the origin.
>>> sk.dual_b_spline(0.0, dual_degree = 5, primal_degree = 2)
1.7451037781381014

splinekit.bsplines.spline_polynomial(*, spline_degree: int, monomial_degree: int) poly

Sum of B-spline-weighted discrete canonic monomials.

Returns as a sympy.poly object the polynomial generated by the B-spline-weighted sum of the discrete monomials of nonnegative degree \(m,\) with \(n\) the degree of the B-spline such that \(n\geq m.\)

The partition of unity is the sum of discrete constant monomials. It is

\[\sum_{k\in{\mathbb{Z}}}\,\beta^{n}(x-k)=\textcolor{green}{1}.\]

B-spline-weighted sums of discrete canonic monomials can be computed for positive odd monomial degree \(m\) as

\[\sum_{k\in{\mathbb{Z}}}\,\beta^{n}(x-k)\,k^{m}= \textcolor{green}{\sum_{c=0}^{(m-1)/2}\,v^{n}[m-1][\frac{m-1}{2}-c]\, x^{2\,c+1}},\]
\[\]

while B-spline-weighted sums of discrete canonic monomials can be computed for positive even monomial degree \(m\) as

\[\sum_{k\in{\mathbb{Z}}}\,\beta^{n}(x-k) \,k^{m}=\textcolor{green}{v^{n}[m-1][\frac{m}{2}]+\sum_{c=1}^{m/2}\, v^{n}[m-1][\frac{m}{2}-c]\,x^{2\,c}}.\]

There, \(v^{n}\) is the lookup table described here.

Parameters:
  • spline_degree (int) – Nonnegative degree of the weighting polynomial B-spline.

  • monomial_degree (int) – Nonnegative degree of the weighted monomials.

Returns:

The polynomial in \(x\) of the right-hand side of the equations above.

Return type:

sympy.poly

Examples

Load the library.
>>> import splinekit as sk
Polynomial generated by weighting cubic discrete monomials by octic B-splines.
>>> print(sk.spline_polynomial(spline_degree = 8, monomial_degree = 3))
Poly(x**3 + 9/4*x, x, domain='QQ')

Notes

The results of this method are cached. If the returned results are mutated, the cache gets modified and the next call will return corrupted values.

The returned polynomial polyQQ is valid over the sympy domain "QQ". If it is desired to evaluate it at floating-point arguments, it may be convenient to perform the conversion polyRR = sympy.Poly.from_poly(polyQQ, domain = "RR").


splinekit.bsplines.partition_of_monomial(*, spline_degree: int, monomial_degree: int) poly

Expression of the coefficients of splines that reproduce canonic monomials.

Returns as a sympy.poly object the expression of the discrete polynomial that, once weighted by a polynomial B-spline of nonnegative degree \(n\) and summed, will represent a monomial of nonnegative degree \(m.\) The degree of the B-spline and of the monomial must be such that \(n\geq m.\)

The partition of unity is the sum of discrete constant monomials. It is

\[1=\sum_{k\in{\mathbb{Z}}}\,\left(\textcolor{green}{1}\right)\, \beta^{n}(x-k).\]

Monomials for positive odd \(m\) can be reproduced as

\[x^{m}=\sum_{k\in{\mathbb{Z}}}\, \left(\textcolor{green}{\sum_{p=0}^{\left(m-1\right)/2}\, \alpha^{n}[m][2\,p+1]\,k^{2\,p+1}}\right)\,\beta^{n}(x-k),\]
\[\]

while monomials for positive even \(m\) can be reproduced as

\[x^{m}=\sum_{k\in{\mathbb{Z}}}\, \left(\textcolor{green}{\alpha^{n}[m][0]+\sum_{p=1}^{m/2}\, \alpha^{n}[m][2\,p]\,k^{2\,p}}\right)\,\beta^{n}(x-k).\]

There, \(\alpha^{n}\) is the lookup table described here.

Parameters:
  • spline_degree (int) – Nonnegative degree of the weighting polynomial B-spline.

  • monomial_degree (int) – Nonnegative degree of the generated monomial.

Returns:

The discrete polynomial in \(k\) in the parenthesis of the right-hand side of the equations above.

Return type:

sympy.poly

Examples

Load the library.
>>> import splinekit as sk
Discrete polynomial as the coefficient needed to generate a quadratic monomial from quartic B-splines.
>>> print(sk.partition_of_monomial(spline_degree = 4, monomial_degree = 2))
Poly(k**2 - 5/12, k, domain='QQ')

Notes

The results of this method are cached. If the returned results are mutated, the cache gets modified and the next call will return corrupted values.


splinekit.bsplines.convolve_b_spline_monomial(*, spline_degree: int, spline_differentiation_order: int = 0, monomial_degree: int) poly

Expression of the convolution between a spline and a canonic monomial.

Returns as a sympy.poly object the polynomial that results from the convolution betweeen the \(d\)-th derivative of a polynomial B-spline of nonnegative degree \(n\) and a monomial of nonnegative degree \(m\). The order of differentiation must be such that \(d\in[0\ldots n+1+m].\)

\[\begin{split}\begin{eqnarray*} \left({\mathrm{D}}^{d}\beta^{n}*\left(\cdot\right)^{m}\right)(x)&=& \int_{{\mathbb{R}}}\, \frac{{\mathrm{d}}^{d}\beta^{n}(y)}{{\mathrm{d}}y^{d}}\, \left(x-y\right)^{m}\,{\mathrm{d}}y\\ &=&\frac{m!}{\left(m+n+1-d\right)!}\,\sum_{k=0}^{n+1}\, \left(-1\right)^{k}\,{n+1\choose k}\, \left(x+\frac{n+1}{2}-k\right)^{m+n+1-d}\\ &=&\textcolor{green}{\gamma_{m}^{n}[0]+ \sum_{k=1}^{m+n+1-d}\,\gamma_{m}^{n}[k]\,x^{k}}. \end{eqnarray*}\end{split}\]
Parameters:
  • spline_degree (int) – Nonnegative degree of the polynomial B-spline.

  • spline_differentiation_order (int) – Nonnegative differentiation order of the polynomial B-spline (must not exceed \(m+n+1\)).

  • monomial_degree (int) – Nonnegative degree of the monomial.

Returns:

The polynomial in \(x\) in the right-hand side of the equation above.

Return type:

sympy.poly

Examples

Load the library.
>>> import splinekit as sk
Polynomial obtained by convolving a linear B-spline with a cubic monomial.
>>> print(sk.convolve_b_spline_monomial(spline_degree = 1, monomial_degree = 3))
Poly(x**3 + 1/2*x, x, domain='QQ')
Polynomial obtained by convolving the Hessian of a B-spline of degree zero with a quartic monomial.
>>> print(sk.convolve_b_spline_monomial(spline_degree = 0, spline_differentiation_order = 2, monomial_degree = 4))
oly(12*x**2 + 1, x, domain='QQ')

Notes

The results of this method are cached. If the returned results are mutated, the cache gets modified and the next call will return corrupted values.

The returned polynomial polyQQ is valid over the sympy domain "QQ". If it is desired to evaluate it at floating-point arguments, it may be convenient to perform the conversion polyRR = sympy.Poly.from_poly(polyQQ, domain = "RR").