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;
    }