mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-01 18:26:24 +08:00
add a info() function in LLT to report on succes/faillure
This commit is contained in:
parent
a25749ade9
commit
03331552a9
@ -150,6 +150,18 @@ template<typename _MatrixType, int _UpLo> class LLT
|
||||
|
||||
MatrixType reconstructedMatrix() const;
|
||||
|
||||
|
||||
/** \brief Reports whether previous computation was successful.
|
||||
*
|
||||
* \returns \c Success if computation was succesful,
|
||||
* \c NumericalIssue if the matrix.appears to be negative.
|
||||
*/
|
||||
ComputationInfo info() const
|
||||
{
|
||||
ei_assert(m_isInitialized && "LLT is not initialized.");
|
||||
return m_info;
|
||||
}
|
||||
|
||||
inline Index rows() const { return m_matrix.rows(); }
|
||||
inline Index cols() const { return m_matrix.cols(); }
|
||||
|
||||
@ -160,6 +172,7 @@ template<typename _MatrixType, int _UpLo> class LLT
|
||||
*/
|
||||
MatrixType m_matrix;
|
||||
bool m_isInitialized;
|
||||
ComputationInfo m_info;
|
||||
};
|
||||
|
||||
template<int UpLo> struct ei_llt_inplace;
|
||||
@ -275,7 +288,10 @@ LLT<MatrixType,_UpLo>& LLT<MatrixType,_UpLo>::compute(const MatrixType& a)
|
||||
m_matrix.resize(size, size);
|
||||
m_matrix = a;
|
||||
|
||||
m_isInitialized = Traits::inplace_decomposition(m_matrix);
|
||||
m_isInitialized = true;
|
||||
bool ok = Traits::inplace_decomposition(m_matrix);
|
||||
m_info = ok ? Success : NumericalIssue;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -234,6 +234,14 @@ enum {
|
||||
IsSparse
|
||||
};
|
||||
|
||||
/** \brief Enum for reporting the status of a computation.
|
||||
*/
|
||||
enum ComputationInfo {
|
||||
Success = 0, /**< \brief Computation was successful. */
|
||||
NumericalIssue = 1, /**< \brief The provided data did not satisfy the prerequisites. */
|
||||
NoConvergence = 2 /**< \brief Iterative procedure did not converge. */
|
||||
};
|
||||
|
||||
enum TransformTraits {
|
||||
Isometry = 0x1,
|
||||
Affine = 0x2,
|
||||
|
@ -25,15 +25,7 @@
|
||||
#ifndef EIGEN_EIGENVALUES_COMMON_H
|
||||
#define EIGEN_EIGENVALUES_COMMON_H
|
||||
|
||||
/** \eigenvalues_module \ingroup Eigenvalues_Module
|
||||
* \nonstableyet
|
||||
*
|
||||
* \brief Enum for reporting the status of a computation.
|
||||
*/
|
||||
enum ComputationInfo {
|
||||
Success = 0, /**< \brief Computation was successful. */
|
||||
NoConvergence = 1 /**< \brief Iterative procedure did not converge. */
|
||||
};
|
||||
|
||||
|
||||
#endif // EIGEN_EIGENVALUES_COMMON_H
|
||||
|
||||
|
@ -119,6 +119,10 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(symm * vecX, vecB);
|
||||
matX = cholup.solve(matB);
|
||||
VERIFY_IS_APPROX(symm * matX, matB);
|
||||
|
||||
MatrixType neg = -symmLo;
|
||||
chollo.compute(neg);
|
||||
VERIFY(chollo.info()==NumericalIssue);
|
||||
}
|
||||
|
||||
// LDLT
|
||||
|
Loading…
Reference in New Issue
Block a user