Merge branch 'master' of https://code.google.com/p/ceres-solver
diff --git a/examples/bundle_adjuster.cc b/examples/bundle_adjuster.cc
index 61cd41f..885dbe2 100644
--- a/examples/bundle_adjuster.cc
+++ b/examples/bundle_adjuster.cc
@@ -75,7 +75,9 @@
DEFINE_int32(num_iterations, 5, "Number of iterations");
DEFINE_int32(num_threads, 1, "Number of threads");
-DEFINE_double(eta, 1e-2, "Default value for eta.");
+DEFINE_double(eta, 1e-2, "Default value for eta. Eta determines the "
+ "accuracy of each linear solve of the truncated newton step. "
+ "Changing this parameter can affect solve performance ");
DEFINE_bool(use_schur_ordering, false, "Use automatic Schur ordering.");
DEFINE_bool(use_quaternions, false, "If true, uses quaternions to represent "
"rotations. If false, angle axis is used");
@@ -99,7 +101,7 @@
options->linear_solver_type = ceres::CONJUGATE_GRADIENTS;
} else if (FLAGS_solver_type == "dense_qr") {
// DENSE_QR is included here for completeness, but actually using
- // this opttion is a bad idea due to the amount of memory needed
+ // this option is a bad idea due to the amount of memory needed
// to store even the smallest of the bundle adjustment jacobian
// arrays
options->linear_solver_type = ceres::DENSE_QR;
@@ -108,8 +110,20 @@
<< FLAGS_solver_type;
}
- if (options->linear_solver_type == ceres::ITERATIVE_SCHUR ||
- options->linear_solver_type == ceres::CONJUGATE_GRADIENTS) {
+ if (options->linear_solver_type == ceres::CONJUGATE_GRADIENTS) {
+ options->linear_solver_min_num_iterations = 5;
+ if (FLAGS_preconditioner_type == "identity") {
+ options->preconditioner_type = ceres::IDENTITY;
+ } else if (FLAGS_preconditioner_type == "jacobi") {
+ options->preconditioner_type = ceres::JACOBI;
+ } else {
+ LOG(FATAL) << "For CONJUGATE_GRADIENTS, only identity and jacobian "
+ << "preconditioners are supported. Got: "
+ << FLAGS_preconditioner_type;
+ }
+ }
+
+ if (options->linear_solver_type == ceres::ITERATIVE_SCHUR) {
options->linear_solver_min_num_iterations = 5;
if (FLAGS_preconditioner_type == "identity") {
options->preconditioner_type = ceres::IDENTITY;
@@ -123,7 +137,7 @@
options->preconditioner_type = ceres::CLUSTER_TRIDIAGONAL;
} else {
LOG(FATAL) << "Unknown ceres preconditioner type: "
- << FLAGS_preconditioner_type;
+ << FLAGS_preconditioner_type;
}
}
diff --git a/internal/ceres/solver_impl_test.cc b/internal/ceres/solver_impl_test.cc
index 6f22357..99733a2 100644
--- a/internal/ceres/solver_impl_test.cc
+++ b/internal/ceres/solver_impl_test.cc
@@ -37,7 +37,6 @@
#include "ceres/solver_impl.h"
#include "ceres/sized_cost_function.h"
-
namespace ceres {
namespace internal {
@@ -363,14 +362,6 @@
EXPECT_EQ(parameter_blocks[2]->user_state(), &y);
}
-
-TEST(SolverImpl, CreateLinearSolverConjugateGradients) {
- Solver::Options options;
- options.linear_solver_type = CONJUGATE_GRADIENTS;
- string error;
- EXPECT_FALSE(SolverImpl::CreateLinearSolver(&options, &error));
-}
-
#ifdef CERES_NO_SUITESPARSE
TEST(SolverImpl, CreateLinearSolverNoSuiteSparse) {
Solver::Options options;
diff --git a/internal/ceres/symmetric_linear_solver_test.cc b/internal/ceres/symmetric_linear_solver_test.cc
index 365c9c0..8a7ce68 100644
--- a/internal/ceres/symmetric_linear_solver_test.cc
+++ b/internal/ceres/symmetric_linear_solver_test.cc
@@ -36,6 +36,7 @@
// more badly conditioned problem.
#include "gtest/gtest.h"
+#include "ceres/conjugate_gradients_solver.h"
#include "ceres/linear_solver.h"
#include "ceres/triplet_sparse_matrix.h"
#include "ceres/internal/eigen.h"
@@ -63,14 +64,13 @@
LinearSolver::Options options;
options.max_num_iterations = 10;
options.constant_sparsity = false;
- options.type = CONJUGATE_GRADIENTS;
LinearSolver::PerSolveOptions per_solve_options;
per_solve_options.r_tolerance = 1e-9;
- scoped_ptr<LinearSolver> solver(LinearSolver::Create(options));
+ ConjugateGradientsSolver solver(options);
LinearSolver::Summary summary =
- solver->Solve(A.get(), b.data(), per_solve_options, x.data());
+ solver.Solve(A.get(), b.data(), per_solve_options, x.data());
EXPECT_EQ(summary.termination_type, TOLERANCE);
ASSERT_EQ(summary.num_iterations, 1);
@@ -121,15 +121,13 @@
LinearSolver::Options options;
options.max_num_iterations = 10;
- options.constant_sparsity = false;
- options.type = CONJUGATE_GRADIENTS;
LinearSolver::PerSolveOptions per_solve_options;
per_solve_options.r_tolerance = 1e-9;
- scoped_ptr<LinearSolver> solver(LinearSolver::Create(options));
+ ConjugateGradientsSolver solver(options);
LinearSolver::Summary summary =
- solver->Solve(A.get(), b.data(), per_solve_options, x.data());
+ solver.Solve(A.get(), b.data(), per_solve_options, x.data());
EXPECT_EQ(summary.termination_type, TOLERANCE);