MathPHP\LinearAlgebra\Matrix::cofactorMatrix PHP Method

cofactorMatrix() public method

[A₀₀ A₀₁ A₀₂] A = [A₁₀ A₁₁ A₁₂] [A₂₀ A₂₁ A₂₂] [C₀₀ C₀₁ C₀₂] CM = [C₁₀ C₁₁ C₁₂] [C₂₀ C₂₁ C₂₂]
public cofactorMatrix ( ) : SquareMatrix
return SquareMatrix
    public function cofactorMatrix() : SquareMatrix
    {
        if (!$this->isSquare()) {
            throw new Exception\MatrixException('Matrix is not square; cannot get cofactor Matrix of a non-square matrix');
        }
        $m = $this->m;
        $n = $this->n;
        $R = [];
        for ($i = 0; $i < $m; $i++) {
            for ($j = 0; $j < $n; $j++) {
                $R[$i][$j] = $this->cofactor($i, $j);
            }
        }
        return MatrixFactory::create($R);
    }