public function set(array $m) { for ($r = 0; $r < $this->rows; ++$r) { $this->matrix[$r] = []; for ($c = 0; $c < $this->columns; ++$c) { $this->matrix[$r][$c] = isset($m[$r][$c]) ? $m[$r][$c] : 0; } } }