mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-13 20:26:03 +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;
|
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 rows() const { return m_matrix.rows(); }
|
||||||
inline Index cols() const { return m_matrix.cols(); }
|
inline Index cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
@ -160,6 +172,7 @@ template<typename _MatrixType, int _UpLo> class LLT
|
|||||||
*/
|
*/
|
||||||
MatrixType m_matrix;
|
MatrixType m_matrix;
|
||||||
bool m_isInitialized;
|
bool m_isInitialized;
|
||||||
|
ComputationInfo m_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<int UpLo> struct ei_llt_inplace;
|
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.resize(size, size);
|
||||||
m_matrix = a;
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +234,14 @@ enum {
|
|||||||
IsSparse
|
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 {
|
enum TransformTraits {
|
||||||
Isometry = 0x1,
|
Isometry = 0x1,
|
||||||
Affine = 0x2,
|
Affine = 0x2,
|
||||||
|
@ -25,15 +25,7 @@
|
|||||||
#ifndef EIGEN_EIGENVALUES_COMMON_H
|
#ifndef EIGEN_EIGENVALUES_COMMON_H
|
||||||
#define 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
|
#endif // EIGEN_EIGENVALUES_COMMON_H
|
||||||
|
|
||||||
|
@ -119,6 +119,10 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
|
|||||||
VERIFY_IS_APPROX(symm * vecX, vecB);
|
VERIFY_IS_APPROX(symm * vecX, vecB);
|
||||||
matX = cholup.solve(matB);
|
matX = cholup.solve(matB);
|
||||||
VERIFY_IS_APPROX(symm * matX, matB);
|
VERIFY_IS_APPROX(symm * matX, matB);
|
||||||
|
|
||||||
|
MatrixType neg = -symmLo;
|
||||||
|
chollo.compute(neg);
|
||||||
|
VERIFY(chollo.info()==NumericalIssue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// LDLT
|
// LDLT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user