Efficient, differentiable B-splines in JAX with De Boor's algorithm.
- JAX-traceable De Boor implementation - completely sparse
- Jitable, vmapable, etc.
- Compile-time precomputation for minimal FLOPS
- Transparent shapes and types with Jaxtyping
import jax.numpy as jnp
from bspx import bspline
P = jnp.array([[0., 0.], [1., 1.], [1., 2.], [2., 4.], [4., 2.], [2., 1.], [3., 0.]])
curve = bspline(P, n_points=42, k=4) # shape (42, 2)When no knots and evaluation times are given, we assume cardinal B-splines, i.e. uniform knots and evaluation times. This allows us to precompute the blending factors at compile time, resulting in efficient evaluation during runtime. For this, most functions in bspx process both NumPy arrays and JAX tracers, so we can use the same code for precomputation and runtime evaluation.
To enable beartype, have a look at bspx/__init__.py
| Symbol | Description |
|---|---|
| order (= degree + 1) | |
| index of last control point → |
|
| index of last knot → |
|
| parameter value | |
| knot vector, shape (m+1,) | |
| control points, shape (n+1, d) |
Other:
- Check if a custom vjp might be faster than autodiff -> No its not!