final int n = 4;
final Array x = xRange(-2.0, 2.0, n);
final Array y = parabolic(x);
// Not-a-knot spline
CubicInterpolation f = new CubicInterpolation(
x, y,
CubicInterpolation.DerivativeApprox.Spline, false,
CubicInterpolation.BoundaryCondition.NotAKnot, Constants.NULL_REAL,
CubicInterpolation.BoundaryCondition.NotAKnot, Constants.NULL_REAL);
f.update();
checkValues("Not-a-knot spline", f, x, y);
check1stDerivativeValue("Not-a-knot spline", f, x.get(0), 4.0);
check1stDerivativeValue("Not-a-knot spline", f, x.get(n-1), -4.0);
check2ndDerivativeValue("Not-a-knot spline", f, x.get(0), -2.0);
check2ndDerivativeValue("Not-a-knot spline", f, x.get(n-1), -2.0);
// Clamped spline
f = new CubicInterpolation(
x, y,
CubicInterpolation.DerivativeApprox.Spline, false,
CubicInterpolation.BoundaryCondition.FirstDerivative, 4.0,
CubicInterpolation.BoundaryCondition.FirstDerivative, -4.0);
f.update();
checkValues("Clamped spline", f, x, y);
check1stDerivativeValue("Clamped spline", f, x.get(0), 4.0);
check1stDerivativeValue("Clamped spline", f, x.get(n-1), -4.0);
check2ndDerivativeValue("Clamped spline", f, x.get(0), -2.0);
check2ndDerivativeValue("Clamped spline", f, x.get(n-1), -2.0);
// SecondDerivative spline
f = new CubicInterpolation(
x, y,
CubicInterpolation.DerivativeApprox.Spline, false,
CubicInterpolation.BoundaryCondition.SecondDerivative, -2.0,
CubicInterpolation.BoundaryCondition.SecondDerivative, -2.0);
f.update();
checkValues("SecondDerivative spline", f, x, y);
check1stDerivativeValue("SecondDerivative spline", f, x.get(0), 4.0);
check1stDerivativeValue("SecondDerivative spline", f, x.get(n-1), -4.0);
check2ndDerivativeValue("SecondDerivative spline", f, x.get(0), -2.0);
check2ndDerivativeValue("SecondDerivative spline", f, x.get(n-1), -2.0);
// MC Not-a-knot spline
f = new CubicInterpolation(
x, y,
CubicInterpolation.DerivativeApprox.Spline, true,
CubicInterpolation.BoundaryCondition.NotAKnot, Constants.NULL_REAL,
CubicInterpolation.BoundaryCondition.NotAKnot, Constants.NULL_REAL);
f.update();
checkValues("MC Not-a-knot spline", f, x, y);
check1stDerivativeValue("MC Not-a-knot spline", f, x.get(0), 4.0);
check1stDerivativeValue("MC Not-a-knot spline", f, x.get(n-1), -4.0);
check2ndDerivativeValue("MC Not-a-knot spline", f, x.get(0), -2.0);
check2ndDerivativeValue("MC Not-a-knot spline", f, x.get(n-1), -2.0);
// MC Clamped spline
f = new CubicInterpolation(
x, y,
CubicInterpolation.DerivativeApprox.Spline, true,
CubicInterpolation.BoundaryCondition.FirstDerivative, 4.0,
CubicInterpolation.BoundaryCondition.FirstDerivative, -4.0);
f.update();
checkValues("MC Clamped spline", f, x, y);
check1stDerivativeValue("MC Clamped spline", f, x.get(0), 4.0);
check1stDerivativeValue("MC Clamped spline", f, x.get(n-1), -4.0);
check2ndDerivativeValue("MC Clamped spline", f, x.get(0), -2.0);
check2ndDerivativeValue("MC Clamped spline", f, x.get(n-1), -2.0);
// MC SecondDerivative spline
f = new CubicInterpolation(
x, y,
CubicInterpolation.DerivativeApprox.Spline, true,
CubicInterpolation.BoundaryCondition.SecondDerivative, -2.0,
CubicInterpolation.BoundaryCondition.SecondDerivative, -2.0);
f.update();
checkValues("MC SecondDerivative spline", f, x, y);
check1stDerivativeValue("MC SecondDerivative spline", f, x.get(0), 4.0);
check1stDerivativeValue("MC SecondDerivative spline", f, x.get(n-1), -4.0);
check2ndDerivativeValue("SecondDerivative spline", f, x.get(0), -2.0);
check2ndDerivativeValue("MC SecondDerivative spline", f, x.get(n-1), -2.0);