/** * dim must be 1 for evaluateAndDifferentiate. */ @Test(expectedExceptions = UnsupportedOperationException.class) public void dimFailTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf(new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); int dim = 2; int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.evaluateAndDifferentiate(pp, 1.5); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void infxIntTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {1., 0., 0., 0. }, {1., 3., 3., 1. } }); double[][] xKeys = new double[][] { {INF, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 1; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.integrate(pp, 1., xKeys[0][0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void NaNxIntMultiTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {1., 0., 0., 0. }, {1., 3., 3., 1. } }); double[] xKeys = new double[] {1.5, 7. / 3., 29. / 7., Double.NaN }; final int dim = 1; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.integrate(pp, 1., xKeys); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void infxEvaluateMatrixTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); double[][] xKeys = new double[][] { {-2, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., INF } }; final int dim = 2; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.evaluate(pp, xKeys); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void NaNxEvaluateMultiTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); double[][] xKeys = new double[][] { {-2, 1, Double.NaN, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 2; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.evaluate(pp, xKeys[0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullDimIntMultiTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); double[] xKeys = new double[] {-2, 1, 2, 2.5 }; final int dim = 2; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.integrate(pp, 1., xKeys); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void infxIntMultiTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {1., 0., 0., 0. }, {1., 3., 3., 1. } }); double[] xKeys = new double[] {1.5, 7. / 3., 29. / 7., INF }; final int dim = 1; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.integrate(pp, 1., xKeys); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void NaNxIntTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {1., 0., 0., 0. }, {1., 3., 3., 1. } }); double[][] xKeys = new double[][] { {Double.NaN, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 1; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.integrate(pp, 1., xKeys[0][0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void constFuncDiffTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {-1 }, {20 }, {0. }, {5 }, {1. }, {0. } }); double[] xKeys = new double[] {-2, 1, 2, 2.5 }; final int dim = 2; final int nCoefs = 1; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.differentiate(pp, xKeys[0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullxEvaluateMatrixTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); double[][] xKeys = new double[][] { {-2, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 2; final int nCoefs = 4; xKeys = null; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.evaluate(pp, xKeys); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void constFuncDiffMultiTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {-1 }, {20 }, {0. }, {5 }, {1. }, {0. } }); double[] xKeys = new double[] {-2, 1, 2, 2.5 }; final int dim = 2; final int nCoefs = 1; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.differentiate(pp, xKeys); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void linearFuncDiffTwiceTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3. }, {0., 5. }, {1., 0. }, {0., 5. }, {1., 3. }, {0., 5. } }); double[] xKeys = new double[] {-2, 1, 2, 2.5 }; final int dim = 2; final int nCoefs = 2; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.differentiateTwice(pp, xKeys[0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void linearFuncDiffTwiceMultiTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3. }, {0., 5. }, {1., 0. }, {0., 5. }, {1., 3. }, {0., 5. } }); double[] xKeys = new double[] {-2, 1, 2, 2.5 }; final int dim = 2; final int nCoefs = 2; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.differentiateTwice(pp, xKeys); }
/** * Error tests below */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullpEvaluateTest() { final DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); final double[][] xKeys = new double[][] { {-2, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 2; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); pp = null; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.evaluate(pp, xKeys[0][0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullpEvaluateMatrixTest() { final DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); final double[][] xKeys = new double[][] { {-2, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 2; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); pp = null; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.evaluate(pp, xKeys); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullpDifferentiateTest() { final DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); final double[][] xKeys = new double[][] { {-2, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 2; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); pp = null; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.differentiate(pp, xKeys[0][0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullpDifferentiateMultiTest() { final DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); final double[][] xKeys = new double[][] { {-2, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 2; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); pp = null; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.differentiate(pp, xKeys[0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullpIntegrateTest() { final DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {1., 0., 0., 0. }, {1., 3., 3., 1. } }); final double[][] xKeys = new double[][] { {-2, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 1; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); pp = null; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.integrate(pp, 1., xKeys[0][0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void infxEvaluateMultiTest() { DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {0., 5., -20., 20 }, {1., 0., 0., 0. }, {0., 5., -10., 5 }, {1., 3., 3., 1. }, {0., 5., 0., 0. } }); double[][] xKeys = new double[][] { {-2, 1, INF, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 2; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.evaluate(pp, xKeys[0]); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullpIntegrateMultiTest() { final DoubleMatrix coefsMatrix = DoubleMatrix.copyOf( new double[][] { {1., -3., 3., -1 }, {1., 0., 0., 0. }, {1., 3., 3., 1. } }); final double[][] xKeys = new double[][] { {-2, 1, 2, 2.5 }, {1.5, 7. / 3., 29. / 7., 5. } }; final int dim = 1; final int nCoefs = 4; PiecewisePolynomialResult pp = new PiecewisePolynomialResult(X_VALUES, coefsMatrix, nCoefs, dim); pp = null; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); function.integrate(pp, 1., xKeys[0]); }