Interpolator1DDoubleQuadraticDataBundle implements Interpolator1DDataBundle, Serializable { private RealPolynomialFunction1D getQuadratic(final double[] x, final double[] y, final int index) { final double a = y[index]; final double dx1 = x[index] - x[index - 1]; final double dx2 = x[index + 1] - x[index]; final double dy1 = y[index] - y[index - 1]; final double dy2 = y[index + 1] - y[index]; final double b = (dx1 * dy2 / dx2 + dx2 * dy1 / dx1) / (dx1 + dx2); final double c = (dy2 / dx2 - dy1 / dx1) / (dx1 + dx2); return new RealPolynomialFunction1D(new double[] {a, b, c }); } Interpolator1DDoubleQuadraticDataBundle(final Interpolator1DDataBundle underlyingData); RealPolynomialFunction1D getQuadratic(final int index); RealPolynomialFunction1D getQuadraticFirstDerivative(final int index); @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(); @Override void setYValueAtIndex(final int index, final double y); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void testQuadratics() { for (int i = 0; i < (X.length - 2); i++) { RealPolynomialFunction1D quad = DATA.getQuadratic(i); double[] coeff = quad.getCoefficients(); assertTrue(coeff.length == 3); double x = X[i + 1]; assertEquals(2 + 3 * x + 4 * x * x, coeff[0], 0); assertEquals(3 + 2 * 4 * x, coeff[1], 0); assertEquals(4, coeff[2], 0); } }