CommonsMathWrapper { public static RealMatrix wrapAsMatrix(final DoubleMatrix1D x) { Validate.notNull(x); final int n = x.getNumberOfElements(); final double[][] y = new double[n][1]; for (int i = 0; i < n; i++) { y[i][0] = x.getEntry(i); } return new Array2DRowRealMatrix(x.getData()); } 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 public void testVectorAsMatrix() { final RealMatrix commons = CommonsMathWrapper.wrapAsMatrix(OG_VECTOR); final double[][] data = commons.getData(); assertEquals(data.length, OG_VECTOR.getNumberOfElements()); assertEquals(data[0].length, 1); }