# \[pre-ANN\] SplineGrids.jl - Efficient evaluation of spline/NURBS geometries of any dimensionality

**URL:** <https://discourse.julialang.org/t/pre-ann-splinegrids-jl-efficient-evaluation-of-spline-nurbs-geometries-of-any-dimensionality/124459>\
**Category:** Package Announcements\
**Tags:** package, announcement, geometry, splines\
**Created:** [January 6, 2025, 6:29am UTC](https://discourse.julialang.org/t/pre-ann-splinegrids-jl-efficient-evaluation-of-spline-nurbs-geometries-of-any-dimensionality/124459 "2025-01-06T06:29:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BdeKoning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdekoning/32/214557_2.png) [@BdeKoning](https://discourse.julialang.org/u/BdeKoning)\
**Post date:** [January 6, 2025, 6:29am UTC](https://discourse.julialang.org/t/pre-ann-splinegrids-jl-efficient-evaluation-of-spline-nurbs-geometries-of-any-dimensionality/124459/1 "2025-01-06T06:29:26Z")

</div>

Hello everyone,

I’d like to announce a package I’ve been working on as a passion project for the past few weeks: **SplineGrids.jl** :

- Repo: [SouthEndMusic/SplineGrids.jl: Evaluating splines of arbitrary dimensionality on a grid.](https://github.com/SouthEndMusic/SplineGrids.jl)
- Docs: [SplineGrids.jl · SplineGrids.jl](https://southendmusic.github.io/SplineGrids.jl/dev/)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/0/3041566e6fb65995583ff463940b58918decc52a.png)

**What**  
SplineGrids.jl is designed to efficiently evaluate a broad class of spline objects on a grid in the spline’s domain. The package supports:

- Any number of input and output dimensions (see the examples [here](https://southendmusic.github.io/SplineGrids.jl/dev/examples_dimensions/))
- Any degree of basis functions and type of knot vector
- Using weights to define NURBS (see an example [here](https://southendmusic.github.io/SplineGrids.jl/dev/examples_nurbs/))
- Any combination of partial derivatives (not for NURBS, coming up) (see an example [here](https://southendmusic.github.io/SplineGrids.jl/dev/examples_derivatives/))
- Local refinement (coming up)
- CPU and GPU backends via [KernelAbstractions.jl](https://github.com/JuliaGPU/KernelAbstractions.jl) (tested with `CUDABackend`)

The intended use case of this package is to be integrated into the [SciML ecosystem](https://sciml.ai/), for easy and efficient incorporation of spline geometries in problems of [fitting](https://southendmusic.github.io/SplineGrids.jl/dev/examples_linear_fitting/), [optimization](https://southendmusic.github.io/SplineGrids.jl/dev/examples_optics/), [differential equation solving](https://southendmusic.github.io/SplineGrids.jl/dev/examples_pde/) (isogeometric analysis?) and machine learning. Since SplineGrids.jl makes heavy use of in-place computations, the recommended automatic differentiation framework to use with SplineGrids.jl is [Enzyme](https://github.com/EnzymeAD/Enzyme.jl).

**Background**  
This package was inspired by research I did on lens design with differentiable ray-tracing a few years ago, see the repo README for more details on that.

**Why a new spline package?**  
There already are several spline packages for Julia, here’s an undoubtedly incomplete list:

- [sp94/CubicSplines.jl: Cubic splines for Julia](https://github.com/sp94/CubicSplines.jl)
- [jipolanco/BSplineKit.jl: A collection of B-spline tools in Julia](https://github.com/jipolanco/BSplineKit.jl)
- [HoBeZwe/NURBS.jl: This package provides functionality to define and evaluate B-spline and NURBS (non-uniform rational B-spline) basis functions, their derivatives, as well as curves and surfaces based on both considered basis functions.](https://github.com/HoBeZwe/NURBS.jl)
- [hyrodium/BasicBSpline.jl: Basic (mathematical) operations for B-spline functions and related things with julia](https://github.com/hyrodium/BasicBSpline.jl)

What I think make this new package stand out are:

- The `KernelAbstractions.jl` backend for efficient parallelism
- The flexibility in input and output dimensionality
- The efficient grid evaluation
- Local refinement support (coming up)

**A note on grid evaluation**  
The grid evaluation is quite fundamental to this package. Evaluating the geometry at arbitrary points is not a priority, but might be added down the road as a convenience.

**Roadmap**  
I’m currently working out local refinement and an issue with Enzyme when using `CUDABackend`. After that I’ll register the package.

I’d love to hear what you think of this package and how it can be made more useful for your usecase!

---

<div class="post-metadata">

**Author:** ![BdeKoning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdekoning/32/214557_2.png) [@BdeKoning](https://discourse.julialang.org/u/BdeKoning)\
**Post date:** [January 7, 2025, 7:51am UTC](https://discourse.julialang.org/t/pre-ann-splinegrids-jl-efficient-evaluation-of-spline-nurbs-geometries-of-any-dimensionality/124459/2 "2025-01-07T07:51:08Z")

</div>

![MergeResult_2025_01_07_07_32_37](https://global.discourse-cdn.com/julialang/original/3X/6/2/629cefd10481bd4b37a4c6836e3e76c20b69240b.png)

---

<div class="post-metadata">

**Author:** ![tp2750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tp2750/32/207806_2.png) [@tp2750](https://discourse.julialang.org/u/tp2750)\
**Post date:** [January 14, 2025, 11:37pm UTC](https://discourse.julialang.org/t/pre-ann-splinegrids-jl-efficient-evaluation-of-spline-nurbs-geometries-of-any-dimensionality/124459/3 "2025-01-14T23:37:24Z")

</div>

Very cool!  
Can this be used to fit smoothing splines ([Smoothing spline - Wikipedia](https://en.m.wikipedia.org/wiki/Smoothing_spline))?

---

<div class="post-metadata">

**Author:** ![BdeKoning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdekoning/32/214557_2.png) [@BdeKoning](https://discourse.julialang.org/u/BdeKoning)\
**Post date:** [January 15, 2025, 5:41am UTC](https://discourse.julialang.org/t/pre-ann-splinegrids-jl-efficient-evaluation-of-spline-nurbs-geometries-of-any-dimensionality/124459/4 "2025-01-15T05:41:13Z")

</div>

Thanks!

I wasn’t familiar with that concept but I did a quick read.

To do this it seems you have to evaluate the spline in your observation points. In 1D a ‘grid’ is trivial so this works fine. In higher dimensions this would only be efficient if your observations have a grid structure.

So in short: it’s not inplemented but I think possible under the grid constraint
