PCHIPYieldCurveInterpolator1D extends Interpolator1D { @Override public Double interpolate(final Interpolator1DDataBundle data, final Double value) { final double eps = 1e-10; Validate.notNull(value, "value"); Validate.notNull(data, "data bundle"); Validate.isTrue(data instanceof Interpolator1DPiecewisePoynomialDataBundle); final Interpolator1DPiecewisePoynomialDataBundle polyData = (Interpolator1DPiecewisePoynomialDataBundle) data; ArgumentChecker.isFalse(value < 0, "value must be zero or positive"); if (value == 0) { return 0.0; } final double t = Math.max(eps, value); final DoubleMatrix1D res = FUNC.evaluate(polyData.getPiecewisePolynomialResultsWithSensitivity(), t); return res.getEntry(0) / t; }  @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(enabled=false) public void printTest() { System.out.println("PCHIPYieldCurveInterpolator1DTest"); final int nSamples = 201; for (int i = 0; i < nSamples; i++) { final double t = 30.0 * i / ((nSamples - 1)); final double r = INTERPOLATOR.interpolate(DATA, t); System.out.println(t + "\t" + r); } }
@Test public void test() { final int n = T.length; for(int i=1;i<n;i++) { final double r = INTERPOLATOR.interpolate(DATA, T[i]); assertEquals(R[i],r,1e-15); } }