A number of bug fixes. 1. Fix a build breakage in graph_test. 2. Respect Solver::Options::min_num_linear_solver_iterations in conjugate_gradients_solver.cc Thanks to Johannes Schönberger for reporting these. Change-Id: Ib32e3929bf5d92dd576ae5b53d4d88797095136e
diff --git a/docs/source/solving.rst b/docs/source/solving.rst index 5f3711a..790d5f3 100644 --- a/docs/source/solving.rst +++ b/docs/source/solving.rst
@@ -1304,7 +1304,7 @@ .. member:: int Solver::Options::min_linear_solver_iterations - Default: ``1`` + Default: ``0`` Minimum number of iterations used by the linear solver. This only makes sense when the linear solver is an iterative solver, e.g.,
diff --git a/include/ceres/solver.h b/include/ceres/solver.h index ef391a7..0af34ca 100644 --- a/include/ceres/solver.h +++ b/include/ceres/solver.h
@@ -120,7 +120,7 @@ num_linear_solver_threads = 1; use_postordering = false; dynamic_sparsity = false; - min_linear_solver_iterations = 1; + min_linear_solver_iterations = 0; max_linear_solver_iterations = 500; eta = 1e-1; jacobi_scaling = true;
diff --git a/internal/ceres/conjugate_gradients_solver.cc b/internal/ceres/conjugate_gradients_solver.cc index 524cb8a..5e71501 100644 --- a/internal/ceres/conjugate_gradients_solver.cc +++ b/internal/ceres/conjugate_gradients_solver.cc
@@ -101,7 +101,7 @@ A->RightMultiply(x, tmp.data()); r = bref - tmp; double norm_r = r.norm(); - if (norm_r <= tol_r) { + if (options_.min_num_iteratios == 0 && norm_r <= tol_r) { summary.termination_type = LINEAR_SOLVER_SUCCESS; summary.message = StringPrintf("Convergence. |r| = %e <= %e.", norm_r, tol_r); @@ -114,7 +114,8 @@ double Q0 = -1.0 * xref.dot(bref + r); for (summary.num_iterations = 1; - summary.num_iterations < options_.max_num_iterations; + summary.num_iterations > options_.min_num_iterations && + summary.num_iterations < options_.max_num_iterations ++summary.num_iterations) { // Apply preconditioner if (per_solve_options.preconditioner != NULL) {
diff --git a/internal/ceres/graph_test.cc b/internal/ceres/graph_test.cc index a1521d8..033d1d9 100644 --- a/internal/ceres/graph_test.cc +++ b/internal/ceres/graph_test.cc
@@ -58,14 +58,14 @@ Graph<int> graph; graph.AddVertex(0); graph.AddVertex(1); - graph.AddEdge(0, 1) + graph.AddEdge(0, 1); const HashSet<int>& vertices = graph.vertices(); EXPECT_EQ(vertices.size(), 2); // Try adding the vertex again with a new weight. - graph.AddVertex(0, 3.0); + graph.AddVertex(0); EXPECT_EQ(vertices.size(), 2); // Rest of the graph remains the same.