Added detail to NegativeMatrixException
parent
91d727d4eb
commit
93c601d03c
|
|
@ -168,11 +168,10 @@ Eigen::LDLT<Matrix>::TranspositionType ldlPartial(Matrix& ABC, size_t nFrontal)
|
||||||
ldlt.compute(ABC.block(0,0,nFrontal,nFrontal).selfadjointView<Eigen::Upper>());
|
ldlt.compute(ABC.block(0,0,nFrontal,nFrontal).selfadjointView<Eigen::Upper>());
|
||||||
|
|
||||||
if(ldlt.vectorD().unaryExpr(boost::bind(less<double>(), _1, 0.0)).any()) {
|
if(ldlt.vectorD().unaryExpr(boost::bind(less<double>(), _1, 0.0)).any()) {
|
||||||
if(debug) {
|
if(ISDEBUG("detailed_exceptions"))
|
||||||
gtsam::print(Matrix(ldlt.matrixU()), "U: ");
|
throw NegativeMatrixException(NegativeMatrixException::Detail(ABC, ldlt.matrixU(), ldlt.vectorD()));
|
||||||
gtsam::print(Vector(ldlt.vectorD()), "D: ");
|
else
|
||||||
}
|
throw NegativeMatrixException();
|
||||||
throw NegativeMatrixException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector sqrtD = ldlt.vectorD().cwiseSqrt();
|
Vector sqrtD = ldlt.vectorD().cwiseSqrt();
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,29 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gtsam/base/Matrix.h>
|
#include <gtsam/base/Matrix.h>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An exception indicating an attempt to factor a negative or indefinite matrix.
|
* An exception indicating an attempt to factor a negative or indefinite matrix.
|
||||||
|
* If detailed exceptions are enabled
|
||||||
|
* \todo fill this in
|
||||||
*/
|
*/
|
||||||
class NegativeMatrixException : public std::exception { };
|
struct NegativeMatrixException : public std::exception {
|
||||||
|
/// Detail for NegativeMatrixException
|
||||||
|
struct Detail {
|
||||||
|
Matrix A; ///< The original matrix attempted to factor
|
||||||
|
Matrix U; ///< The produced upper-triangular factor
|
||||||
|
Matrix D; ///< The produced diagonal factor
|
||||||
|
Detail(const Matrix& _A, const Matrix& _U, const Matrix& _D) /**< Detail constructor */ : A(_A), U(_A), D(_D) {}
|
||||||
|
};
|
||||||
|
const boost::shared_ptr<const Detail> detail; ///< Detail
|
||||||
|
NegativeMatrixException() /**< Constructor with no detail */ {}
|
||||||
|
NegativeMatrixException(const Detail& _detail) /**< Constructor with detail */ : detail(new Detail(_detail)) {}
|
||||||
|
NegativeMatrixException(const boost::shared_ptr<Detail>& _detail) /**< Constructor with detail */ : detail(_detail) {}
|
||||||
|
virtual ~NegativeMatrixException() throw() {}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Careful" Cholesky computes the positive square-root of a positive symmetric
|
* "Careful" Cholesky computes the positive square-root of a positive symmetric
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue