aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2010-06-12 10:12:22 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2010-06-12 10:12:22 +0200
commit03331552a9daf670d510f26089c9584ab0a5e655 (patch)
treee79d20fd30f793ff5b4c771389306fe5d693bdeb
parenta25749ade9ee4c97fab5a801314a733a8a6a6e30 (diff)
add a info() function in LLT to report on succes/faillure
-rw-r--r--Eigen/src/Cholesky/LLT.h18
-rw-r--r--Eigen/src/Core/util/Constants.h8
-rw-r--r--Eigen/src/Eigenvalues/EigenvaluesCommon.h10
-rw-r--r--test/cholesky.cpp4
4 files changed, 30 insertions, 10 deletions
diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h
index 6e7660ddf..9abe5cf5c 100644
--- a/Eigen/src/Cholesky/LLT.h
+++ b/Eigen/src/Cholesky/LLT.h
@@ -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;
}
diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h
index 2335a3f08..831b82890 100644
--- a/Eigen/src/Core/util/Constants.h
+++ b/Eigen/src/Core/util/Constants.h
@@ -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,
diff --git a/Eigen/src/Eigenvalues/EigenvaluesCommon.h b/Eigen/src/Eigenvalues/EigenvaluesCommon.h
index d5fff9ba1..749bea795 100644
--- a/Eigen/src/Eigenvalues/EigenvaluesCommon.h
+++ b/Eigen/src/Eigenvalues/EigenvaluesCommon.h
@@ -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
diff --git a/test/cholesky.cpp b/test/cholesky.cpp
index 666cee20f..54ff94f32 100644
--- a/test/cholesky.cpp
+++ b/test/cholesky.cpp
@@ -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