DoubleMatrixUtils { public static DoubleMatrix2D getTwoDimensionalDiagonalMatrix(final DoubleMatrix1D vector) { Validate.notNull(vector); final int n = vector.getNumberOfElements(); if (n == 0) { return DoubleMatrix2D.EMPTY_MATRIX; } final double[][] data = new double[n][n]; for (int i = 0; i < n; i++) { data[i][i] = vector.getEntry(i); } return new DoubleMatrix2D(data); } private  DoubleMatrixUtils(); static DoubleMatrix2D getTranspose(final DoubleMatrix2D matrix); static DoubleMatrix2D getIdentityMatrix2D(final int dimension); static DoubleMatrix2D getTwoDimensionalDiagonalMatrix(final DoubleMatrix1D vector); static DoubleMatrix2D getTwoDimensionalDiagonalMatrix(final double[] vector);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullVector() { DoubleMatrixUtils.getTwoDimensionalDiagonalMatrix((DoubleMatrix1D) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullArray() { DoubleMatrixUtils.getTwoDimensionalDiagonalMatrix((double[]) null); }