\returns A number representing the sign of the determinant * * \sa absDeterminant(), logAbsDeterminant() */
| 307 | * \sa absDeterminant(), logAbsDeterminant() |
| 308 | */ |
| 309 | Scalar signDeterminant() |
| 310 | { |
| 311 | eigen_assert(m_factorizationIsOk && "The matrix should be factorized first."); |
| 312 | // Initialize with the determinant of the row matrix |
| 313 | Index det = 1; |
| 314 | // Note that the diagonal blocks of U are stored in supernodes, |
| 315 | // which are available in the L part :) |
| 316 | for (Index j = 0; j < this->cols(); ++j) |
| 317 | { |
| 318 | for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) |
| 319 | { |
| 320 | if(it.index() == j) |
| 321 | { |
| 322 | if(it.value()<0) |
| 323 | det = -det; |
| 324 | else if(it.value()==0) |
| 325 | return 0; |
| 326 | break; |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | return det * m_detPermR * m_detPermC; |
| 331 | } |
| 332 | |
| 333 | /** \returns The determinant of the matrix. |
| 334 | * |