From ce9669003acf32bd9f6badd2e04bde1ea897f46d Mon Sep 17 00:00:00 2001 From: Alex Stewart Date: Sun, 6 Feb 2022 21:14:16 +0000 Subject: [PATCH] Add const accessor for functor wrapped by auto/numeric-diff objects - The intended use-case for these accessors is in client code tests to support verification of the configuration with which cost functions were constructed. Change-Id: Ib77afa6409804ba7f724138f579e0c51b154f5ad --- include/ceres/autodiff_cost_function.h | 2 ++ include/ceres/autodiff_first_order_function.h | 2 ++ include/ceres/autodiff_local_parameterization.h | 2 ++ include/ceres/autodiff_manifold.h | 2 ++ include/ceres/numeric_diff_cost_function.h | 2 ++ include/ceres/numeric_diff_first_order_function.h | 2 ++ 6 files changed, 12 insertions(+) diff --git a/include/ceres/autodiff_cost_function.h b/include/ceres/autodiff_cost_function.h index 207f0a416..993daf159 100644 --- a/include/ceres/autodiff_cost_function.h +++ b/include/ceres/autodiff_cost_function.h @@ -215,6 +215,8 @@ class AutoDiffCostFunction : public SizedCostFunction { jacobians); }; + const CostFunctor & functor() const { return *functor_; } + private: std::unique_ptr functor_; Ownership ownership_; diff --git a/include/ceres/autodiff_first_order_function.h b/include/ceres/autodiff_first_order_function.h index b98d84565..d0280b045 100644 --- a/include/ceres/autodiff_first_order_function.h +++ b/include/ceres/autodiff_first_order_function.h @@ -142,6 +142,8 @@ class AutoDiffFirstOrderFunction : public FirstOrderFunction { int NumParameters() const override { return kNumParameters; } + const FirstOrderFunctor & functor() const { return *functor_; } + private: std::unique_ptr functor_; }; diff --git a/include/ceres/autodiff_local_parameterization.h b/include/ceres/autodiff_local_parameterization.h index d694376fd..4ca4a501b 100644 --- a/include/ceres/autodiff_local_parameterization.h +++ b/include/ceres/autodiff_local_parameterization.h @@ -143,6 +143,8 @@ class AutoDiffLocalParameterization : public LocalParameterization { int GlobalSize() const override { return kGlobalSize; } int LocalSize() const override { return kLocalSize; } + const Functor & functor() const { return *functor_; } + private: std::unique_ptr functor_; }; diff --git a/include/ceres/autodiff_manifold.h b/include/ceres/autodiff_manifold.h index 8a7601f02..96735335c 100644 --- a/include/ceres/autodiff_manifold.h +++ b/include/ceres/autodiff_manifold.h @@ -173,6 +173,8 @@ class AutoDiffManifold : public Manifold { bool MinusJacobian(const double* x, double* jacobian) const override; + const Functor & functor() const { return *functor_; } + private: std::unique_ptr functor_; }; diff --git a/include/ceres/numeric_diff_cost_function.h b/include/ceres/numeric_diff_cost_function.h index cf7971cde..43fe768a4 100644 --- a/include/ceres/numeric_diff_cost_function.h +++ b/include/ceres/numeric_diff_cost_function.h @@ -246,6 +246,8 @@ class NumericDiffCostFunction : public SizedCostFunction { return true; } + const CostFunctor & functor() const { return *functor_; } + private: std::unique_ptr functor_; Ownership ownership_; diff --git a/include/ceres/numeric_diff_first_order_function.h b/include/ceres/numeric_diff_first_order_function.h index 866383549..cd24c969c 100644 --- a/include/ceres/numeric_diff_first_order_function.h +++ b/include/ceres/numeric_diff_first_order_function.h @@ -151,6 +151,8 @@ class NumericDiffFirstOrderFunction : public FirstOrderFunction { int NumParameters() const override { return kNumParameters; } + const FirstOrderFunctor & functor() const { return *functor_; } + private: std::unique_ptr functor_; Ownership ownership_;