class 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);

}