code: public static Basic1DMatrix diagonal(int size, double diagonal) {
          double[] array = new double[size * size];
  
          for (int i = 0; i < size; i++) {
              array[i * size + i] = diagonal;
          }
  
          return new Basic1DMatrix(size, size, array);
      }
docs: Creates a diagonal {@link Basic1DMatrix} of the given {@code size} whose
  diagonal elements are equal to {@code diagonal}.