\brief Give the natural log of the absolute determinant. * * \returns the natural log of the absolute value of the determinant of the matrix * of which **this is the QR decomposition * * \note This method is useful to work around the risk of overflow/underflow that's * inherent to the determinant computation. * * \sa absDeterminant(), signDeterminant() */
| 397 | * \sa absDeterminant(), signDeterminant() |
| 398 | */ |
| 399 | Scalar logAbsDeterminant() const { |
| 400 | using std::abs; |
| 401 | using std::log; |
| 402 | |
| 403 | eigen_assert(m_factorizationIsOk && "The matrix should be factorized first."); |
| 404 | Scalar det = Scalar(0.); |
| 405 | for (Index j = 0; j < this->cols(); ++j) { |
| 406 | for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) { |
| 407 | if (it.row() < j) continue; |
| 408 | if (it.row() == j) { |
| 409 | det += log(abs(it.value())); |
| 410 | break; |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | return det; |
| 415 | } |
| 416 | |
| 417 | /** \brief Give the sign of the determinant. |
| 418 | * |