MathPHP\LinearAlgebra\Matrix::augment PHP Method

augment() public method

[1, 2, 3] A = [2, 3, 4] [3, 4, 5] [4] B = [5] [6] [1, 2, 3 | 4] (A|B) = [2, 3, 4 | 5] [3, 4, 5 | 6]
public augment ( Matrix $B ) : Matrix
$B Matrix Matrix columns to add to matrix A
return Matrix
    public function augment(Matrix $B) : Matrix
    {
        if ($B->getM() !== $this->m) {
            throw new Exception\MatrixException('Matrices to augment do not have the same number of rows');
        }
        $m = $this->m;
        $A = $this->A;
        $B = $B->getMatrix();
        $⟮A∣B⟯ = [];
        for ($i = 0; $i < $m; $i++) {
            $⟮A∣B⟯[$i] = array_merge($A[$i], $B[$i]);
        }
        return MatrixFactory::create($⟮A∣B⟯);
    }