src/Malenki/Math/Matrix.php
public function cofactor()
    {
        $c = new self($this->size->rows, $this->size->cols);

        for ($m = 0; $m < $this->size->rows; $m++) {
            $arr_row = array();

            for ($n = 0; $n < $this->size->cols; $n++) {
                if ($this->size->cols == 2) {
                    $arr_row[] = pow(-1, $m + $n) * $this->subMatrix($m, $n)->get(0,0);
                } else {
                    $arr_row[] = pow(-1, $m + $n) * $this->subMatrix($m, $n)->det();
                }
            }

            $c->addRow($arr_row);
        }

        return $c;
    }
public function cofactor()
    {
        $c = new self($this->size->rows, $this->size->cols);

        for ($m = 0; $m < $this->size->rows; $m++) {
            $arr_row = array();

            for ($n = 0; $n < $this->size->cols; $n++) {
                if ($this->size->cols == 2) {
                    $arr_row[] = pow(-1, $m + $n) * $this->subMatrix($m, $n)->get(0,0);
                } else {
                    $arr_row[] = pow(-1, $m + $n) * $this->subMatrix($m, $n)->det();
                }
            }

            $c->addRow($arr_row);
        }

        return $c;
    }
Gets the cofactor matrix

@access public
@return Matrix