Bound(DoubleArray xValues, DoubleArray yValues) { super(xValues, yValues); this.xValues = xValues.toArrayUnsafe(); this.yValues = yValues.toArrayUnsafe(); this.logYValues = getYLogValues(this.yValues); ClampedPiecewisePolynomialInterpolator underlying = new ClampedPiecewisePolynomialInterpolator( new NaturalSplineInterpolator(), new double[] {0d}, new double[] {0d}); this.poly = underlying.interpolate(xValues.toArray(), logYValues); this.polySens = Suppliers.memoize(() -> underlying.interpolateWithSensitivity(xValues.toArray(), logYValues)); }
public void testInterpolate() { for (PiecewisePolynomialInterpolator baseInterp : BASE_INTERP) { ClampedPiecewisePolynomialInterpolator interp = new ClampedPiecewisePolynomialInterpolator(baseInterp, X_CLAMPED, Y_CLAMPED); PiecewisePolynomialResult computed = interp.interpolate(X_VALUES, Y_VALUES); PiecewisePolynomialResult expected = baseInterp.interpolate(X_VALUES_TOTAL, Y_VALUES_TOTAL); assertEquals(computed, expected); assertEquals(interp.getPrimaryMethod(), baseInterp); } }
public void testInterpolateWithSensitivity() { for (PiecewisePolynomialInterpolator baseInterp : BASE_INTERP) { ClampedPiecewisePolynomialInterpolator interp = new ClampedPiecewisePolynomialInterpolator(baseInterp, X_CLAMPED, Y_CLAMPED); PiecewisePolynomialResultsWithSensitivity computed = interp.interpolateWithSensitivity(X_VALUES, Y_VALUES); PiecewisePolynomialResultsWithSensitivity expected = baseInterp.interpolateWithSensitivity(X_VALUES_TOTAL, Y_VALUES_TOTAL); assertEquals(computed, expected); } }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testInterpolateMultiDim() { ClampedPiecewisePolynomialInterpolator interp = new ClampedPiecewisePolynomialInterpolator( new NaturalSplineInterpolator(), new double[] {1d }, new double[] {2d }); interp.interpolate(X_VALUES, new double[][] {Y_VALUES, Y_VALUES }); }
public void testWrongClampedPoints() { assertThrowsIllegalArg(() -> new ClampedPiecewisePolynomialInterpolator( new NaturalSplineInterpolator(), new double[] {0d }, new double[] {0d, 1d })); assertThrowsIllegalArg(() -> new ClampedPiecewisePolynomialInterpolator( new CubicSplineInterpolator(), new double[] {}, new double[] {})); }
@Override public PiecewisePolynomialResult interpolate(double[] xValues, double[] yValues) { ArgChecker.notNull(xValues, "xValues"); ArgChecker.notNull(yValues, "yValues"); ArgChecker.isTrue(xValues.length == yValues.length, "xValues length = yValues length"); double[][] xyValuesAll = getDataTotal(xValues, yValues); return _baseMethod.interpolate(xyValuesAll[0], xyValuesAll[1]); }
new ClampedPiecewisePolynomialInterpolator(BASE_INTERP[0], new double[] {0d }, new double[] {0d }); PiecewisePolynomialResult result = interp.interpolate(xValues, rt); PiecewisePolynomialFunction1D polyFunc = new PiecewisePolynomialFunction1D(); for (int i = 0; i < 600; ++i) {
@Override public PiecewisePolynomialResultsWithSensitivity interpolateWithSensitivity(double[] xValues, double[] yValues) { ArgChecker.notNull(xValues, "xValues"); ArgChecker.notNull(yValues, "yValues"); ArgChecker.isTrue(xValues.length == yValues.length, "xValues length = yValues length"); double[][] xyValuesAll = getDataTotal(xValues, yValues); return _baseMethod.interpolateWithSensitivity(xyValuesAll[0], xyValuesAll[1]); }