Spline fitting functions