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