/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void shortDataLengthTest() { double[] xValues = new double[] {1. }; double[] yValues = new double[] {4. }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void wrongDatalengthMultiTest() { double[] xValues = new double[] {1., 2., 3. }; double[][] yValues = new double[][] { {1., 2., 3., 4. }, {2., 2., 3., 4. } }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void InfyValuesTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[] yValues = new double[] {1., 2., 3., INF }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void coincideXvaluesMultiTest() { double[] xValues = new double[] {1., 2., 3., 3. }; double[][] yValues = new double[][] { {1., 2., 3., 4. }, {2., 2., 3., 4. } }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void NanOutputTest() { double[] xValues = new double[] {1., 2.e-308, 3.e-308, 4. }; double[] yValues = new double[] {1., 2., 1.e308, 3. }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void NullKeyMultiTest() { double[] xValues = new double[] {1., 2., 3. }; double[][] yValues = new double[][] { {1., 3., 4. }, {2., 3., 1. } }; double[] xKey = new double[3]; xKey = null; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues, xKey); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void NullXvaluesTest() { double[] xValues = new double[4]; double[] yValues = new double[] {1., 2., 3., 4. }; xValues = null; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void NaNxValuesTest() { double[] xValues = new double[] {1., 2., Double.NaN, 4. }; double[] yValues = new double[] {1., 2., 3., 4. }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void coincideXvaluesTest() { double[] xValues = new double[] {1., 2., 3., 3. }; double[] yValues = new double[] {1., 2., 3., 4. }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void NullYvaluesMultiTest() { double[] xValues = new double[] {1., 2., 3., 4. }; double[][] yValues = new double[2][4]; yValues = null; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void shortDataLengthMultiTest() { double[] xValues = new double[] {1. }; double[][] yValues = new double[][] { {4. }, {1. } }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void InfxValuesMultiTest() { double[] xValues = new double[] {1., 2., 3., INF }; double[][] yValues = new double[][] { {1., 2., 3., 4. }, {2., 2., 3., 4. } }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void InfiniteOutputTest() { double[] xValues = new double[] {1.e-308, 2.e-308 }; double[] yValues = new double[] {1., 1.e308 }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void LargeInterpolantsTest() { final double[] xValues = new double[] {1., 2., 3., 4. }; final double[][] yValues = new double[][] { {2., 10., 2., 5. }, {1., 2., 10., 11. } }; NaturalSplineInterpolator interp = new NaturalSplineInterpolator(); interp.interpolate(xValues, yValues[0], 1.e308); }
Bound(DoubleArray xValues, DoubleArray yValues) { super(xValues, yValues); this.xValues = xValues.toArrayUnsafe(); this.yValues = yValues.toArrayUnsafe(); PiecewisePolynomialInterpolator underlying = new NonnegativityPreservingCubicSplineInterpolator(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 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 diffDataMultiTest() { final double[] xValues = new double[] {1., 2., 3., 4. }; final double[][] yValues = new double[][] { {2., 0., 0.1, 0.05, 2. }, {1., 0., 0.1, 1.05, 2. } }; PiecewisePolynomialInterpolator interp = new NaturalSplineInterpolator(); PiecewisePolynomialInterpolator interpPos = new MonotonicityPreservingCubicSplineInterpolator(interp); 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())); }
public void testWrongClampedPoints() { assertThrowsIllegalArg(() -> new ClampedPiecewisePolynomialInterpolator( new NaturalSplineInterpolator(), new double[] {0d }, new double[] {0d, 1d })); assertThrowsIllegalArg(() -> new ClampedPiecewisePolynomialInterpolator( new CubicSplineInterpolator(), new double[] {}, new double[] {})); }
Bound(DoubleArray xValues, DoubleArray yValues) { super(xValues, yValues); ArgChecker.isTrue(xValues.get(0) > 0d || xValues.get(xValues.size() - 1) < 0d, "xValues must have the same sign"); this.xValues = xValues.toArrayUnsafe(); this.yValues = yValues.toArrayUnsafe(); NaturalSplineInterpolator underlying = new NaturalSplineInterpolator(); this.poly = underlying.interpolate(xValues.toArray(), getProduct(this.xValues, this.yValues)); this.polySens = Suppliers.memoize( () -> underlying.interpolateWithSensitivity(xValues.toArray(), getProduct(this.xValues, this.yValues))); }