int order0 = pp.getOrder()[0]; int order1 = pp.getOrder()[1]; ArgChecker.isFalse(order0 < 3, "polynomial degree of x0 < 2"); DoubleArray knots0 = pp.getKnots0(); DoubleArray knots1 = pp.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); DoubleMatrix[][] coefs = pp.getCoefs(); PiecewisePolynomialResult2D ppDiff = new PiecewisePolynomialResult2D( knots0, knots1, res, new int[] {order0 - 2, order1});
ArgChecker.isFalse(Double.isInfinite(x1Key), "x1Key containing Infinity"); DoubleArray knots0 = result.getKnots0(); DoubleArray knots1 = result.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); double res = getValue(result.getCoefs()[ind0][ind1], x0Key, x1Key, knots0.get(ind0), knots1.get(ind1));
assertEquals(result.getNumberOfIntervals()[0], n0IntExp); assertEquals(result.getNumberOfIntervals()[1], n1IntExp); assertEquals(result.getOrder()[0], orderExp); assertEquals(result.getOrder()[1], orderExp); assertEquals(result.getKnots0().get(i), x0Values[i], ref * EPS); assertEquals(result.getKnots2D().get(0).get(i), x0Values[i], ref * EPS); assertEquals(result.getKnots1().get(i), x1Values[i], ref * EPS); assertEquals(result.getKnots2D().get(1).get(i), x1Values[i], ref * EPS); for (int l = 0; l < orderExp; ++l) { final double ref = Math.abs(coefsExp[i][j].get(k, l)) == 0. ? 1. : Math.abs(coefsExp[i][j].get(k, l)); assertEquals(result.getCoefs()[i][j].get(k, l), coefsExp[i][j].get(k, l), ref * EPS);
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void constDiffX1MultiTest() { PiecewisePolynomialResult2D result = new PiecewisePolynomialResult2D(knots0, knots1, coefsConst, new int[] {1, 1 }); PiecewisePolynomialFunction2D function = new PiecewisePolynomialFunction2D(); final int n0Keys = 21; final int n1Keys = 31; double[] x0Keys = new double[n0Keys]; double[] x1Keys = new double[n1Keys]; for (int i = 0; i < n0Keys; ++i) { x0Keys[i] = 0. + 4. / (n0Keys - 1) * i; } for (int i = 0; i < n1Keys; ++i) { x1Keys[i] = 1. + 3. / (n1Keys - 1) * i; } function.differentiateX1(result, x0Keys, x1Keys); }
assertEquals(result.getNumberOfIntervals()[0], n0IntExp); assertEquals(result.getNumberOfIntervals()[1], n1IntExp); assertEquals(result.getOrder()[0], orderExp); assertEquals(result.getOrder()[1], orderExp); assertEquals(result.getKnots0().get(i), x0Values[i], ref * EPS); assertEquals(result.getKnots2D().get(0).get(i), x0Values[i], ref * EPS); assertEquals(result.getKnots1().get(i), x1Values[i], ref * EPS); assertEquals(result.getKnots2D().get(1).get(i), x1Values[i], ref * EPS); for (int j = 0; j < n1Data - 1; ++j) { final double ref = Math.abs(yValues[i][j]) == 0. ? 1. : Math.abs(yValues[i][j]); assertEquals(result.getCoefs()[i][j].get(orderExp - 1, orderExp - 1), yValues[i][j], ref * EPS);
ArgChecker.isFalse(Double.isInfinite(x1Key), "x1Key containing Infinity"); DoubleArray knots0 = pp.getKnots0(); DoubleArray knots1 = pp.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); double res = getValue(pp.getCoefs()[ind0][ind1], x0Key, x1Key, knots0.get(ind0), knots1.get(ind1));
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void linearDiffTwiceX1MultiTest() { PiecewisePolynomialResult2D result = new PiecewisePolynomialResult2D(knots0, knots1, coefsLin, new int[] {2, 2 }); PiecewisePolynomialFunction2D function = new PiecewisePolynomialFunction2D(); final int n0Keys = 21; final int n1Keys = 31; double[] x0Keys = new double[n0Keys]; double[] x1Keys = new double[n1Keys]; for (int i = 0; i < n0Keys; ++i) { x0Keys[i] = 0. + 4. / (n0Keys - 1) * i; } for (int i = 0; i < n1Keys; ++i) { x1Keys[i] = 1. + 3. / (n1Keys - 1) * i; } function.differentiateTwiceX1(result, x0Keys, x1Keys); }
int order0 = pp.getOrder()[0]; int order1 = pp.getOrder()[1]; ArgChecker.isFalse(order0 < 2, "polynomial degree of x0 < 1"); DoubleArray knots0 = pp.getKnots0(); DoubleArray knots1 = pp.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); DoubleMatrix[][] coefs = pp.getCoefs(); PiecewisePolynomialResult2D ppDiff = new PiecewisePolynomialResult2D( knots0, knots1, res, new int[] {order0 - 1, order1});
assertEquals(result.getNumberOfIntervals()[0], n0IntExp); assertEquals(result.getNumberOfIntervals()[1], n1IntExp); assertEquals(result.getOrder()[0], orderExp); assertEquals(result.getOrder()[1], orderExp); assertEquals(result.getKnots0().get(i), x0Values[i], ref * EPS); assertEquals(result.getKnots2D().get(0).get(i), x0Values[i], ref * EPS); assertEquals(result.getKnots1().get(i), x1Values[i], ref * EPS); assertEquals(result.getKnots2D().get(1).get(i), x1Values[i], ref * EPS); for (int j = 0; j < n1Data - 1; ++j) { final double ref = Math.abs(yValues[i][j]) == 0. ? 1. : Math.abs(yValues[i][j]); assertEquals(result.getCoefs()[i][j].get(orderExp - 1, orderExp - 1), yValues[i][j], ref * EPS);
DoubleArray knots0 = result.getKnots0(); DoubleArray knots1 = result.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); res[i][j] = getValue(result.getCoefs()[ind0][ind1], x0Keys[i], x1Keys[j], knots0.get(ind0), knots1.get(ind1)); ArgChecker.isFalse(Double.isInfinite(res[i][j]), "Too large input"); ArgChecker.isFalse(Double.isNaN(res[i][j]), "Too large input");
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullPpDiffCrossMultiTest() { PiecewisePolynomialResult2D result = new PiecewisePolynomialResult2D(knots0, knots1, coefs, new int[] {5, 4 }); PiecewisePolynomialFunction2D function = new PiecewisePolynomialFunction2D(); final int n0Keys = 21; final int n1Keys = 31; double[] x0Keys = new double[n0Keys]; double[] x1Keys = new double[n1Keys]; for (int i = 0; i < n0Keys; ++i) { x0Keys[i] = 0. + 4. / (n0Keys - 1) * i; } for (int i = 0; i < n1Keys; ++i) { x1Keys[i] = 1. + 3. / (n1Keys - 1) * i; } result = null; function.differentiateCross(result, x0Keys, x1Keys); }
int order0 = pp.getOrder()[0]; int order1 = pp.getOrder()[1]; ArgChecker.isFalse(order1 < 2, "polynomial degree of x1 < 1"); DoubleArray knots0 = pp.getKnots0(); DoubleArray knots1 = pp.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); DoubleMatrix[][] coefs = pp.getCoefs(); PiecewisePolynomialResult2D ppDiff = new PiecewisePolynomialResult2D( knots0, knots1, res, new int[] {order0, order1 - 1});
assertEquals(result.getNumberOfIntervals()[0], n0IntExp); assertEquals(result.getNumberOfIntervals()[1], n1IntExp); assertEquals(result.getOrder()[0], orderExp); assertEquals(result.getOrder()[1], orderExp); assertEquals(result.getKnots0().get(i), x0Values[i], ref * EPS); assertEquals(result.getKnots2D().get(0).get(i), x0Values[i], ref * EPS); assertEquals(result.getKnots1().get(i), x1Values[i], ref * EPS); assertEquals(result.getKnots2D().get(1).get(i), x1Values[i], ref * EPS); for (int j = 0; j < n1Data - 1; ++j) { double ref = Math.abs(yValues[i][j]) == 0. ? 1. : Math.abs(yValues[i][j]); assertEquals(result.getCoefs()[i][j].get(orderExp - 1, orderExp - 1), yValues[i][j], ref * EPS);
DoubleArray knots0 = pp.getKnots0(); DoubleArray knots1 = pp.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); res[i][j] = getValue(pp.getCoefs()[ind0][ind1], x0Keys[i], x1Keys[j], knots0.get(ind0), knots1.get(ind1)); ArgChecker.isFalse(Double.isInfinite(res[i][j]), "Too large input"); ArgChecker.isFalse(Double.isNaN(res[i][j]), "Too large input");
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nanX1Test() { PiecewisePolynomialResult2D result = new PiecewisePolynomialResult2D(knots0, knots1, coefs, new int[] {5, 4 }); PiecewisePolynomialFunction2D function = new PiecewisePolynomialFunction2D(); final int n0Keys = 21; final int n1Keys = 31; double[] x0Keys = new double[n0Keys]; double[] x1Keys = new double[n1Keys]; for (int i = 0; i < n0Keys; ++i) { x0Keys[i] = 0. + 4. / (n0Keys - 1) * i; } for (int i = 0; i < n1Keys; ++i) { x1Keys[i] = 1. + 3. / (n1Keys - 1) * i; } x1Keys[3] = Double.NaN; function.evaluate(result, x0Keys[3], x1Keys[3]); }
int order0 = pp.getOrder()[0]; int order1 = pp.getOrder()[1]; ArgChecker.isFalse(order1 < 3, "polynomial degree of x1 < 2"); DoubleArray knots0 = pp.getKnots0(); DoubleArray knots1 = pp.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); DoubleMatrix[][] coefs = pp.getCoefs(); PiecewisePolynomialResult2D ppDiff = new PiecewisePolynomialResult2D( knots0, knots1, res, new int[] {order0, order1 - 2});
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void linearDiffTwiceX0Test() { PiecewisePolynomialResult2D result = new PiecewisePolynomialResult2D(knots0, knots1, coefsLin, new int[] {2, 2 }); PiecewisePolynomialFunction2D function = new PiecewisePolynomialFunction2D(); final int n0Keys = 21; final int n1Keys = 31; double[] x0Keys = new double[n0Keys]; double[] x1Keys = new double[n1Keys]; for (int i = 0; i < n0Keys; ++i) { x0Keys[i] = 0. + 4. / (n0Keys - 1) * i; } for (int i = 0; i < n1Keys; ++i) { x1Keys[i] = 1. + 3. / (n1Keys - 1) * i; } function.differentiateTwiceX0(result, x0Keys[0], x1Keys[0]); }
int order0 = pp.getOrder()[0]; int order1 = pp.getOrder()[1]; ArgChecker.isFalse(order0 < 3, "polynomial degree of x0 < 2"); DoubleArray knots0 = pp.getKnots0(); DoubleArray knots1 = pp.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); DoubleMatrix[][] coefs = pp.getCoefs(); PiecewisePolynomialResult2D ppDiff = new PiecewisePolynomialResult2D( knots0, knots1, res, new int[] {order0 - 2, order1});
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void nullPpEvaluateTest() { PiecewisePolynomialResult2D result = new PiecewisePolynomialResult2D(knots0, knots1, coefs, new int[] {5, 4 }); PiecewisePolynomialFunction2D function = new PiecewisePolynomialFunction2D(); final int n0Keys = 21; final int n1Keys = 31; double[] x0Keys = new double[n0Keys]; double[] x1Keys = new double[n1Keys]; for (int i = 0; i < n0Keys; ++i) { x0Keys[i] = 0. + 4. / (n0Keys - 1) * i; } for (int i = 0; i < n1Keys; ++i) { x1Keys[i] = 1. + 3. / (n1Keys - 1) * i; } result = null; function.evaluate(result, x0Keys[1], x1Keys[1]); }
int order0 = pp.getOrder()[0]; int order1 = pp.getOrder()[1]; ArgChecker.isFalse(order0 < 2, "polynomial degree of x0 < 1"); DoubleArray knots0 = pp.getKnots0(); DoubleArray knots1 = pp.getKnots1(); int nKnots0 = knots0.size(); int nKnots1 = knots1.size(); DoubleMatrix[][] coefs = pp.getCoefs(); PiecewisePolynomialResult2D ppDiff = new PiecewisePolynomialResult2D( knots0, knots1, res, new int[] {order0 - 1, order1});