FieldHermiteInterpolator { public void addSamplePoint(final T x, final T[] ... value) throws ZeroException, MathArithmeticException, DimensionMismatchException, NullArgumentException { MathUtils.checkNotNull(x); T factorial = x.getField().getOne(); for (int i = 0; i < value.length; ++i) { final T[] y = value[i].clone(); if (i > 1) { factorial = factorial.multiply(i); final T inv = factorial.reciprocal(); for (int j = 0; j < y.length; ++j) { y[j] = y[j].multiply(inv); } } final int n = abscissae.size(); bottomDiagonal.add(n - i, y); T[] bottom0 = y; for (int j = i; j < n; ++j) { final T[] bottom1 = bottomDiagonal.get(n - (j + 1)); if (x.equals(abscissae.get(n - (j + 1)))) { throw new ZeroException(LocalizedFormats.DUPLICATED_ABSCISSA_DIVISION_BY_ZERO, x); } final T inv = x.subtract(abscissae.get(n - (j + 1))).reciprocal(); for (int k = 0; k < y.length; ++k) { bottom1[k] = inv.multiply(bottom0[k].subtract(bottom1[k])); } bottom0 = bottom1; } topDiagonal.add(bottom0.clone()); abscissae.add(x); } } FieldHermiteInterpolator(); void addSamplePoint(final T x, final T[] ... value); T[] value(T x); T[][] derivatives(T x, int order);  }
@Test(expected=IllegalArgumentException.class) public void testDuplicatedAbscissa() { FieldHermiteInterpolator<BigFraction> interpolator = new FieldHermiteInterpolator<BigFraction>(); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(0) }); interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(1) }); }