/// <summary> /// Sample data /// </summary> public virtual void sampleDataTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] xValues = new double[] {0.0, 10.0, 30.0, 50.0, 70.0, 90.0, 100.0 }; double[] xValues = new double[] { 0.0, 10.0, 30.0, 50.0, 70.0, 90.0, 100.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] yValues = new double[] {30.0, 130.0, 150.0, 150.0, 170.0, 220.0, 320.0 }; double[] yValues = new double[] { 30.0, 130.0, 150.0, 150.0, 170.0, 220.0, 320.0 }; PiecewisePolynomialInterpolator interp = new ConstrainedCubicSplineInterpolator(); PiecewisePolynomialResult result = interp.interpolate(xValues, yValues); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[][] coefsMatPartExp = new double[][] { {-9.0 / 220.0, 0.0, 155.0 / 11.0, 30.0 }, {-1.0 / 2200.0, -7.0 / 220.0, 20.0 / 11.0, 130.0 }, {0.0, 0.0, 0.0, 150.0 } }; double[][] coefsMatPartExp = new double[][] { new double[] { -9.0 / 220.0, 0.0, 155.0 / 11.0, 30.0 }, new double[] { -1.0 / 2200.0, -7.0 / 220.0, 20.0 / 11.0, 130.0 }, new double[] { 0.0, 0.0, 0.0, 150.0 } }; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 4; ++j) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double ref = Math.abs(coefsMatPartExp[i][j]) == 0.0 ? 1.0 : Math.abs(coefsMatPartExp[i][j]); double @ref = Math.Abs(coefsMatPartExp[i][j]) == 0.0 ? 1.0 : Math.Abs(coefsMatPartExp[i][j]); assertEquals(result.CoefMatrix.get(i, j), coefsMatPartExp[i][j], @ref * EPS); } } int nKeys = 101; double key0 = 0.0; for (int i = 1; i < nKeys; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double key = 0.0 + 100.0 / (nKeys - 1) * i; double key = 0.0 + 100.0 / (nKeys - 1) * i; assertTrue(function.evaluate(result, key).get(0) - function.evaluate(result, key0).get(0) >= -EPS); key0 = 0.0 + 100.0 / (nKeys - 1) * i; } }
public virtual void baseInterpolationTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int nExamples = Y.length; int nExamples = Y.Length; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int n = XX.length; int n = XX.Length; for (int example = 0; example < nExamples; example++) { PiecewisePolynomialResult pp = PCHIP.interpolate(X, Y[example]); for (int i = 0; i < n; i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double y = PPVAL.evaluate(pp, XX[i]).get(0); double y = PPVAL.evaluate(pp, XX[i]).get(0); assertEquals(YY[example][i], y, 1e-14); } } }
/// public virtual void extremumTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] xValues = new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; double[] xValues = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] yValues = new double[] {1.0, 1.0, 4.0, 5.0, 4.0, 1.0, 1.0 }; double[] yValues = new double[] { 1.0, 1.0, 4.0, 5.0, 4.0, 1.0, 1.0 }; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); PiecewisePolynomialInterpolator interp = new ConstrainedCubicSplineInterpolator(); PiecewisePolynomialResult result = interp.interpolate(xValues, yValues); assertEquals(result.Dimensions, 1); assertEquals(result.NumberOfIntervals, 6); assertEquals(result.Order, 4); const int nKeys = 31; double key0 = 1.0; for (int i = 1; i < nKeys; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double key = 1.0 + 3.0 / (nKeys - 1) * i; double key = 1.0 + 3.0 / (nKeys - 1) * i; assertTrue(function.evaluate(result, key).get(0) - function.evaluate(result, key0).get(0) >= 0.0); key0 = 1.0 + 3.0 / (nKeys - 1) * i; } key0 = 4.0; for (int i = 1; i < nKeys; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double key = 4.0 + 3.0 / (nKeys - 1) * i; double key = 4.0 + 3.0 / (nKeys - 1) * i; assertTrue(function.evaluate(result, key).get(0) - function.evaluate(result, key0).get(0) <= 0.0); key0 = 4.0 + 3.0 / (nKeys - 1) * i; } }
/// public virtual void flipTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] xValues = new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; double[] xValues = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] yValues = new double[] {3.0, 0.1, 0.01, 0.01, 0.1, 3.0 }; double[] yValues = new double[] { 3.0, 0.1, 0.01, 0.01, 0.1, 3.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] xValuesFlip = new double[] {6.0, 2.0, 3.0, 5.0, 4.0, 1.0 }; double[] xValuesFlip = new double[] { 6.0, 2.0, 3.0, 5.0, 4.0, 1.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] yValuesFlip = new double[] {3.0, 0.1, 0.01, 0.1, 0.01, 3.0 }; double[] yValuesFlip = new double[] { 3.0, 0.1, 0.01, 0.1, 0.01, 3.0 }; PiecewisePolynomialInterpolator interp = new NaturalSplineInterpolator(); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); PiecewisePolynomialInterpolator interpPos = new NonnegativityPreservingCubicSplineInterpolator(interp); PiecewisePolynomialResult resultPos = interpPos.interpolate(xValues, yValues); PiecewisePolynomialResult resultPosFlip = interpPos.interpolate(xValuesFlip, yValuesFlip); assertEquals(resultPos.Dimensions, resultPosFlip.Dimensions); assertEquals(resultPos.NumberOfIntervals, resultPosFlip.NumberOfIntervals); assertEquals(resultPos.Order, resultPosFlip.Order); const int nPts = 101; for (int i = 0; i < 101; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double key = 1.0 + 5.0 / (nPts - 1) * i; double key = 1.0 + 5.0 / (nPts - 1) * i; assertTrue(function.evaluate(resultPos, key).get(0) >= 0.0); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int nData = xValues.length; int nData = xValues.Length; for (int i = 0; i < nData - 1; ++i) { for (int k = 0; k < 4; ++k) { assertEquals(resultPos.CoefMatrix.get(i, k), resultPosFlip.CoefMatrix.get(i, k)); } } }
/// public virtual void positivityClampedMultiTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] xValues = new double[] {1.0, 2.0, 3.0, 4.0, 5.0 }; double[] xValues = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[][] yValues = new double[][] { {0.0, 0.1, 1.0, 1.0, 20.0, 5.0, 0.0 }, {-10.0, 0.1, 1.0, 1.0, 20.0, 5.0, 0.0 } }; double[][] yValues = new double[][] { new double[] { 0.0, 0.1, 1.0, 1.0, 20.0, 5.0, 0.0 }, new double[] { -10.0, 0.1, 1.0, 1.0, 20.0, 5.0, 0.0 } }; PiecewisePolynomialInterpolator interp = new CubicSplineInterpolator(); PiecewisePolynomialResult result = interp.interpolate(xValues, yValues); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); PiecewisePolynomialInterpolator interpPos = new NonnegativityPreservingCubicSplineInterpolator(interp); PiecewisePolynomialResult resultPos = interpPos.interpolate(xValues, yValues); assertEquals(resultPos.Dimensions, result.Dimensions); assertEquals(resultPos.NumberOfIntervals, result.NumberOfIntervals); assertEquals(resultPos.Order, result.Order); const int nPts = 101; for (int i = 0; i < 101; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double key = 1.0 + 4.0 / (nPts - 1) * i; double key = 1.0 + 4.0 / (nPts - 1) * i; assertTrue(function.evaluate(resultPos, key).get(0) >= 0.0); } int dim = yValues.Length; int nData = xValues.Length; for (int j = 0; j < dim; ++j) { for (int i = 1; i < nData - 2; ++i) { DoubleMatrix coefMatrix = resultPos.CoefMatrix; double tau = Math.Sign(coefMatrix.get(dim * i + j, 3)); assertTrue(coefMatrix.get(dim * i + j, 2) * tau >= -3.0 * yValues[j][i + 1] * tau / (xValues[i + 1] - xValues[i])); assertTrue(coefMatrix.get(dim * i + j, 2) * tau <= 3.0 * yValues[j][i + 1] * tau / (xValues[i] - xValues[i - 1])); } } }
public virtual void testFunctionalForm() { double[] xValues = new double[] { 0.5, 1.0, 3.0, 5.0, 10.0, 30.0 }; double lambda0 = 0.14; double[] lambda = new double[] { 0.25, 0.05, -0.12, 0.03, -0.15, 0.0 }; double pValueTmp = 0d; int nData = xValues.Length; for (int i = 0; i < nData - 1; ++i) { lambda[nData - 1] += lambda[i] * xValues[i]; pValueTmp += lambda[i]; } lambda[nData - 1] *= -1d / xValues[nData - 1]; pValueTmp += lambda[nData - 1]; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double pValue = pValueTmp; double pValue = pValueTmp; Function <double, double> func = new FunctionAnonymousInnerClass(this, xValues, lambda0, lambda, nData, pValue); double[] rt = new double[nData]; for (int i = 0; i < nData; ++i) { rt[i] = func.apply(xValues[i]); } ClampedPiecewisePolynomialInterpolator interp = 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) { double tm = 0.05 * i; double exp = func.apply(tm); assertEquals(exp, polyFunc.evaluate(result, tm).get(0), Math.Abs(exp) * TOL); } }
/// <summary> /// Recovering quadratic function /// </summary> public virtual void quadraticTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] xValues = new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; double[] xValues = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int nData = xValues.length; int nData = xValues.Length; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] yValues = new double[nData]; double[] yValues = new double[nData]; for (int i = 0; i < nData; ++i) { yValues[i] = xValues[i] * xValues[i] / 7.0 + xValues[i] / 13.0 + 1 / 11.0; } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[][] coefsMatExp = new double[][] { {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[0] + 1.0 / 13.0, yValues[0] }, {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[1] + 1.0 / 13.0, yValues[1] }, {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[2] + 1.0 / 13.0, yValues[2] }, {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[3] + 1.0 / 13.0, yValues[3] }, {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[4] + 1.0 / 13.0, yValues[4] } }; double[][] coefsMatExp = new double[][] { new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[0] + 1.0 / 13.0, yValues[0] }, new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[1] + 1.0 / 13.0, yValues[1] }, new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[2] + 1.0 / 13.0, yValues[2] }, new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[3] + 1.0 / 13.0, yValues[3] }, new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[4] + 1.0 / 13.0, yValues[4] } }; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); PiecewisePolynomialInterpolator interp = new SemiLocalCubicSplineInterpolator(); PiecewisePolynomialResult result = interp.interpolate(xValues, yValues); assertEquals(result.Dimensions, 1); assertEquals(result.NumberOfIntervals, 5); assertEquals(result.Order, 4); for (int i = 0; i < result.NumberOfIntervals; ++i) { for (int j = 0; j < result.Order; ++j) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double ref = Math.abs(coefsMatExp[i][j]) == 0.0 ? 1.0 : Math.abs(coefsMatExp[i][j]); double @ref = Math.Abs(coefsMatExp[i][j]) == 0.0 ? 1.0 : Math.Abs(coefsMatExp[i][j]); assertEquals(result.CoefMatrix.get(i, j), coefsMatExp[i][j], @ref * EPS); } } const int nKeys = 101; for (int i = 0; i < nKeys; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double key = 1.0 + 5.0 / (nKeys - 1) * i; double key = 1.0 + 5.0 / (nKeys - 1) * i; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double ref = key * key / 7.0 + key / 13.0 + 1 / 11.0; double @ref = key * key / 7.0 + key / 13.0 + 1 / 11.0; assertEquals(function.evaluate(result, key).get(0), @ref, @ref * EPS); } }
/// <summary> /// Sample data given in the original paper, consisting of constant part and monotonically increasing part /// </summary> public virtual void sampleDataTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] xValues = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 }; double[] xValues = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] yValues = new double[] {10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.5, 15.0, 50.0, 60.0, 85.0 }; double[] yValues = new double[] { 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.5, 15.0, 50.0, 60.0, 85.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[][] coefsMatPartExp = new double[][] { {0.0, 0.0, 0.0, 10.0 }, {0.0, 0.0, 0.0, 10.0 }, {0.0, 0.0, 0.0, 10.0 }, {0.0, 0.0, 0.0, 10.0 }, {0.0, 0.0, 0.0, 10.0 } }; double[][] coefsMatPartExp = new double[][] { new double[] { 0.0, 0.0, 0.0, 10.0 }, new double[] { 0.0, 0.0, 0.0, 10.0 }, new double[] { 0.0, 0.0, 0.0, 10.0 }, new double[] { 0.0, 0.0, 0.0, 10.0 }, new double[] { 0.0, 0.0, 0.0, 10.0 } }; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); PiecewisePolynomialInterpolator interp = new SemiLocalCubicSplineInterpolator(); PiecewisePolynomialResult result = interp.interpolate(xValues, yValues); assertEquals(result.Dimensions, 1); assertEquals(result.NumberOfIntervals, 10); assertEquals(result.Order, 4); for (int i = 0; i < 5; ++i) { for (int j = 0; j < 4; ++j) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double ref = Math.abs(coefsMatPartExp[i][j]) == 0.0 ? 1.0 : Math.abs(coefsMatPartExp[i][j]); double @ref = Math.Abs(coefsMatPartExp[i][j]) == 0.0 ? 1.0 : Math.Abs(coefsMatPartExp[i][j]); assertEquals(result.CoefMatrix.get(i, j), coefsMatPartExp[i][j], @ref * EPS); } } const int nKeys = 101; double key0 = 5.0; for (int i = 1; i < nKeys; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double key = 5.0 + 5.0 / (nKeys - 1) * i; double key = 5.0 + 5.0 / (nKeys - 1) * i; assertTrue(function.evaluate(result, key).get(0) - function.evaluate(result, key0).get(0) >= 0.0); key0 = 5.0 + 5.0 / (nKeys - 1) * i; } key0 = 0.0; for (int i = 1; i < nKeys; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double key = 0.0 + 5.0 / (nKeys - 1) * i; double key = 0.0 + 5.0 / (nKeys - 1) * i; assertTrue(function.evaluate(result, key).get(0) - function.evaluate(result, key0).get(0) == 0.0); key0 = 0.0 + 5.0 / (nKeys - 1) * i; } }
/// public virtual void quadraticMultiTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] xValues = new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; double[] xValues = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int nData = xValues.length; int nData = xValues.Length; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[][] yValues = new double[2][nData]; //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java: //ORIGINAL LINE: double[][] yValues = new double[2][nData]; double[][] yValues = RectangularArrays.ReturnRectangularDoubleArray(2, nData); for (int i = 0; i < nData; ++i) { yValues[0][i] = xValues[i] * xValues[i] / 7.0 + xValues[i] / 13.0 + 1 / 11.0; } for (int i = 0; i < nData; ++i) { yValues[1][i] = xValues[i] * xValues[i] / 3.0 + xValues[i] / 7.0 + 1 / 17.0; } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[][] coefsMatExp = new double[][] { {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[0] + 1.0 / 13.0, yValues[0][0] }, {0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[0] + 1.0 / 7.0, yValues[1][0] }, {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[1] + 1.0 / 13.0, yValues[0][1] }, {0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[1] + 1.0 / 7.0, yValues[1][1] }, {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[2] + 1.0 / 13.0, yValues[0][2] }, {0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[2] + 1.0 / 7.0, yValues[1][2] }, {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[3] + 1.0 / 13.0, yValues[0][3] }, {0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[3] + 1.0 / 7.0, yValues[1][3] }, {0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[4] + 1.0 / 13.0, yValues[0][4] }, {0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[4] + 1.0 / 7.0, yValues[1][4] } }; double[][] coefsMatExp = new double[][] { new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[0] + 1.0 / 13.0, yValues[0][0] }, new double[] { 0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[0] + 1.0 / 7.0, yValues[1][0] }, new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[1] + 1.0 / 13.0, yValues[0][1] }, new double[] { 0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[1] + 1.0 / 7.0, yValues[1][1] }, new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[2] + 1.0 / 13.0, yValues[0][2] }, new double[] { 0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[2] + 1.0 / 7.0, yValues[1][2] }, new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[3] + 1.0 / 13.0, yValues[0][3] }, new double[] { 0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[3] + 1.0 / 7.0, yValues[1][3] }, new double[] { 0.0, 1.0 / 7.0, 2.0 / 7.0 * xValues[4] + 1.0 / 13.0, yValues[0][4] }, new double[] { 0.0, 1.0 / 3.0, 2.0 / 3.0 * xValues[4] + 1.0 / 7.0, yValues[1][4] } }; PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); PiecewisePolynomialInterpolator interp = new SemiLocalCubicSplineInterpolator(); PiecewisePolynomialResult result = interp.interpolate(xValues, yValues); assertEquals(result.Dimensions, 2); assertEquals(result.NumberOfIntervals, 5); assertEquals(result.Order, 4); for (int i = 0; i < result.NumberOfIntervals * 2; ++i) { for (int j = 0; j < result.Order; ++j) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double ref = Math.abs(coefsMatExp[i][j]) == 0.0 ? 1.0 : Math.abs(coefsMatExp[i][j]); double @ref = Math.Abs(coefsMatExp[i][j]) == 0.0 ? 1.0 : Math.Abs(coefsMatExp[i][j]); assertEquals(result.CoefMatrix.get(i, j), coefsMatExp[i][j], @ref * EPS); } } const int nKeys = 101; for (int i = 0; i < nKeys; ++i) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double key = 1.0 + 5.0 / (nKeys - 1) * i; double key = 1.0 + 5.0 / (nKeys - 1) * i; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double ref = key * key / 7.0 + key / 13.0 + 1 / 11.0; double @ref = key * key / 7.0 + key / 13.0 + 1 / 11.0; assertEquals(function.evaluate(result, key).get(0), @ref, @ref * EPS); } }