public function determinant() : float
{
$this->checkSquare();
try {
$decomp = new LUP($this);
} catch (MatrixException $exception) {
// Singular matrix, so determinant is defined to be zero.
return 0.0;
}
$upper = $decomp->upper();
$determinant = 1.0;
for ($i = 0, $size = $upper->getRowCount(); $i < $size; $i++) {
$determinant *= $upper->get($i, $i);
}
$sign = $decomp->parity() % 2 ? -1 : 1;
return $sign * $determinant;
}