CubicSpline derivatives mixture of natural and specified

(David Rutten) #1

I’m constructing a CubicSpline interpolator through a set of sorted (x,y) coordinates. Some of these coordinates have a first derivative value specified, ie. I need the slope at that sample point to have a specific value, but other points should assume a ‘natural’ first derivative.

I’m assuming I’ll need to use either public CubicSpline(double[] x, double[] c0, double[] c1, double[] c2, double[] c3) or public static CubicSpline InterpolateHermiteSorted(double[] x, double[] y, double[] firstDerivatives) as those are the only creation methods that allow me to specify per-sample derivatives, but how do I get these derivatives?

Is it ok to first compute all natural derivatives, then overwrite the ones I have values for? Is there a way to get this array of natural derivatives without copy-pasting the InterpolateBoundariesSorted method?