diff --git a/gtsam/base/cholesky.cpp b/gtsam/base/cholesky.cpp index 0b03e7bda..cad43381b 100644 --- a/gtsam/base/cholesky.cpp +++ b/gtsam/base/cholesky.cpp @@ -168,8 +168,10 @@ Eigen::LDLT::TranspositionType ldlPartial(Matrix& ABC, size_t nFrontal) ldlt.compute(ABC.block(0,0,nFrontal,nFrontal).selfadjointView()); if(ldlt.vectorD().unaryExpr(boost::bind(less(), _1, 0.0)).any()) { - gtsam::print(Matrix(ldlt.matrixU()), "U: "); - gtsam::print(Vector(ldlt.vectorD()), "D: "); + if(debug) { + gtsam::print(Matrix(ldlt.matrixU()), "U: "); + gtsam::print(Vector(ldlt.vectorD()), "D: "); + } throw NegativeMatrixException(); } diff --git a/gtsam/nonlinear/NonlinearOptimizer-inl.h b/gtsam/nonlinear/NonlinearOptimizer-inl.h index 1102df92f..4e633660a 100644 --- a/gtsam/nonlinear/NonlinearOptimizer-inl.h +++ b/gtsam/nonlinear/NonlinearOptimizer-inl.h @@ -203,7 +203,8 @@ namespace gtsam { } } } catch(const NegativeMatrixException& e) { - cout << "Negative matrix, increasing lambda" << endl; + if(verbosity >= Parameters::LAMBDA) + cout << "Negative matrix, increasing lambda" << endl; // Either we're not cautious, or the same lambda was worse than the current error. // The more adventurous lambda was worse too, so make lambda more conservative // and keep the same values.