\returns A number representing the sign of the determinant * * \sa absDeterminant(), logAbsDeterminant() */
| 407 | * \sa absDeterminant(), logAbsDeterminant() |
| 408 | */ |
| 409 | Scalar signDeterminant() |
| 410 | { |
| 411 | eigen_assert(m_factorizationIsOk && "The matrix should be factorized first."); |
| 412 | // Initialize with the determinant of the row matrix |
| 413 | Index det = 1; |
| 414 | // Note that the diagonal blocks of U are stored in supernodes, |
| 415 | // which are available in the L part :) |
| 416 | for (Index j = 0; j < this->cols(); ++j) |
| 417 | { |
| 418 | for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) |
| 419 | { |
| 420 | if(it.index() == j) |
| 421 | { |
| 422 | if(it.value()<0) |
| 423 | det = -det; |
| 424 | else if(it.value()==0) |
| 425 | return 0; |
| 426 | break; |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | return det * m_detPermR * m_detPermC; |
| 431 | } |
| 432 | |
| 433 | /** \returns The determinant of the matrix. |
| 434 | * |