Interpolator1DCubicSplineDataBundle implements Interpolator1DDataBundle, Serializable { public double[] getSecondDerivatives() { if (_secondDerivatives == null) { _secondDerivatives = calculateSecondDerivative(); } return _secondDerivatives; } Interpolator1DCubicSplineDataBundle(final Interpolator1DDataBundle underlyingData);  Interpolator1DCubicSplineDataBundle(final Interpolator1DDataBundle underlyingData, final double leftGrad, final double rightGrad); @Override boolean containsKey(final Double key); @Override Double firstKey(); @Override Double firstValue(); @Override Double get(final Double key); @Override InterpolationBoundedValues getBoundedValues(final Double key); @Override double[] getKeys(); @Override int getLowerBoundIndex(final Double value); @Override Double getLowerBoundKey(final Double value); @Override double[] getValues(); @Override Double higherKey(final Double key); @Override Double higherValue(final Double key); @Override Double lastKey(); @Override Double lastValue(); @Override int size(); double[] getSecondDerivatives(); double[][] getSecondDerivativesSensitivities(); @Override void setYValueAtIndex(final int index, final double y); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void testSecondDerivatives() { int n = 10; double x[] = new double[n]; double y[] = new double[n]; for (int i = 0; i < n; i++) { x[i] = (i - 5); y[i] = LINEAR.evaluate(x[i]); } Interpolator1DCubicSplineDataBundle data = new Interpolator1DCubicSplineDataBundle( new ArrayInterpolator1DDataBundle(x, y)); double[] y2 = data.getSecondDerivatives(); assertEquals(y2.length, 10); assertEquals(y2[0], 0, EPS); assertEquals(y2[y2.length - 1], 0, EPS); for (final double element : y2) { assertEquals(0.0, element, 0.0); } n = 150; x = new double[n]; y = new double[n]; for (int i = 0; i < n; i++) { x[i] = (i - 75) / 10.; y[i] = NORMAL.evaluate(x[i]); } data = new Interpolator1DCubicSplineDataBundle(new ArrayInterpolator1DDataBundle(x, y)); y2 = data.getSecondDerivatives(); for (int i = 0; i < n; i++) { final double temp = (x[i] * x[i] - 1) * Math.exp(-x[i] * x[i] / 2.0); assertEquals(temp, y2[i], 1e-2); } }