\brief Give the sign of the determinant. * * \returns A number representing the sign of the determinant * * \sa absDeterminant(), logAbsDeterminant() */
| 421 | * \sa absDeterminant(), logAbsDeterminant() |
| 422 | */ |
| 423 | Scalar signDeterminant() { |
| 424 | eigen_assert(m_factorizationIsOk && "The matrix should be factorized first."); |
| 425 | // Initialize with the determinant of the row matrix |
| 426 | Index det = 1; |
| 427 | // Note that the diagonal blocks of U are stored in supernodes, |
| 428 | // which are available in the L part :) |
| 429 | for (Index j = 0; j < this->cols(); ++j) { |
| 430 | for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) { |
| 431 | if (it.index() == j) { |
| 432 | if (it.value() < 0) |
| 433 | det = -det; |
| 434 | else if (it.value() == 0) |
| 435 | return 0; |
| 436 | break; |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | return det * m_detPermR * m_detPermC; |
| 441 | } |
| 442 | |
| 443 | /** \brief Give the determinant. |
| 444 | * |