bgrimstad / splinter

Library for multivariate function approximation with splines (B-spline, P-spline, and more) with interfaces to C++, C, Python and MATLAB
Mozilla Public License 2.0
416 stars 116 forks source link

More B-spline end conditions #22

Open bgrimstad opened 9 years ago

bgrimstad commented 9 years ago

Implement new end conditions for the B-spline, e.g. Hermite and Natural end conditions.

wolfgangp commented 7 years ago

Hi. I'm wondering what end conditions are available right now for (3rd degree) B-splines in splinter? I'd need interpolation equivalent to a cubic spline with not-a-knot end conditions. Where in splinter would new end conditions be implemented? P.S. I'm not very familiar with the subject of splines, but would be happy to work on a contribution regarding this.

bgrimstad commented 7 years ago

Hi.

Currently, the only supported end condition is the free end condition (also known as not-a-knot). This end condition follows implicitly when knot vectors are set using the AS_SAMPLED keyword, which is the default setting.

The free end condition is normally used with cubic splines to ensure continuous third derivatives close to the boundaries. We have attempted to simplify things for the user so this end condition may also be used (in a modified form) with splines of other degrees, although it no longer holds the same meaning as for the cubic case. I can understand that this may be confusing for the user.

I am planning to rewrite the code that handles knot vectors and possibly extend the fit function to accept other end conditions. This code currently resides in the files bspline_builder. and knot_utils. (please refer to the multidim-control-points branch, which is far ahead of the master and develop branch at this moment).

I suggest that we consider supporting the following end conditions:

  1. Hermite / clamped (fixed derivatives, specified by user)
  2. Natural (second-derivatives set to zero)
  3. Free / not-a-knot (continuous third derivatives - supported today)
  4. Periodic (equal first derivatives at boundaries and equal second derivatives at boundaries)

A warning: The fact that we have implemented tensor product B-splines, for any number of variables (x_dim), may complicate the implementation of other end conditions. In particular, we will have to consider 2^(x_dim) boundary/corner points.

If you want to read more about splines, I would suggest the following book, which is used to teach a course at the University in Oslo (see Ch. 5 about cubic spline interpolation, and p. 125 about end conditions). Spline Methods

wolfgangp commented 7 years ago

Hi. Thank you for your kind explanation. As splinter does exactly what I need, I will happily continue to use this fine library. Cheers