\returns The determinant of the matrix. * * \sa absDeterminant(), logAbsDeterminant() */
| 335 | * \sa absDeterminant(), logAbsDeterminant() |
| 336 | */ |
| 337 | Scalar determinant() |
| 338 | { |
| 339 | eigen_assert(m_factorizationIsOk && "The matrix should be factorized first."); |
| 340 | // Initialize with the determinant of the row matrix |
| 341 | Scalar det = Scalar(1.); |
| 342 | // Note that the diagonal blocks of U are stored in supernodes, |
| 343 | // which are available in the L part :) |
| 344 | for (Index j = 0; j < this->cols(); ++j) |
| 345 | { |
| 346 | for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) |
| 347 | { |
| 348 | if(it.index() == j) |
| 349 | { |
| 350 | det *= it.value(); |
| 351 | break; |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | return (m_detPermR * m_detPermC) > 0 ? det : -det; |
| 356 | } |
| 357 | |
| 358 | protected: |
| 359 | // Functions |