MathPHP\LinearAlgebra\Matrix::rowAdd PHP 메소드

rowAdd() 공개 메소드

Add k times row mᵢ to row mⱼ
public rowAdd ( integer $mᵢ, integer $mⱼ, integer $k ) : Matrix
$mᵢ integer Row to multiply * k to be added to row mⱼ
$mⱼ integer Row that will have row mⱼ * k added to it
$k integer Multiplier
리턴 Matrix
    public function rowAdd(int $mᵢ, int $mⱼ, int $k) : Matrix
    {
        if ($mᵢ >= $this->m || $mⱼ >= $this->m) {
            throw new Exception\MatrixException('Row to add does not exist');
        }
        if ($k == 0) {
            throw new Exception\BadParameterException('Multiplication factor k must not be 0');
        }
        $n = $this->n;
        $R = $this->A;
        for ($j = 0; $j < $n; $j++) {
            $R[$mⱼ][$j] += $R[$mᵢ][$j] * $k;
        }
        return MatrixFactory::create($R);
    }