From 0e17310e23321b61d5196a05521a731fbe20b13c Mon Sep 17 00:00:00 2001 From: Kai Ni Date: Sat, 16 Jan 2010 22:56:57 +0000 Subject: [PATCH] remove the printf --- cpp/iterative-inl.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cpp/iterative-inl.h b/cpp/iterative-inl.h index c4c26cece..61904e3b3 100644 --- a/cpp/iterative-inl.h +++ b/cpp/iterative-inl.h @@ -22,17 +22,14 @@ namespace gtsam { template V conjugateGradients(const S& Ab, V x, bool verbose, double epsilon, double epsilon_abs, size_t maxIterations, bool steepest = false) { - //GTSAM_PRINT(Ab); if (maxIterations == 0) maxIterations = dim(x) * (steepest ? 10 : 1); size_t reset = (size_t)(sqrt(dim(x))+0.5); // when to reset // Start with g0 = A'*(A*x0-b), d0 = - g0 // i.e., first step is in direction of negative gradient V g = Ab.gradient(x); - //print(g, "g"); V d = -g; double dotg0 = dot(g, g), prev_dotg = dotg0; - //printf("dotg0:%g epsilon_abs:%g\n", dotg0, epsilon_abs); if (dotg0 < epsilon_abs) return x; double threshold = epsilon * epsilon * dotg0; @@ -45,16 +42,15 @@ namespace gtsam { // calculate optimal step-size E Ad = Ab * d; - //printf("dot(d, g):%g dot(Ad, Ad):%g\n", dot(d, g), dot(Ad, Ad)); double alpha = -dot(d, g) / dot(Ad, Ad); - //printf("alpha:%g\n", alpha); // do step in new search direction x = x + alpha * d; if (k==maxIterations) break; // update gradient (or re-calculate at reset time) - g = (k%reset==0) ? Ab.gradient(x) : g + alpha * (Ab ^ Ad); + // g = (k%reset==0) ? Ab.gradient(x) : g + alpha * (Ab ^ Ad); + g = g + alpha * (Ab ^ Ad); // check for convergence double dotg = dot(g, g);