public virtual void testInterpolateWithSensitivity() { foreach (PiecewisePolynomialInterpolator baseInterp in BASE_INTERP) { ClampedPiecewisePolynomialInterpolator interp = new ClampedPiecewisePolynomialInterpolator(baseInterp, X_CLAMPED, Y_CLAMPED); PiecewisePolynomialResultsWithSensitivity computed = interp.interpolateWithSensitivity(X_VALUES, Y_VALUES); PiecewisePolynomialResultsWithSensitivity expected = baseInterp.interpolateWithSensitivity(X_VALUES_TOTAL, Y_VALUES_TOTAL); assertEquals(computed, expected); } }
public virtual void testInterpolate() { foreach (PiecewisePolynomialInterpolator baseInterp in BASE_INTERP) { ClampedPiecewisePolynomialInterpolator interp = new ClampedPiecewisePolynomialInterpolator(baseInterp, X_CLAMPED, Y_CLAMPED); PiecewisePolynomialResult computed = interp.interpolate(X_VALUES, Y_VALUES); PiecewisePolynomialResult expected = baseInterp.interpolate(X_VALUES_TOTAL, Y_VALUES_TOTAL); assertEquals(computed, expected); assertEquals(interp.PrimaryMethod, baseInterp); } }
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); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(expectedExceptions = UnsupportedOperationException.class) public void testInterpolateMultiDim() public virtual void testInterpolateMultiDim() { ClampedPiecewisePolynomialInterpolator interp = new ClampedPiecewisePolynomialInterpolator(new NaturalSplineInterpolator(), new double[] { 1d }, new double[] { 2d }); interp.interpolate(X_VALUES, new double[][] { Y_VALUES, Y_VALUES }); }