basis_functions#

This submodule provides a wide range of basis functions implemented as classes. Each of these classes inherites from the the abstrac base class splinebox.basis_functions.BasisFunction described below and should overwrite the following class methods:

Currently the following basis functions are implemented: B1, B2, B2, Exponential, Catmull Rom, Cubic Hermite, Exponential Hermite

class splinebox.basis_functions.BasisFunction(multigenerator, support)#

Base class for all basis functions.

Parameters#

multigeneratorboolean

This indicates if the basis function generates multiple outputs. In practice, this is used to indicate if a basis function is meant for a Hermite spline or not. Basis functions for Hermite splines return two values instead of one.

supportfloat

The support of the function, i.e. the size of the area being mapped to non-zero values.

eval(t, derivative=0)#

Evaluate the function at position(s) t.

Parameters#

tfloat or numpy.array

The points where the function should be evaluated.

derivative[0, 1, 2], default = 0

Whether to evaluate the function (0) or its first (1) or second (2) derivative.

Returns#

ynumpy.array

Values of the function or its first or second derivative at position(s) t.

filter_periodic(s)#

The filter used to turn knots into control points for a closed spline.

Parameters#

snumpy.array

An array of knots of shape (n, dim) where n is the number of knots and dim is the dimensionality of the codomain, i.e. the space in which the curve lives. Note that the knots should be padded.

Returns#

control_pointsnumpy.array

The control points for the spline passing through the knots provided.

filter_symmetric(s)#

The filter used to turn knots into control points for an open spline.

Parameters#

snumpy.array

An array of knots of shape (n, dim) where n is the number of knots and dim is the dimensionality of the codomain, i.e. the space in which the curve lives. Note that the knots should be padded.

Returns#

control_pointsnumpy.array

The control points for the spline passing through the knots provided.

splinebox.basis_functions.inventory()#

This function returns a dictionary with all implemented basis function. The keys are the names of the basis function and the values are the classes.

splinebox.basis_functions.basis_function_from_name(name, **kwargs)#

Returns a basis function object based on the name of the basis function.

Parameters#

namestr

The name of the basis function, e.g. ‘B1’, ‘ExponentialHermite’, …

kwargs

Additional keyword arguments that might be required to create some basis functions, such as M (i.e. the number of knots/control points) for Exponential basis functions.

Returns#

basis_functionObject of one of the subcases of splinebox.basis_functions.BasisFunction.

The basis function object required for the construction of a spline.