/// public virtual void localMonotonicityClampedTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] xValues = new double[] {-2.0, 3.0, 4.0, 8.0, 9.1, 10.0 }; double[] xValues = new double[] { -2.0, 3.0, 4.0, 8.0, 9.1, 10.0 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[] yValues = new double[] {0.0, 10.0, 9.5, 2.0, 1.1, -2.2, -2.6, 0.0 }; double[] yValues = new double[] { 0.0, 10.0, 9.5, 2.0, 1.1, -2.2, -2.6, 0.0 }; PiecewisePolynomialInterpolator interp = new CubicSplineInterpolator(); PiecewisePolynomialResult result = interp.interpolate(xValues, yValues); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); PiecewisePolynomialInterpolator interpPos = new MonotonicityPreservingCubicSplineInterpolator(interp); PiecewisePolynomialResult resultPos = interpPos.interpolate(xValues, yValues); assertEquals(resultPos.Dimensions, result.Dimensions); assertEquals(resultPos.NumberOfIntervals, result.NumberOfIntervals); assertEquals(resultPos.Order, result.Order); const int nKeys = 121; double key0 = -2.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 = -2.0 + 12.0 / (nKeys - 1) * i; double key = -2.0 + 12.0 / (nKeys - 1) * i; assertTrue(function.evaluate(resultPos, key).get(0) - function.evaluate(resultPos, key0).get(0) <= 0.0); key0 = -2.0 + 11.0 / (nKeys - 1) * i; } }
/// <summary> /// local extrema are not necessarily at data-points /// </summary> 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, 8 }; double[] xValues = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double[][] yValues = new double[][] { {1.0, 1.0, 2.0, 4.0, 4.0, 2.0, 1.0, 1.0 }, {10.0, 10.0, 6.0, 4.0, 4.0, 6.0, 10.0, 10.0 } }; double[][] yValues = new double[][] { new double[] { 1.0, 1.0, 2.0, 4.0, 4.0, 2.0, 1.0, 1.0 }, new double[] { 10.0, 10.0, 6.0, 4.0, 4.0, 6.0, 10.0, 10.0 } }; PiecewisePolynomialInterpolator interp = new CubicSplineInterpolator(); PiecewisePolynomialResult result = interp.interpolate(xValues, yValues); PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D(); PiecewisePolynomialInterpolator interpPos = new MonotonicityPreservingCubicSplineInterpolator(interp); PiecewisePolynomialResult resultPos = interpPos.interpolate(xValues, yValues); assertEquals(resultPos.Dimensions, result.Dimensions); assertEquals(resultPos.NumberOfIntervals, result.NumberOfIntervals); assertEquals(resultPos.Order, result.Order); assertTrue(function.evaluate(resultPos, 4.5).get(0) - function.evaluate(resultPos, 4).get(0) >= 0.0); assertTrue(function.evaluate(resultPos, 4.5).get(0) - function.evaluate(resultPos, 5).get(0) >= 0.0); assertTrue(function.evaluate(resultPos, 4.5).get(1) - function.evaluate(resultPos, 4).get(1) <= 0.0); assertTrue(function.evaluate(resultPos, 4.5).get(1) - function.evaluate(resultPos, 5).get(1) <= 0.0); const int nKeys = 41; 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(resultPos, key).get(0) - function.evaluate(resultPos, key0).get(0) >= 0.0); key0 = 1.0 + 3.0 / (nKeys - 1) * i; } 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(resultPos, key).get(1) - function.evaluate(resultPos, key0).get(1) <= 0.0); key0 = 1.0 + 3.0 / (nKeys - 1) * i; } 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 + 3.0 / (nKeys - 1) * i; double key = 5.0 + 3.0 / (nKeys - 1) * i; assertTrue(function.evaluate(resultPos, key).get(0) - function.evaluate(resultPos, key0).get(0) <= 0.0); key0 = 5.0 + 3.0 / (nKeys - 1) * i; } 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 + 3.0 / (nKeys - 1) * i; double key = 5.0 + 3.0 / (nKeys - 1) * i; assertTrue(function.evaluate(resultPos, key).get(1) - function.evaluate(resultPos, key0).get(1) >= 0.0); key0 = 5.0 + 3.0 / (nKeys - 1) * i; } }