double interpolated;
// Natural spline
CubicInterpolation f = new CubicInterpolation(
RPN15A_x, RPN15A_y,
CubicInterpolation.DerivativeApprox.Spline, false,
CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0,
CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0);
f.update();
checkValues("Natural spline", f, RPN15A_x, RPN15A_y);
check2ndDerivativeValue("Natural spline", f, RPN15A_x.first(), 0.0);
check2ndDerivativeValue("Natural spline", f, RPN15A_x.last(), 0.0);
// poor performance
final double x_bad = 11.0;
interpolated = f.op(x_bad);
assertFalse("Natural spline interpolation poor performance unverified"
+"\n at x = "+x_bad
+"\n interpolated value: "+interpolated
+"\n expected value > 1.0",
interpolated<1.0);
// Clamped spline
f = new CubicInterpolation(
RPN15A_x, RPN15A_y,
CubicInterpolation.DerivativeApprox.Spline, false,
CubicInterpolation.BoundaryCondition.FirstDerivative, 0.0,
CubicInterpolation.BoundaryCondition.FirstDerivative, 0.0);
f.update();
checkValues("Clamped spline", f, RPN15A_x, RPN15A_y);
check1stDerivativeValue("Clamped spline", f, RPN15A_x.first(), 0.0);
check1stDerivativeValue("Clamped spline", f, RPN15A_x.last(), 0.0);
// poor performance
interpolated = f.op(x_bad);
assertFalse("Clamped spline interpolation poor performance unverified"
+"\n at x = "+x_bad
+"\n interpolated value: "+interpolated
+"\n expected value > 1.0",
interpolated<1.0);
// Not-a-knot spline
f = new CubicInterpolation(
RPN15A_x, RPN15A_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, RPN15A_x, RPN15A_y);
checkNotAKnotCondition("Not-a-knot spline", f);
// poor performance
interpolated = f.op(x_bad);
assertFalse("Not-a-knot spline interpolation poor performance unverified"
+"\n at x = "+x_bad
+"\n interpolated value: "+interpolated
+"\n expected value > 1.0",
interpolated<1.0);
// MC natural spline values
f = new CubicInterpolation(
RPN15A_x, RPN15A_y,
CubicInterpolation.DerivativeApprox.Spline, true,
CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0,
CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0);
f.update();
checkValues("MC natural spline", f, RPN15A_x, RPN15A_y);
// good performance
interpolated = f.op(x_bad);
assertFalse("MC natural spline interpolation good performance unverified"
+"\n at x = "+x_bad
+"\n interpolated value: "+interpolated
+"\n expected value > 1.0",
interpolated>1.0);
// MC clamped spline values
f = new CubicInterpolation(
RPN15A_x, RPN15A_y,
CubicInterpolation.DerivativeApprox.Spline, true,
CubicInterpolation.BoundaryCondition.FirstDerivative, 0.0,
CubicInterpolation.BoundaryCondition.FirstDerivative, 0.0);
f.update();
checkValues("MC clamped spline", f, RPN15A_x, RPN15A_y);
check1stDerivativeValue("MC clamped spline", f, RPN15A_x.first(), 0.0);
check1stDerivativeValue("MC clamped spline", f, RPN15A_x.last(), 0.0);
// good performance
interpolated = f.op(x_bad);
assertFalse("MC clamped spline interpolation good performance unverified"
+"\n at x = "+x_bad
+"\n interpolated value: "+interpolated
+"\n expected value > 1.0",
interpolated>1.0);
// MC not-a-knot spline values
f = new CubicInterpolation(
RPN15A_x, RPN15A_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, RPN15A_x, RPN15A_y);
// good performance
interpolated = f.op(x_bad);
assertFalse("MC clamped spline interpolation good performance unverified"
+"\n at x = "+x_bad
+"\n interpolated value: "+interpolated
+"\n expected value > 1.0",
interpolated>1.0);