\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() */
| 281 | * \sa absDeterminant(), signDeterminant() |
| 282 | */ |
| 283 | Scalar logAbsDeterminant() const |
| 284 | { |
| 285 | using std::log; |
| 286 | using std::abs; |
| 287 | |
| 288 | eigen_assert(m_factorizationIsOk && "The matrix should be factorized first."); |
| 289 | Scalar det = Scalar(0.); |
| 290 | for (Index j = 0; j < this->cols(); ++j) |
| 291 | { |
| 292 | for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) |
| 293 | { |
| 294 | if(it.row() < j) continue; |
| 295 | if(it.row() == j) |
| 296 | { |
| 297 | det += log(abs(it.value())); |
| 298 | break; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | return det; |
| 303 | } |
| 304 | |
| 305 | /** \returns A number representing the sign of the determinant |
| 306 | * |