From 2f72d585c504c9939f89030a8066a74d33d8abf6 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Sun, 7 Mar 2010 00:10:02 +0000 Subject: [PATCH] be a bit more verbose --- cpp/iterative-inl.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cpp/iterative-inl.h b/cpp/iterative-inl.h index 6a8ac6869..cb325b6df 100644 --- a/cpp/iterative-inl.h +++ b/cpp/iterative-inl.h @@ -115,14 +115,16 @@ namespace gtsam { V conjugateGradients(const S& Ab, V x, bool verbose, double epsilon, double epsilon_abs, size_t maxIterations, bool steepest = false) { - CGState state(Ab, x, verbose, epsilon, epsilon_abs, maxIterations, - steepest); - if (state.gamma < state.threshold) return x; - + CGState state(Ab, x, verbose, epsilon, epsilon_abs, maxIterations,steepest); if (verbose) cout << "CG: epsilon = " << epsilon << ", maxIterations = " << state.maxIterations << ", ||g0||^2 = " << state.gamma << ", threshold = " << state.threshold << endl; + if (state.gamma < state.threshold) { + if (verbose) cout << "||g0||^2 < threshold, exiting immediately !" << endl; + return x; + } + // loop maxIterations times while (!state.step(Ab, x)) ;