From 1ebaff8a10e155f1fb16ac0c7e63eeb6f4d9eb30 Mon Sep 17 00:00:00 2001 From: Sameer Agarwal Date: Mon, 27 Feb 2017 14:58:47 -0800 Subject: [PATCH] Two bug fixes. 1. Add schur_templates.cc to Android.mk 2. When detecting the Schur structure of the Jacobian, the check for whether linear solver being used is indeed of Schur type or not, should use the LinearSolver::Options struct created and populated by the preprocessor rather than depending on the value in the input Solver::Options. The reason is that the preprocessor may change the linear solver type depending on the lack of a Schur structure in the problem. Change-Id: I6f018f6817c05d704409181c7b1e25155528ab84 --- internal/ceres/solver.cc | 8 ++++++-- jni/Android.mk | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/ceres/solver.cc b/internal/ceres/solver.cc index 716307a46..705364bda 100644 --- a/internal/ceres/solver.cc +++ b/internal/ceres/solver.cc @@ -382,7 +382,7 @@ void PostSolveSummarize(const internal::PreprocessedProblem& pp, &(summary->inner_iteration_ordering_used)); summary->inner_iterations_used = pp.inner_iteration_minimizer.get() != NULL; // NOLINT - summary->linear_solver_type_used = pp.options.linear_solver_type; + summary->linear_solver_type_used = pp.linear_solver_options.type; summary->num_linear_solver_threads_used = pp.options.num_linear_solver_threads; // NOLINT summary->num_threads_used = pp.options.num_threads; summary->preconditioner_type_used = pp.options.preconditioner_type; // NOLINT @@ -540,7 +540,11 @@ void Solver::Solve(const Solver::Options& options, const bool status = preprocessor->Preprocess(modified_options, problem_impl, &pp); - if (IsSchurType(pp.options.linear_solver_type)) { + // We check the linear_solver_options.type rather than + // modified_options.linear_solver_type because, depending on the + // lack of a Schur structure, the preprocessor may change the linear + // solver type. + if (IsSchurType(pp.linear_solver_options.type)) { // TODO(sameeragarwal): We can likely eliminate the duplicate call // to DetectStructure here and inside the linear solver, by // calling this in the preprocessor. diff --git a/jni/Android.mk b/jni/Android.mk index 565eeb3e6..d60c0fcd7 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -181,6 +181,7 @@ LOCAL_SRC_FILES := $(CERES_SRC_PATH)/array_utils.cc \ $(CERES_SRC_PATH)/schur_complement_solver.cc \ $(CERES_SRC_PATH)/schur_eliminator.cc \ $(CERES_SRC_PATH)/schur_jacobi_preconditioner.cc \ + $(CERES_SRC_PATH)/schur_templates.cc \ $(CERES_SRC_PATH)/scratch_evaluate_preparer.cc \ $(CERES_SRC_PATH)/solver.cc \ $(CERES_SRC_PATH)/solver_utils.cc \