### Question:
DoubleMatrix implements Matrix, Serializable, ImmutableBean { public static DoubleMatrix ofArrays(int rows, int columns, IntFunction<double[]> valuesFunction) { if (rows == 0 || columns == 0) { return EMPTY; } double[][] array = new double[rows][columns]; for (int i = 0; i < array.length; i++) { double[] values = valuesFunction.apply(i); if (values.length != columns) { throw new IllegalArgumentException(Messages.format( "Function returned array of incorrect length {}, expected {}", values.length, columns)); } array[i] = values.clone(); } return new DoubleMatrix(array, rows, columns); } 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_ofArrays() { assertMatrix(DoubleMatrix.ofArrays(0, 0, i -> { throw new AssertionError(); })); assertMatrix(DoubleMatrix.ofArrays(0, 2, i -> { throw new AssertionError(); })); assertMatrix(DoubleMatrix.ofArrays(2, 0, i -> { throw new AssertionError(); })); AtomicInteger counter = new AtomicInteger(2); assertMatrix(DoubleMatrix.ofArrays(1, 2, i -> new double[] {counter.getAndIncrement(), counter.getAndIncrement()}), 2d, 3d); assertThatIllegalArgumentException().isThrownBy(() -> DoubleMatrix.ofArrays(1, 2, i -> new double[0])); }