cut method

Matrix cut(
  1. int m,
  2. int n
)

Cuts the given column m and row n from the matrix and returns the remainder.

Matrix m = Matrix( [
  [1.0, 2.0, 3.0],
  [4.0, 5.0, 6.0],
  [7.0, 8.0, 9.0],
]);
print(m.cut(1,1))

prints

[[1.0, 3.0], [7.0, 9.0]]

Implementation

Matrix cut(int m, int n) {
  Matrix cm = Matrix.fill(this.m - 1, this.n - 1, 0.0);

  int dr = 0;
  for (int r = 0; r < this.m; r++) {
    int dc = 0;
    if (r == m) {
      continue;
    }
    for (int c = 0; c < this.n; c++) {
      if (c == n) {
        continue;
      }
      cm[dr][dc] = _values[r][c];
      dc++;
    }
    dr++;
  }

  return cm;
}