public function determinant()
    {
        if (!$this->isSquare()) {
            throw new RuntimeException('Determinant is undefined'
                . ' for a non square matrix.');
        }

        [$b, $swaps] = $this->ref();

        $pi = $b->diagonalAsVector()->product();

        return $pi * (-1.) ** $swaps;
    }
public function determinant()
    {
        if (!$this->isSquare()) {
            throw new RuntimeException('Determinant is undefined'
                . ' for a non square matrix.');
        }

        [$b, $swaps] = $this->ref();

        $pi = $b->diagonalAsVector()->product();

        return $pi * (-1.) ** $swaps;
    }
public function determinant ( ) { if ( ! $ this -> isSquare ( ) ) { throw new RuntimeException ( 'Determinant is undefined' . ' for a non square matrix.' ) ; } [ $ b , $ swaps ] = $ this -> ref ( ) ; $ pi = $ b -> diagonalAsVector ( ) -> product ( ) ; return $ pi * ( - 1. ) ** $ swaps ; }
Calculate the determinant of the matrix.

@throws \RuntimeException
@return int|float
Calculate the determinant of the matrix .