Solver::Options uses shared_ptr to handle ownership.
Solver::Options::linear_solver_ordering and
Solver::Options::inner_iteration_ordering
were bare pointers even though Solver::Options took ownership of these
objects.
This lead to buggy user code and the inability to copy Solver::Options
objects around.
With this change, these naked pointers have been replaced by a
shared_ptr object which will managed the lifetime of these objects. This
also leads to simplification of the lifetime handling of these objects
inside the solver.
The Android.mk and Application.mk files have also been updated
to use a newer NDK revision which ships with LLVM's libc++.
Change-Id: I25161fb3ddf737be0b3e5dfd8e7a0039b22548cd
diff --git a/include/ceres/solver.h b/include/ceres/solver.h
index f0d5be6..c5bfadc 100644
--- a/include/ceres/solver.h
+++ b/include/ceres/solver.h
@@ -107,7 +107,6 @@
num_linear_solver_threads = 1;
- linear_solver_ordering = NULL;
use_postordering = false;
min_linear_solver_iterations = 1;
max_linear_solver_iterations = 500;
@@ -115,7 +114,6 @@
jacobi_scaling = true;
use_inner_iterations = false;
inner_iteration_tolerance = 1e-3;
- inner_iteration_ordering = NULL;
logging_type = PER_MINIMIZER_ITERATION;
minimizer_progress_to_stdout = false;
trust_region_problem_dump_directory = "/tmp";
@@ -126,7 +124,6 @@
update_state_every_iteration = false;
}
- ~Options();
// Minimizer options ----------------------------------------
// Ceres supports the two major families of optimization strategies -
@@ -480,10 +477,7 @@
// the parameter blocks into two groups, one for the points and one
// for the cameras, where the group containing the points has an id
// smaller than the group containing cameras.
- //
- // Once assigned, Solver::Options owns this pointer and will
- // deallocate the memory when destroyed.
- ParameterBlockOrdering* linear_solver_ordering;
+ shared_ptr<ParameterBlockOrdering> linear_solver_ordering;
// Sparse Cholesky factorization algorithms use a fill-reducing
// ordering to permute the columns of the Jacobian matrix. There
@@ -576,7 +570,7 @@
// the lower numbered groups are optimized before the higher
// number groups. Each group must be an independent set. Not
// all parameter blocks need to be present in the ordering.
- ParameterBlockOrdering* inner_iteration_ordering;
+ shared_ptr<ParameterBlockOrdering> inner_iteration_ordering;
// Generally speaking, inner iterations make significant progress
// in the early stages of the solve and then their contribution