From 31ae83381106a7aaee5303710b818c13f42ceddc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 18 Jun 2020 10:12:01 +0200 Subject: Ceres: Update to the latest upstream version Using latest master because of various compilation error fixes. Brings a lot of recent development. From most interesting parts: - New threading model. - Tiny solver. - Compatibility with C++17. --- .../ceres/include/ceres/autodiff_cost_function.h | 89 ++- .../include/ceres/autodiff_first_order_function.h | 151 +++++ .../ceres/autodiff_local_parameterization.h | 40 +- extern/ceres/include/ceres/c_api.h | 4 +- extern/ceres/include/ceres/ceres.h | 9 +- .../include/ceres/conditioned_cost_function.h | 16 +- extern/ceres/include/ceres/context.h | 56 ++ extern/ceres/include/ceres/cost_function.h | 27 +- .../ceres/include/ceres/cost_function_to_functor.h | 612 ++---------------- extern/ceres/include/ceres/covariance.h | 79 ++- extern/ceres/include/ceres/crs_matrix.h | 5 +- extern/ceres/include/ceres/cubic_interpolation.h | 436 +++++++++++++ .../include/ceres/dynamic_autodiff_cost_function.h | 95 ++- extern/ceres/include/ceres/dynamic_cost_function.h | 56 ++ .../ceres/dynamic_cost_function_to_functor.h | 62 +- .../ceres/dynamic_numeric_diff_cost_function.h | 125 ++-- extern/ceres/include/ceres/evaluation_callback.h | 80 +++ extern/ceres/include/ceres/first_order_function.h | 54 ++ extern/ceres/include/ceres/fpclassify.h | 70 --- extern/ceres/include/ceres/gradient_checker.h | 23 +- extern/ceres/include/ceres/gradient_problem.h | 25 +- .../ceres/include/ceres/gradient_problem_solver.h | 128 ++-- .../ceres/include/ceres/internal/array_selector.h | 95 +++ extern/ceres/include/ceres/internal/autodiff.h | 291 +++++---- .../include/ceres/internal/disable_warnings.h | 2 +- extern/ceres/include/ceres/internal/eigen.h | 41 +- extern/ceres/include/ceres/internal/fixed_array.h | 573 ++++++++++++----- .../include/ceres/internal/householder_vector.h | 88 +++ .../ceres/internal/integer_sequence_algorithm.h | 165 +++++ .../include/ceres/internal/line_parameterization.h | 183 ++++++ extern/ceres/include/ceres/internal/macros.h | 170 ----- .../include/ceres/internal/manual_constructor.h | 208 ------- extern/ceres/include/ceres/internal/memory.h | 90 +++ extern/ceres/include/ceres/internal/numeric_diff.h | 198 +++--- .../ceres/include/ceres/internal/parameter_dims.h | 124 ++++ extern/ceres/include/ceres/internal/port.h | 62 +- extern/ceres/include/ceres/internal/scoped_ptr.h | 310 --------- .../include/ceres/internal/variadic_evaluate.h | 210 ++----- extern/ceres/include/ceres/iteration_callback.h | 64 +- extern/ceres/include/ceres/jet.h | 693 ++++++++++++--------- .../ceres/include/ceres/local_parameterization.h | 186 +++--- extern/ceres/include/ceres/loss_function.h | 85 +-- extern/ceres/include/ceres/normal_prior.h | 12 +- .../include/ceres/numeric_diff_cost_function.h | 147 ++--- extern/ceres/include/ceres/numeric_diff_options.h | 22 +- extern/ceres/include/ceres/ordered_groups.h | 47 +- extern/ceres/include/ceres/problem.h | 235 ++++--- extern/ceres/include/ceres/rotation.h | 255 ++++---- extern/ceres/include/ceres/sized_cost_function.h | 51 +- extern/ceres/include/ceres/solver.h | 494 ++++++++------- extern/ceres/include/ceres/tiny_solver.h | 368 +++++++++++ .../include/ceres/tiny_solver_autodiff_function.h | 206 ++++++ .../ceres/tiny_solver_cost_function_adapter.h | 142 +++++ extern/ceres/include/ceres/types.h | 71 ++- extern/ceres/include/ceres/version.h | 6 +- 55 files changed, 4773 insertions(+), 3363 deletions(-) create mode 100644 extern/ceres/include/ceres/autodiff_first_order_function.h create mode 100644 extern/ceres/include/ceres/context.h create mode 100644 extern/ceres/include/ceres/cubic_interpolation.h create mode 100644 extern/ceres/include/ceres/dynamic_cost_function.h create mode 100644 extern/ceres/include/ceres/evaluation_callback.h create mode 100644 extern/ceres/include/ceres/first_order_function.h delete mode 100644 extern/ceres/include/ceres/fpclassify.h create mode 100644 extern/ceres/include/ceres/internal/array_selector.h create mode 100644 extern/ceres/include/ceres/internal/householder_vector.h create mode 100644 extern/ceres/include/ceres/internal/integer_sequence_algorithm.h create mode 100644 extern/ceres/include/ceres/internal/line_parameterization.h delete mode 100644 extern/ceres/include/ceres/internal/macros.h delete mode 100644 extern/ceres/include/ceres/internal/manual_constructor.h create mode 100644 extern/ceres/include/ceres/internal/memory.h create mode 100644 extern/ceres/include/ceres/internal/parameter_dims.h delete mode 100644 extern/ceres/include/ceres/internal/scoped_ptr.h create mode 100644 extern/ceres/include/ceres/tiny_solver.h create mode 100644 extern/ceres/include/ceres/tiny_solver_autodiff_function.h create mode 100644 extern/ceres/include/ceres/tiny_solver_cost_function_adapter.h (limited to 'extern/ceres/include') diff --git a/extern/ceres/include/ceres/autodiff_cost_function.h b/extern/ceres/include/ceres/autodiff_cost_function.h index e7893e4828e..5e6e9c55db5 100644 --- a/extern/ceres/include/ceres/autodiff_cost_function.h +++ b/extern/ceres/include/ceres/autodiff_cost_function.h @@ -1,5 +1,5 @@ // Ceres Solver - A fast non-linear least squares minimizer -// Copyright 2015 Google Inc. All rights reserved. +// Copyright 2019 Google Inc. All rights reserved. // http://ceres-solver.org/ // // Redistribution and use in source and binary forms, with or without @@ -30,7 +30,7 @@ // // Create CostFunctions as needed by the least squares framework, with // Jacobians computed via automatic differentiation. For more -// information on automatic differentation, see the wikipedia article +// information on automatic differentiation, see the wikipedia article // at http://en.wikipedia.org/wiki/Automatic_differentiation // // To get an auto differentiated cost function, you must define a class with a @@ -54,7 +54,7 @@ // for a series of measurements, where there is an instance of the cost function // for each measurement k. // -// The actual cost added to the total problem is e^2, or (k - x'k)^2; however, +// The actual cost added to the total problem is e^2, or (k - x'y)^2; however, // the squaring is implicitly done by the optimization framework. // // To write an auto-differentiable cost function for the above model, first @@ -90,7 +90,7 @@ // Dimension of x ---------------+ | // Dimension of y ------------------+ // -// In this example, there is usually an instance for each measumerent of k. +// In this example, there is usually an instance for each measurement of k. // // In the instantiation above, the template parameters following // "MyScalarCostFunctor", "1, 2, 2", describe the functor as computing a @@ -110,12 +110,8 @@ // Dimension of x ------------------------------------+ | // Dimension of y ---------------------------------------+ // -// The framework can currently accommodate cost functions of up to 10 -// independent variables, and there is no limit on the dimensionality -// of each of them. -// // WARNING #1: Since the functor will get instantiated with different types for -// T, you must to convert from other numeric types to T before mixing +// T, you must convert from other numeric types to T before mixing // computations with other variables of type T. In the example above, this is // seen where instead of using k_ directly, k_ is wrapped with T(k_). // @@ -129,8 +125,9 @@ #ifndef CERES_PUBLIC_AUTODIFF_COST_FUNCTION_H_ #define CERES_PUBLIC_AUTODIFF_COST_FUNCTION_H_ +#include + #include "ceres/internal/autodiff.h" -#include "ceres/internal/scoped_ptr.h" #include "ceres/sized_cost_function.h" #include "ceres/types.h" #include "glog/logging.h" @@ -138,7 +135,7 @@ namespace ceres { // A cost function which computes the derivative of the cost with respect to -// the parameters (a.k.a. the jacobian) using an autodifferentiation framework. +// the parameters (a.k.a. the jacobian) using an auto differentiation framework. // The first template argument is the functor object, described in the header // comment. The second argument is the dimension of the residual (or // ceres::DYNAMIC to indicate it will be set at runtime), and subsequent @@ -153,27 +150,15 @@ namespace ceres { // of residuals for a single autodiff cost function at runtime. template // Number of parameters in block 9. -class AutoDiffCostFunction : public SizedCostFunction { + int... Ns> // Number of parameters in each parameter block. +class AutoDiffCostFunction : public SizedCostFunction { public: // Takes ownership of functor. Uses the template-provided value for the // number of residuals ("kNumResiduals"). - explicit AutoDiffCostFunction(CostFunctor* functor) - : functor_(functor) { - CHECK_NE(kNumResiduals, DYNAMIC) - << "Can't run the fixed-size constructor if the " - << "number of residuals is set to ceres::DYNAMIC."; + explicit AutoDiffCostFunction(CostFunctor* functor) : functor_(functor) { + static_assert(kNumResiduals != DYNAMIC, + "Can't run the fixed-size constructor if the number of " + "residuals is set to ceres::DYNAMIC."); } // Takes ownership of functor. Ignores the template-provided @@ -183,13 +168,10 @@ class AutoDiffCostFunction : public SizedCostFunction - ::set_num_residuals(num_residuals); + static_assert(kNumResiduals == DYNAMIC, + "Can't run the dynamic-size constructor if the number of " + "residuals is not ceres::DYNAMIC."); + SizedCostFunction::set_num_residuals(num_residuals); } virtual ~AutoDiffCostFunction() {} @@ -197,29 +179,28 @@ class AutoDiffCostFunction : public SizedCostFunction