MathPHP\LinearAlgebra\Matrix::columnAdd PHP Метод

columnAdd() публичный Метод

Add k times column nᵢ to column nⱼ
public columnAdd ( integer $nᵢ, integer $nⱼ, integer $k ) : Matrix
$nᵢ integer Column to multiply * k to be added to column nⱼ
$nⱼ integer Column that will have column nⱼ * k added to it
$k integer Multiplier
Результат Matrix
    public function columnAdd(int $nᵢ, int $nⱼ, int $k) : Matrix
    {
        if ($nᵢ >= $this->n || $nⱼ >= $this->n) {
            throw new Exception\MatrixException('Column to add does not exist');
        }
        if ($k == 0) {
            throw new Exception\BadParameterException('Multiplication factor k must not be 0');
        }
        $m = $this->m;
        $R = $this->A;
        for ($i = 0; $i < $m; $i++) {
            $R[$i][$nⱼ] += $R[$i][$nᵢ] * $k;
        }
        return MatrixFactory::create($R);
    }