### Question:
DoubleMatrix implements Matrix, Serializable, ImmutableBean { public static DoubleMatrix identity(int size) { if (size == 0) { return EMPTY; } double[][] array = new double[size][size]; for (int i = 0; i < size; i++) { array[i][i] = 1d; } return new DoubleMatrix(array, size, size); } DoubleMatrix(double[][] data, int rows, int columns); @ImmutableConstructor private  DoubleMatrix(double[][] array); static DoubleMatrix of(); static DoubleMatrix of(int rows, int columns, double... values); static DoubleMatrix of(int rows, int columns, IntIntToDoubleFunction valueFunction); static DoubleMatrix ofArrays(int rows, int columns, IntFunction<double[]> valuesFunction); static DoubleMatrix ofArrayObjects(int rows, int columns, IntFunction<DoubleArray> valuesFunction); static DoubleMatrix ofUnsafe(double[][] array); static DoubleMatrix copyOf(double[][] array); static DoubleMatrix filled(int rows, int columns); static DoubleMatrix filled(int rows, int columns, double value); static DoubleMatrix identity(int size); static DoubleMatrix diagonal(DoubleArray array); @Override int dimensions(); @Override int size(); int rowCount(); int columnCount(); boolean isSquare(); boolean isEmpty(); double get(int row, int column); DoubleArray row(int row); double[] rowArray(int row); DoubleArray column(int column); double[] columnArray(int column); double[][] toArray(); double[][] toArrayUnsafe(); void forEach(IntIntDoubleConsumer action); DoubleMatrix with(int row, int column, double newValue); DoubleMatrix multipliedBy(double factor); DoubleMatrix map(DoubleUnaryOperator operator); DoubleMatrix mapWithIndex(IntIntDoubleToDoubleFunction function); DoubleMatrix plus(DoubleMatrix other); DoubleMatrix minus(DoubleMatrix other); DoubleMatrix combine(DoubleMatrix other, DoubleBinaryOperator operator); double total(); double reduce(double identity, DoubleBinaryOperator operator); DoubleMatrix transpose(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static DoubleMatrix.Meta meta(); @Override DoubleMatrix.Meta metaBean(); static final DoubleMatrix EMPTY; }### Answer:
@Test public void test_identity() { assertMatrix(DoubleMatrix.identity(0)); assertMatrix(DoubleMatrix.identity(2), 1d, 0d, 0d, 1d); }