bspline-fortran
bspline-fortran copied to clipboard
Is there a way to impose boundary condition (like derivatives at the edges) with this module?
I believe you can do that by specifying your own knot sequence? You can do this using the subroutine interface (see, for example, the comments in the db2ink
routine in bspline_sub_module.f90
(you set iflag=1
, and provide your own tx
and ty
arrays.
I still can't figure this out. Say a 1d spline interpolated by (x1, y1) (x2, y2) ... (xn, yn) that I want to set its left/right bound derivative (i.e. at x1, xn) to a/b, respectively. How shall I set the knots to achieve that?
I'm not sure. You may have to check the references given in the core routines. I've only ever used the default (not-a-knot) end conditions.
Note: as of 4.1.0
you can now set the knots from the object-oriented interface also.
~~I'm pretty sure you can't do this by modifying the knot vector alone.~~
Edit:
Need to look into this again. The dbint4()
routine from CMLIB might give some inspiration.
Very interesting, I don't think I noticed this routine before. I think we could definitely use it...
dbint4
is hardcoded to fourth-order, which we probably want to change.
In terms of actual end conditions, it would be great to be able to set first or second derivatives directly (as is possible in dbint4
). Periodic boundary conditions would also be extremely useful for me.
For the OO interface, some shortcuts could be great, for example a simple flag that gives a natural spline (second derivatives zero at the ends), or specifying periodicity in individual dimensions.
Not sure how far the original CMLIB routines can help us here, but for more advanced applications, we might be able to leverage some of Dierckx's FITPACK routines.
As for the dbink4
routine, I've got some experiments going on the dbink4
branch. I'll get it hooked up and working just for 1D and 4th order so I can test it out. Then I can look into the details of:
- how to generalize it for an order
- how to call it for any dimension (2D-6D)
I think both are doable.
Just a feature request along this:
:+1: for periodic boundary conditions
Hi Jacob, thanks for this library, it's almost exactly what I need for smooth 4D interpolation. Is there any chance of being able to specify natural boundary conditions (second derivative zero at ends) in the near future?
No promises, but I have started to get back to looking into this.