public function crossOut(int $row, int $column) { $newMatrix = []; $r = 0; for ($i = 0; $i < $this->rows; ++$i) { $c = 0; if ($row != $i) { for ($j = 0; $j < $this->columns; ++$j) { if ($column != $j) { $newMatrix[$r][$c] = $this->matrix[$i][$j]; ++$c; } } ++$r; } } return new self($newMatrix, false); }
public function testCrossOutMatrix() { $matrix = new Matrix([[3, 4, 2], [4, 5, 5], [1, 1, 1]]); $crossOuted = [[3, 2], [1, 1]]; $this->assertEquals($crossOuted, $matrix->crossOut(1, 1)->toArray()); }