jax_sbgeom.jax_utils.splines module
- bspline(x: Array, t: Array, c: Array, k: int, derivative: int)[source]
Evaluate a B-spline at points x.
Note that it is required that c.shape[0] == t.shape[0] - k - 1
- Parameters:
x (
Array) – Points at which to evaluate the B-spline.t (
Array) – Knot vectorc (
Array) – Coefficients of the B-spline basis functions.k (
int) – Degree of the B-spline.derivative (
int) – Order of the derivative to compute
- Returns:
Values of the B-spline at points x
- Return type:
jnp.ndarray [M]
- bspline_vectorized(x: Array, t: Array, c: Array, k: int, derivative: int)
Evaluate a B-spline at points x.
Note that it is required that c.shape[0] == t.shape[0] - k - 1
- Parameters:
x (
Array) – Points at which to evaluate the B-spline.t (
Array) – Knot vectorc (
Array) – Coefficients of the B-spline basis functions.k (
int) – Degree of the B-spline.derivative (
int) – Order of the derivative to compute
- Returns:
Values of the B-spline at points x
- Return type:
jnp.ndarray [M]
- class BSpline(t: Array, c: Array, k: int)[source]
Bases:
objectConvenience class for representing an arbitrarily batched B-spline.
Data
- tjnp.ndarray […, N]
Knot vector
- cjnp.ndarray […, N - k - 1]
Coefficients of the B-spline basis functions.
- kint
Degree of the B-spline.
- t: Array
- c: Array
- k: int
- periodic_interpolating_spline(x, y, k: int)[source]
Fit a periodic interpolating B-spline to batched data points (x,y) of degree k. The resulting spline satisfies S(x[i]) = y[i] for all i and is periodic (including derivatives up to < k).
- Parameters:
x (jnp.ndarray [..., n]) – Data points to be interpolated.
y (jnp.ndarray [..., n]) – Data values to be interpolated.
k (
int) – Degree of the B-spline.
- Returns:
Fitted periodic interpolating B-spline.
- Return type:
- make_periodic_knots(n: int, k: int)[source]
Build a periodic knot vector for n control points, degree k, on the domain [0, 2*pi). This is different than _periodic_knots, which builds a knot vector for periodic interpolation of given data points. This function is for building a knot vector for periodic B-spline parametrization.
- Parameters:
n (
int) – Number of control points.k (
int) – Degree of the B-spline.
- Returns:
Knot vector for periodic B-spline interpolation.
- Return type:
Array
- make_periodic_coeffs(c: Array, k: int)[source]
Extend n coefficients to n+k by wrapping the first k, enforcing periodicity.
- Parameters:
c (
Array) – Coefficients of the B-spline basis functions.k (
int) – Degree of the B-spline.
- Returns:
Extended coefficients for periodic B-spline interpolation.
- Return type:
Array
- periodic_bspline(theta: Array, c: Array, k: int, derivative: int = 0)[source]
Function to evaluate a periodic B-spline at angles theta given coefficients c and degree k.
Note that the coefficients c are the free parameters, which do not map directly to a control point given by their index. Use :func`greville_abscissa_periodic_bspline` to compute the control points location.
- Parameters:
theta (
Array) – Angles at which to evaluate the B-spline, in radians.c (
Array) – Coefficients of the B-spline basis functions. Must have length n, which is the number of free parameters. Internally extended to n+k for periodicity.k (
int) – Degree of the B-spline.derivative (
int) – Order of the derivative to compute. Default is 0 (the function itself).
- Returns:
Values of the periodic B-spline (or its derivative) at the angles theta.
- Return type:
jnp.ndarray [M]