code: private Matrix<Double> generateIdentityMatrix(final int numDimension) {
      final List<List<Double>> rows = new ArrayList<>(numDimension);
      for (int i = 0; i < numDimension; i++) {
        final List<Double> row = new ArrayList<>(numDimension);
        for (int j = 0; j < numDimension; j++) {
          final double value = i == j ? 1 : 0;
          row.add(value);
        }
        rows.add(row);
      }
      return new RowMatrix(rows);
    }
docs: Generate an identity matrix.
  @param numDimension number of rows and columns of the identity matrix.
  @return Identity matrix.