public function rowInterchange(int $mᵢ, int $mⱼ) : Matrix { if ($mᵢ >= $this->m || $mⱼ >= $this->m) { throw new Exception\MatrixException('Row to interchange does not exist'); } $m = $this->m; $R = []; for ($i = 0; $i < $m; $i++) { switch ($i) { case $mᵢ: $R[$i] = $this->A[$mⱼ]; break; case $mⱼ: $R[$i] = $this->A[$mᵢ]; break; default: $R[$i] = $this->A[$i]; } } return MatrixFactory::create($R); }