\brief Give the determinant. * * \returns The determinant of the matrix. * * \sa absDeterminant(), logAbsDeterminant() */
| 447 | * \sa absDeterminant(), logAbsDeterminant() |
| 448 | */ |
| 449 | Scalar determinant() { |
| 450 | eigen_assert(m_factorizationIsOk && "The matrix should be factorized first."); |
| 451 | // Initialize with the determinant of the row matrix |
| 452 | Scalar det = Scalar(1.); |
| 453 | // Note that the diagonal blocks of U are stored in supernodes, |
| 454 | // which are available in the L part :) |
| 455 | for (Index j = 0; j < this->cols(); ++j) { |
| 456 | for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) { |
| 457 | if (it.index() == j) { |
| 458 | det *= it.value(); |
| 459 | break; |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | return (m_detPermR * m_detPermC) > 0 ? det : -det; |
| 464 | } |
| 465 | |
| 466 | /** \brief Give the number of non zero in matrix L. |
| 467 | */ |