HermiteInterpolator implements UnivariateDifferentiableVectorFunction { public void addSamplePoint(final double x, final double[] ... value) throws ZeroException, MathArithmeticException { for (int i = 0; i < value.length; ++i) { final double[] y = value[i].clone(); if (i > 1) { double inv = 1.0 / CombinatoricsUtils.factorial(i); for (int j = 0; j < y.length; ++j) { y[j] *= inv; } } final int n = abscissae.size(); bottomDiagonal.add(n - i, y); double[] bottom0 = y; for (int j = i; j < n; ++j) { final double[] bottom1 = bottomDiagonal.get(n - (j + 1)); final double inv = 1.0 / (x - abscissae.get(n - (j + 1))); if (Double.isInfinite(inv)) { throw new ZeroException(LocalizedFormats.DUPLICATED_ABSCISSA_DIVISION_BY_ZERO, x); } for (int k = 0; k < y.length; ++k) { bottom1[k] = inv * (bottom0[k] - bottom1[k]); } bottom0 = bottom1; } topDiagonal.add(bottom0.clone()); abscissae.add(x); } } HermiteInterpolator(); void addSamplePoint(final double x, final double[] ... value); PolynomialFunction[] getPolynomials(); double[] value(double x); DerivativeStructure[] value(final DerivativeStructure x);  }
@Test(expected=IllegalArgumentException.class) public void testDuplicatedAbscissa() { HermiteInterpolator interpolator = new HermiteInterpolator(); interpolator.addSamplePoint(1.0, new double[] { 0.0 }); interpolator.addSamplePoint(1.0, new double[] { 1.0 }); }