/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void coincideDataMultiTest() { final double[] xValues = new double[] {1., 2., 2. }; final double[][] yValues = new double[][] { {0., 0.1, 0.05 }, {0., 0.1, 1.05 } }; PiecewisePolynomialInterpolator interpPos = new ConstrainedCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
Bound(DoubleArray xValues, DoubleArray yValues) { super(xValues, yValues); this.xValues = xValues.toArrayUnsafe(); this.yValues = yValues.toArrayUnsafe(); PiecewisePolynomialInterpolator underlying = new NaturalSplineInterpolator(); this.poly = underlying.interpolate(xValues.toArray(), yValues.toArray()); this.polySens = Suppliers.memoize(() -> underlying.interpolateWithSensitivity(xValues.toArray(), yValues.toArray())); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void infYdataMultiTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[][] yValues = new double[][] { {0.1, 0.05, 0.2, 1. }, {0.1, 0.05, 0.2, INF } }; PiecewisePolynomialInterpolator interpPos = new ConstrainedCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
Bound(DoubleArray xValues, DoubleArray yValues) { super(xValues, yValues); this.xValues = xValues.toArrayUnsafe(); this.yValues = yValues.toArrayUnsafe(); this.logYValues = getYLogValues(this.yValues); PiecewisePolynomialInterpolator underlying = new MonotonicityPreservingCubicSplineInterpolator(new LogNaturalSplineHelper()); this.poly = underlying.interpolate(xValues.toArray(), logYValues); this.polySens = Suppliers.memoize(() -> underlying.interpolateWithSensitivity(xValues.toArray(), logYValues)); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nanXdataMultiTest() { double[] xValues = new double[] {1., 2., 3., Double.NaN }; double[][] yValues = new double[][] { {0., 0.1, 0.05, 0.2 }, {0., 0.1, 0.05, 0.2 } }; PiecewisePolynomialInterpolator interpPos = new ConstrainedCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void coincideDataTest() { final double[] xValues = new double[] {1., 1., 3. }; final double[] yValues = new double[] {0., 0.1, 0.05 }; PiecewisePolynomialInterpolator interpPos = new SemiLocalCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void coincideDataMultiTest() { final double[] xValues = new double[] {1., 2., 2. }; final double[][] yValues = new double[][] { {0., 0.1, 0.05 }, {0., 0.1, 1.05 } }; PiecewisePolynomialInterpolator interpPos = new SemiLocalCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void infXdataMultiTest() { double[] xValues = new double[] {1., 2., 3., INF }; double[][] yValues = new double[][] { {0., 0.1, 0.05, 0.2 }, {0., 0.1, 0.05, 0.2 } }; PiecewisePolynomialInterpolator interpPos = new SemiLocalCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void infYdataMultiTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[][] yValues = new double[][] { {0.1, 0.05, 0.2, 1. }, {0.1, 0.05, 0.2, INF } }; PiecewisePolynomialInterpolator interpPos = new SemiLocalCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void notReconnectedMultiTest() { double[] xValues = new double[] {1., 2., 4., 2.0000000001 }; double[][] yValues = new double[][] {{2., 3., 500000000., 400. } }; PiecewisePolynomialInterpolator interpPos = new SemiLocalCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nanYdataTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[] yValues = new double[] {0.1, 0.05, 0.2, Double.NaN }; PiecewisePolynomialInterpolator interpPos = new ConstrainedCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void notReconnectedTest() { double[] xValues = new double[] {1., 2., 2.0000001, 4. }; double[] yValues = new double[] {2., 3., 40000000., 5. }; PiecewisePolynomialInterpolator interpPos = new ConstrainedCubicSplineInterpolator(); interpPos.interpolate(xValues, yValues); }
/** * Interpolate. * * @param xValues the values * @param yValuesMatrix the matrix * @param x the x * @return Values of the underlying cubic spline functions interpolating {yValuesMatrix.RowVectors} at the value of x */ public DoubleArray interpolate(final double[] xValues, final double[][] yValuesMatrix, final double x) { DoubleMatrix matrix = DoubleMatrix.copyOf(yValuesMatrix); return DoubleArray.of(matrix.rowCount(), i -> interpolate(xValues, matrix.rowArray(i), x)); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullYdataTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[] yValues = new double[] {0., 0.1, 0.05, 0.2 }; yValues = null; PiecewisePolynomialInterpolator interp = new CubicSplineInterpolator(); PiecewisePolynomialInterpolator interpPos = new NonnegativityPreservingCubicSplineInterpolator(interp); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullXdataMultiTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[][] yValues = new double[][] { {0., 0.1, 0.05, 0.2 }, {0., 0.1, 0.05, 0.2 } }; xValues = null; PiecewisePolynomialInterpolator interp = new CubicSplineInterpolator(); PiecewisePolynomialInterpolator interpPos = new NonnegativityPreservingCubicSplineInterpolator(interp); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nanYdataTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[] yValues = new double[] {0., 0., 0.1, 0.05, 0.2, Double.NaN }; PiecewisePolynomialInterpolator interp = new CubicSplineInterpolator(); PiecewisePolynomialInterpolator interpPos = new NonnegativityPreservingCubicSplineInterpolator(interp); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nanXdataMultiTest() { double[] xValues = new double[] {1., 2., 3., Double.NaN }; double[][] yValues = new double[][] { {0., 0.1, 0.05, 0.2 }, {0., 0.1, 0.05, 0.2 } }; PiecewisePolynomialInterpolator interp = new CubicSplineInterpolator(); PiecewisePolynomialInterpolator interpPos = new NonnegativityPreservingCubicSplineInterpolator(interp); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void diffDataTest() { final double[] xValues = new double[] {1., 2., 3., 4. }; final double[] yValues = new double[] {0., 0.1, 0.05 }; PiecewisePolynomialInterpolator interp = new NaturalSplineInterpolator(); PiecewisePolynomialInterpolator interpPos = new MonotonicityPreservingCubicSplineInterpolator(interp); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullXdataTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[] yValues = new double[] {0., 0.1, 0.05, 0.2 }; xValues = null; PiecewisePolynomialInterpolator interp = new CubicSplineInterpolator(); PiecewisePolynomialInterpolator interpPos = new MonotonicityPreservingCubicSplineInterpolator(interp); interpPos.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullYdataMultiTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[][] yValues = new double[][] { {0., 0.1, 0.05, 0.2 }, {0., 0.1, 0.05, 0.2 } }; yValues = null; PiecewisePolynomialInterpolator interp = new CubicSplineInterpolator(); PiecewisePolynomialInterpolator interpPos = new MonotonicityPreservingCubicSplineInterpolator(interp); interpPos.interpolate(xValues, yValues); }