pad method

Matrix2d pad(
  1. int rings
)

Implementation

Matrix2d pad(int rings) {
  int newRows = _rows + 2 * rings;
  int newCols = _cols + 2 * rings;
  Matrix2d padded = Matrix2d(
      newRows,
      newCols,
      ValueVector(List.generate(newRows * newCols, (index) => Value(0),
          growable: false)));

  for (int i = 0; i < _rows; i++) {
    for (int j = 0; j < _cols; j++) {
      padded.data!.values[(i + rings) * newCols + (j + rings)] = at(i, j);
    }
  }
  return padded;
}