CommonsMathWrapper { public static UnivariateRealFunction wrapUnivariate(final Function1D<Double, Double> f) { Validate.notNull(f); return new UnivariateRealFunction() { @Override public double value(final double x) { return f.evaluate(x); } }; } private  CommonsMathWrapper(); static UnivariateRealFunction wrapUnivariate(final Function1D<Double, Double> f); static MultivariateRealFunction wrapMultivariate(final Function1D<DoubleMatrix1D, Double> f); static MultivariateRealFunction wrap(final FunctionND<Double, Double> f); static RealMatrix wrap(final DoubleMatrix2D x); static RealMatrix wrapAsMatrix(final DoubleMatrix1D x); static DoubleMatrix2D unwrap(final RealMatrix x); static RealVector wrap(final DoubleMatrix1D x); static DoubleMatrix1D unwrap(final RealVector x); static Complex wrap(final ComplexNumber z); static Function1D<Double, Double> unwrap(final PolynomialFunctionLagrangeForm lagrange); static double[] unwrap(final RealPointValuePair x); static DifferentiableUnivariateRealFunction wrapDifferentiable(final DoubleFunction1D f);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNull1DFunction() { CommonsMathWrapper.wrapUnivariate((Function1D<Double, Double>) null); }
@Test public void test1DFunction() throws FunctionEvaluationException { final UnivariateRealFunction commons = CommonsMathWrapper.wrapUnivariate(OG_FUNCTION_1D); for (int i = 0; i < 100; i++) { assertEquals(OG_FUNCTION_1D.evaluate((double) i), commons.value(i), 1e-15); } }