MathPHP\LinearAlgebra\Matrix::columnExclude PHP Méthode

columnExclude() public méthode

Exclude a column from the result matrix
public columnExclude ( integer $nᵢ ) : Matrix
$nᵢ integer Column to exclude
Résultat Matrix with column nᵢ excluded
    public function columnExclude(int $nᵢ) : Matrix
    {
        if ($nᵢ >= $this->n || $nᵢ < 0) {
            throw new Exception\MatrixException('Column to exclude does not exist');
        }
        $m = $this->m;
        $n = $this->n;
        $R = [];
        for ($i = 0; $i < $m; $i++) {
            for ($j = 0; $j < $n; $j++) {
                if ($j === $nᵢ) {
                    continue;
                }
                $R[$i][$j] = $this->A[$i][$j];
            }
        }
        // Reset column indexes
        for ($i = 0; $i < $m; $i++) {
            $R[$i] = array_values($R[$i]);
        }
        return MatrixFactory::create($R);
    }