PCHIPInterpolator1D extends Interpolator1D { @Override public Double interpolate(final Interpolator1DDataBundle data, final Double value) { Validate.notNull(value, "value"); Validate.notNull(data, "data bundle"); Validate.isTrue(data instanceof Interpolator1DPiecewisePoynomialDataBundle); final Interpolator1DPiecewisePoynomialDataBundle polyData = (Interpolator1DPiecewisePoynomialDataBundle) data; final DoubleMatrix1D res = FUNC.evaluate(polyData.getPiecewisePolynomialResultsWithSensitivity(), value); return res.getEntry(0); }  @Override Double interpolate(final Interpolator1DDataBundle data, final Double value); @Override double firstDerivative(final Interpolator1DDataBundle data, final Double value); @Override double[] getNodeSensitivitiesForValue(final Interpolator1DDataBundle data, final Double value); @Override Interpolator1DDataBundle getDataBundle(final double[] x, final double[] y); @Override Interpolator1DDataBundle getDataBundleFromSortedArrays(final double[] x, final double[] y);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullData() { INTERPOLATOR.interpolate(null, 2.3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullValue() { INTERPOLATOR.interpolate(DATA, null); }
@Test public void montonicTest() { final boolean print = false; if (print) { System.out.println("MonotonicCubicInterpolator1DTest"); } final int n = 100; final double low = X_DATA[0]; final double range = X_DATA[X_DATA.length - 1] - X_DATA[0]; double value = INTERPOLATOR.interpolate(DATA, low); for (int i = 1; i < n; i++) { double x = low + i * range / (n - 1); double y = INTERPOLATOR.interpolate(DATA, x); assertTrue(y > value); value = y; if (print) { System.out.println(x + "\t" + y); } } }