fix formatting for public header files
- ensure all public headers files adhere to clang-format
- preserve one-per-line for enums by adding trailing comma
- preserve include order for en/disable_warning.h
Change-Id: I78dbd0527a294ab2ec5f074fb426e48b20c393e6
diff --git a/include/ceres/c_api.h b/include/ceres/c_api.h
index 0e6e590..91b82bf 100644
--- a/include/ceres/c_api.h
+++ b/include/ceres/c_api.h
@@ -38,8 +38,10 @@
#ifndef CERES_PUBLIC_C_API_H_
#define CERES_PUBLIC_C_API_H_
+// clang-format off
#include "ceres/internal/port.h"
#include "ceres/internal/disable_warnings.h"
+// clang-format on
#ifdef __cplusplus
extern "C" {
diff --git a/include/ceres/cost_function_to_functor.h b/include/ceres/cost_function_to_functor.h
index 1beeb90..9364293 100644
--- a/include/ceres/cost_function_to_functor.h
+++ b/include/ceres/cost_function_to_functor.h
@@ -144,8 +144,7 @@
// Extract parameter block pointers from params.
using Indices =
- std::make_integer_sequence<int,
- ParameterDims::kNumParameterBlocks>;
+ std::make_integer_sequence<int, ParameterDims::kNumParameterBlocks>;
std::array<const T*, ParameterDims::kNumParameterBlocks> parameter_blocks =
GetParameterPointers<T>(params, Indices());
diff --git a/include/ceres/dynamic_autodiff_cost_function.h b/include/ceres/dynamic_autodiff_cost_function.h
index 76ca4f2..7ccf6a8 100644
--- a/include/ceres/dynamic_autodiff_cost_function.h
+++ b/include/ceres/dynamic_autodiff_cost_function.h
@@ -79,7 +79,6 @@
template <typename CostFunctor, int Stride = 4>
class DynamicAutoDiffCostFunction : public DynamicCostFunction {
public:
-
// Takes ownership by default.
DynamicAutoDiffCostFunction(CostFunctor* functor,
Ownership ownership = TAKE_OWNERSHIP)
diff --git a/include/ceres/gradient_problem_solver.h b/include/ceres/gradient_problem_solver.h
index 181699d..9fab62e 100644
--- a/include/ceres/gradient_problem_solver.h
+++ b/include/ceres/gradient_problem_solver.h
@@ -62,7 +62,8 @@
// Minimizer options ----------------------------------------
LineSearchDirectionType line_search_direction_type = LBFGS;
LineSearchType line_search_type = WOLFE;
- NonlinearConjugateGradientType nonlinear_conjugate_gradient_type = FLETCHER_REEVES;
+ NonlinearConjugateGradientType nonlinear_conjugate_gradient_type =
+ FLETCHER_REEVES;
// The LBFGS hessian approximation is a low rank approximation to
// the inverse of the Hessian matrix. The rank of the
diff --git a/include/ceres/internal/autodiff.h b/include/ceres/internal/autodiff.h
index 71b7bae..9d7de75 100644
--- a/include/ceres/internal/autodiff.h
+++ b/include/ceres/internal/autodiff.h
@@ -229,7 +229,9 @@
// End of 'recursion'. Nothing more to do.
template <int ParameterIdx, int Total>
-struct Make1stOrderPerturbations<std::integer_sequence<int>, ParameterIdx, Total> {
+struct Make1stOrderPerturbations<std::integer_sequence<int>,
+ ParameterIdx,
+ Total> {
template <typename T, typename JetT>
static void Apply(T const* const* /* NOT USED */, JetT* /* NOT USED */) {}
};
diff --git a/include/ceres/internal/disable_warnings.h b/include/ceres/internal/disable_warnings.h
index fd848fe..d7766a0 100644
--- a/include/ceres/internal/disable_warnings.h
+++ b/include/ceres/internal/disable_warnings.h
@@ -34,11 +34,11 @@
#define CERES_WARNINGS_DISABLED
#ifdef _MSC_VER
-#pragma warning( push )
+#pragma warning(push)
// Disable the warning C4251 which is triggered by stl classes in
// Ceres' public interface. To quote MSDN: "C4251 can be ignored "
// "if you are deriving from a type in the Standard C++ Library"
-#pragma warning( disable : 4251 )
+#pragma warning(disable : 4251)
#endif
#endif // CERES_WARNINGS_DISABLED
diff --git a/include/ceres/internal/eigen.h b/include/ceres/internal/eigen.h
index 59545df..b6d0b7f 100644
--- a/include/ceres/internal/eigen.h
+++ b/include/ceres/internal/eigen.h
@@ -36,31 +36,26 @@
namespace ceres {
typedef Eigen::Matrix<double, Eigen::Dynamic, 1> Vector;
-typedef Eigen::Matrix<double,
- Eigen::Dynamic,
- Eigen::Dynamic,
- Eigen::RowMajor> Matrix;
+typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
+ Matrix;
typedef Eigen::Map<Vector> VectorRef;
typedef Eigen::Map<Matrix> MatrixRef;
typedef Eigen::Map<const Vector> ConstVectorRef;
typedef Eigen::Map<const Matrix> ConstMatrixRef;
// Column major matrices for DenseSparseMatrix/DenseQRSolver
-typedef Eigen::Matrix<double,
- Eigen::Dynamic,
- Eigen::Dynamic,
- Eigen::ColMajor> ColMajorMatrix;
+typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>
+ ColMajorMatrix;
-typedef Eigen::Map<ColMajorMatrix, 0,
- Eigen::Stride<Eigen::Dynamic, 1>> ColMajorMatrixRef;
+typedef Eigen::Map<ColMajorMatrix, 0, Eigen::Stride<Eigen::Dynamic, 1>>
+ ColMajorMatrixRef;
-typedef Eigen::Map<const ColMajorMatrix,
- 0,
- Eigen::Stride<Eigen::Dynamic, 1>> ConstColMajorMatrixRef;
+typedef Eigen::Map<const ColMajorMatrix, 0, Eigen::Stride<Eigen::Dynamic, 1>>
+ ConstColMajorMatrixRef;
// C++ does not support templated typdefs, thus the need for this
// struct so that we can support statically sized Matrix and Maps.
- template <int num_rows = Eigen::Dynamic, int num_cols = Eigen::Dynamic>
+template <int num_rows = Eigen::Dynamic, int num_cols = Eigen::Dynamic>
struct EigenTypes {
typedef Eigen::Matrix<double,
num_rows,
diff --git a/include/ceres/internal/fixed_array.h b/include/ceres/internal/fixed_array.h
index f8ef02d..dcbddcd 100644
--- a/include/ceres/internal/fixed_array.h
+++ b/include/ceres/internal/fixed_array.h
@@ -30,6 +30,7 @@
#ifndef CERES_PUBLIC_INTERNAL_FIXED_ARRAY_H_
#define CERES_PUBLIC_INTERNAL_FIXED_ARRAY_H_
+#include <Eigen/Core> // For Eigen::aligned_allocator
#include <algorithm>
#include <array>
#include <cstddef>
@@ -37,8 +38,6 @@
#include <tuple>
#include <type_traits>
-#include <Eigen/Core> // For Eigen::aligned_allocator
-
#include "ceres/internal/memory.h"
#include "glog/logging.h"
diff --git a/include/ceres/internal/integer_sequence_algorithm.h b/include/ceres/internal/integer_sequence_algorithm.h
index 170acac..8c0f3bc 100644
--- a/include/ceres/internal/integer_sequence_algorithm.h
+++ b/include/ceres/internal/integer_sequence_algorithm.h
@@ -62,7 +62,8 @@
// Strip of and sum the first number.
template <typename T, T N, T... Ns>
struct SumImpl<std::integer_sequence<T, N, Ns...>> {
- static constexpr T Value = N + SumImpl<std::integer_sequence<T, Ns...>>::Value;
+ static constexpr T Value =
+ N + SumImpl<std::integer_sequence<T, Ns...>>::Value;
};
// Strip of and sum the first two numbers.
@@ -129,10 +130,14 @@
struct ExclusiveScanImpl;
template <typename T, T Sum, T N, T... Ns, T... Rs>
-struct ExclusiveScanImpl<T, Sum, std::integer_sequence<T, N, Ns...>,
+struct ExclusiveScanImpl<T,
+ Sum,
+ std::integer_sequence<T, N, Ns...>,
std::integer_sequence<T, Rs...>> {
using Type =
- typename ExclusiveScanImpl<T, Sum + N, std::integer_sequence<T, Ns...>,
+ typename ExclusiveScanImpl<T,
+ Sum + N,
+ std::integer_sequence<T, Ns...>,
std::integer_sequence<T, Rs..., Sum>>::Type;
};
diff --git a/include/ceres/internal/numeric_diff.h b/include/ceres/internal/numeric_diff.h
index fb2e00b..ff7a2c3 100644
--- a/include/ceres/internal/numeric_diff.h
+++ b/include/ceres/internal/numeric_diff.h
@@ -47,15 +47,17 @@
#include "ceres/types.h"
#include "glog/logging.h"
-
namespace ceres {
namespace internal {
// This is split from the main class because C++ doesn't allow partial template
// specializations for member functions. The alternative is to repeat the main
// class for differing numbers of parameters, which is also unfortunate.
-template <typename CostFunctor, NumericDiffMethodType kMethod,
- int kNumResiduals, typename ParameterDims, int kParameterBlock,
+template <typename CostFunctor,
+ NumericDiffMethodType kMethod,
+ int kNumResiduals,
+ typename ParameterDims,
+ int kParameterBlock,
int kParameterBlockSize>
struct NumericDiff {
// Mutates parameters but must restore them before return.
@@ -66,23 +68,23 @@
int num_residuals,
int parameter_block_index,
int parameter_block_size,
- double **parameters,
- double *jacobian) {
+ double** parameters,
+ double* jacobian) {
+ using Eigen::ColMajor;
using Eigen::Map;
using Eigen::Matrix;
using Eigen::RowMajor;
- using Eigen::ColMajor;
DCHECK(jacobian);
const int num_residuals_internal =
(kNumResiduals != ceres::DYNAMIC ? kNumResiduals : num_residuals);
const int parameter_block_index_internal =
- (kParameterBlock != ceres::DYNAMIC ? kParameterBlock :
- parameter_block_index);
+ (kParameterBlock != ceres::DYNAMIC ? kParameterBlock
+ : parameter_block_index);
const int parameter_block_size_internal =
- (kParameterBlockSize != ceres::DYNAMIC ? kParameterBlockSize :
- parameter_block_size);
+ (kParameterBlockSize != ceres::DYNAMIC ? kParameterBlockSize
+ : parameter_block_size);
typedef Matrix<double, kNumResiduals, 1> ResidualVector;
typedef Matrix<double, kParameterBlockSize, 1> ParameterVector;
@@ -97,17 +99,17 @@
(kParameterBlockSize == 1) ? ColMajor : RowMajor>
JacobianMatrix;
- Map<JacobianMatrix> parameter_jacobian(jacobian,
- num_residuals_internal,
- parameter_block_size_internal);
+ Map<JacobianMatrix> parameter_jacobian(
+ jacobian, num_residuals_internal, parameter_block_size_internal);
Map<ParameterVector> x_plus_delta(
parameters[parameter_block_index_internal],
parameter_block_size_internal);
ParameterVector x(x_plus_delta);
- ParameterVector step_size = x.array().abs() *
- ((kMethod == RIDDERS) ? options.ridders_relative_initial_step_size :
- options.relative_step_size);
+ ParameterVector step_size =
+ x.array().abs() * ((kMethod == RIDDERS)
+ ? options.ridders_relative_initial_step_size
+ : options.relative_step_size);
// It is not a good idea to make the step size arbitrarily
// small. This will lead to problems with round off and numerical
@@ -118,8 +120,8 @@
// For Ridders' method, the initial step size is required to be large,
// thus ridders_relative_initial_step_size is used.
if (kMethod == RIDDERS) {
- min_step_size = std::max(min_step_size,
- options.ridders_relative_initial_step_size);
+ min_step_size =
+ std::max(min_step_size, options.ridders_relative_initial_step_size);
}
// For each parameter in the parameter block, use finite differences to
@@ -133,7 +135,9 @@
const double delta = std::max(min_step_size, step_size(j));
if (kMethod == RIDDERS) {
- if (!EvaluateRiddersJacobianColumn(functor, j, delta,
+ if (!EvaluateRiddersJacobianColumn(functor,
+ j,
+ delta,
options,
num_residuals_internal,
parameter_block_size_internal,
@@ -146,7 +150,9 @@
return false;
}
} else {
- if (!EvaluateJacobianColumn(functor, j, delta,
+ if (!EvaluateJacobianColumn(functor,
+ j,
+ delta,
num_residuals_internal,
parameter_block_size_internal,
x.data(),
@@ -182,8 +188,7 @@
typedef Matrix<double, kParameterBlockSize, 1> ParameterVector;
Map<const ParameterVector> x(x_ptr, parameter_block_size);
- Map<ParameterVector> x_plus_delta(x_plus_delta_ptr,
- parameter_block_size);
+ Map<ParameterVector> x_plus_delta(x_plus_delta_ptr, parameter_block_size);
Map<ResidualVector> residuals(residuals_ptr, num_residuals);
Map<ResidualVector> temp_residuals(temp_residuals_ptr, num_residuals);
@@ -191,9 +196,8 @@
// Mutate 1 element at a time and then restore.
x_plus_delta(parameter_index) = x(parameter_index) + delta;
- if (!VariadicEvaluate<ParameterDims>(*functor,
- parameters,
- residuals.data())) {
+ if (!VariadicEvaluate<ParameterDims>(
+ *functor, parameters, residuals.data())) {
return false;
}
@@ -206,9 +210,8 @@
// Compute the function on the other side of x(parameter_index).
x_plus_delta(parameter_index) = x(parameter_index) - delta;
- if (!VariadicEvaluate<ParameterDims>(*functor,
- parameters,
- temp_residuals.data())) {
+ if (!VariadicEvaluate<ParameterDims>(
+ *functor, parameters, temp_residuals.data())) {
return false;
}
@@ -217,8 +220,7 @@
} else {
// Forward difference only; reuse existing residuals evaluation.
residuals -=
- Map<const ResidualVector>(residuals_at_eval_point,
- num_residuals);
+ Map<const ResidualVector>(residuals_at_eval_point, num_residuals);
}
// Restore x_plus_delta.
@@ -254,17 +256,17 @@
double* x_plus_delta_ptr,
double* temp_residuals_ptr,
double* residuals_ptr) {
+ using Eigen::aligned_allocator;
using Eigen::Map;
using Eigen::Matrix;
- using Eigen::aligned_allocator;
typedef Matrix<double, kNumResiduals, 1> ResidualVector;
- typedef Matrix<double, kNumResiduals, Eigen::Dynamic> ResidualCandidateMatrix;
+ typedef Matrix<double, kNumResiduals, Eigen::Dynamic>
+ ResidualCandidateMatrix;
typedef Matrix<double, kParameterBlockSize, 1> ParameterVector;
Map<const ParameterVector> x(x_ptr, parameter_block_size);
- Map<ParameterVector> x_plus_delta(x_plus_delta_ptr,
- parameter_block_size);
+ Map<ParameterVector> x_plus_delta(x_plus_delta_ptr, parameter_block_size);
Map<ResidualVector> residuals(residuals_ptr, num_residuals);
Map<ResidualVector> temp_residuals(temp_residuals_ptr, num_residuals);
@@ -275,18 +277,16 @@
// As the derivative is estimated, the step size decreases.
// By default, the step sizes are chosen so that the middle column
// of the Romberg tableau uses the input delta.
- double current_step_size = delta *
- pow(options.ridders_step_shrink_factor,
- options.max_num_ridders_extrapolations / 2);
+ double current_step_size =
+ delta * pow(options.ridders_step_shrink_factor,
+ options.max_num_ridders_extrapolations / 2);
// Double-buffering temporary differential candidate vectors
// from previous step size.
ResidualCandidateMatrix stepsize_candidates_a(
- num_residuals,
- options.max_num_ridders_extrapolations);
+ num_residuals, options.max_num_ridders_extrapolations);
ResidualCandidateMatrix stepsize_candidates_b(
- num_residuals,
- options.max_num_ridders_extrapolations);
+ num_residuals, options.max_num_ridders_extrapolations);
ResidualCandidateMatrix* current_candidates = &stepsize_candidates_a;
ResidualCandidateMatrix* previous_candidates = &stepsize_candidates_b;
@@ -304,7 +304,9 @@
// 3. Extrapolation becomes numerically unstable.
for (int i = 0; i < options.max_num_ridders_extrapolations; ++i) {
// Compute the numerical derivative at this step size.
- if (!EvaluateJacobianColumn(functor, parameter_index, current_step_size,
+ if (!EvaluateJacobianColumn(functor,
+ parameter_index,
+ current_step_size,
num_residuals,
parameter_block_size,
x.data(),
@@ -327,23 +329,24 @@
// Extrapolation factor for Richardson acceleration method (see below).
double richardson_factor = options.ridders_step_shrink_factor *
- options.ridders_step_shrink_factor;
+ options.ridders_step_shrink_factor;
for (int k = 1; k <= i; ++k) {
// Extrapolate the various orders of finite differences using
// the Richardson acceleration method.
current_candidates->col(k) =
(richardson_factor * current_candidates->col(k - 1) -
- previous_candidates->col(k - 1)) / (richardson_factor - 1.0);
+ previous_candidates->col(k - 1)) /
+ (richardson_factor - 1.0);
richardson_factor *= options.ridders_step_shrink_factor *
- options.ridders_step_shrink_factor;
+ options.ridders_step_shrink_factor;
// Compute the difference between the previous value and the current.
double candidate_error = std::max(
- (current_candidates->col(k) -
- current_candidates->col(k - 1)).norm(),
- (current_candidates->col(k) -
- previous_candidates->col(k - 1)).norm());
+ (current_candidates->col(k) - current_candidates->col(k - 1))
+ .norm(),
+ (current_candidates->col(k) - previous_candidates->col(k - 1))
+ .norm());
// If the error has decreased, update results.
if (candidate_error <= norm_error) {
@@ -365,8 +368,9 @@
// Check to see if the current gradient estimate is numerically unstable.
// If so, bail out and return the last stable result.
if (i > 0) {
- double tableau_error = (current_candidates->col(i) -
- previous_candidates->col(i - 1)).norm();
+ double tableau_error =
+ (current_candidates->col(i) - previous_candidates->col(i - 1))
+ .norm();
// Compare current error to the chosen candidate's error.
if (tableau_error >= 2 * norm_error) {
@@ -482,14 +486,18 @@
// End of 'recursion'. Nothing more to do.
template <typename ParameterDims, int ParameterIdx>
-struct EvaluateJacobianForParameterBlocks<ParameterDims, std::integer_sequence<int>,
+struct EvaluateJacobianForParameterBlocks<ParameterDims,
+ std::integer_sequence<int>,
ParameterIdx> {
- template <NumericDiffMethodType method, int kNumResiduals,
+ template <NumericDiffMethodType method,
+ int kNumResiduals,
typename CostFunctor>
static bool Apply(const CostFunctor* /* NOT USED*/,
const double* /* NOT USED*/,
- const NumericDiffOptions& /* NOT USED*/, int /* NOT USED*/,
- double** /* NOT USED*/, double** /* NOT USED*/) {
+ const NumericDiffOptions& /* NOT USED*/,
+ int /* NOT USED*/,
+ double** /* NOT USED*/,
+ double** /* NOT USED*/) {
return true;
}
};
diff --git a/include/ceres/internal/port.h b/include/ceres/internal/port.h
index 958b0d1..080121e 100644
--- a/include/ceres/internal/port.h
+++ b/include/ceres/internal/port.h
@@ -35,17 +35,17 @@
#include "ceres/internal/config.h"
#if defined(CERES_USE_OPENMP)
-# if defined(CERES_USE_CXX_THREADS) || defined(CERES_NO_THREADS)
-# error CERES_USE_OPENMP is mutually exclusive to CERES_USE_CXX_THREADS and CERES_NO_THREADS
-# endif
+#if defined(CERES_USE_CXX_THREADS) || defined(CERES_NO_THREADS)
+#error CERES_USE_OPENMP is mutually exclusive to CERES_USE_CXX_THREADS and CERES_NO_THREADS
+#endif
#elif defined(CERES_USE_CXX_THREADS)
-# if defined(CERES_USE_OPENMP) || defined(CERES_NO_THREADS)
-# error CERES_USE_CXX_THREADS is mutually exclusive to CERES_USE_OPENMP, CERES_USE_CXX_THREADS and CERES_NO_THREADS
-# endif
+#if defined(CERES_USE_OPENMP) || defined(CERES_NO_THREADS)
+#error CERES_USE_CXX_THREADS is mutually exclusive to CERES_USE_OPENMP, CERES_USE_CXX_THREADS and CERES_NO_THREADS
+#endif
#elif defined(CERES_NO_THREADS)
-# if defined(CERES_USE_OPENMP) || defined(CERES_USE_CXX_THREADS)
-# error CERES_NO_THREADS is mutually exclusive to CERES_USE_OPENMP and CERES_USE_CXX_THREADS
-# endif
+#if defined(CERES_USE_OPENMP) || defined(CERES_USE_CXX_THREADS)
+#error CERES_NO_THREADS is mutually exclusive to CERES_USE_OPENMP and CERES_USE_CXX_THREADS
+#endif
#else
# error One of CERES_USE_OPENMP, CERES_USE_CXX_THREADS or CERES_NO_THREADS must be defined.
#endif
@@ -54,18 +54,18 @@
// compiled without any sparse back-end. Verify that it has not subsequently
// been inconsistently redefined.
#if defined(CERES_NO_SPARSE)
-# if !defined(CERES_NO_SUITESPARSE)
-# error CERES_NO_SPARSE requires CERES_NO_SUITESPARSE.
-# endif
-# if !defined(CERES_NO_CXSPARSE)
-# error CERES_NO_SPARSE requires CERES_NO_CXSPARSE
-# endif
-# if !defined(CERES_NO_ACCELERATE_SPARSE)
-# error CERES_NO_SPARSE requires CERES_NO_ACCELERATE_SPARSE
-# endif
-# if defined(CERES_USE_EIGEN_SPARSE)
-# error CERES_NO_SPARSE requires !CERES_USE_EIGEN_SPARSE
-# endif
+#if !defined(CERES_NO_SUITESPARSE)
+#error CERES_NO_SPARSE requires CERES_NO_SUITESPARSE.
+#endif
+#if !defined(CERES_NO_CXSPARSE)
+#error CERES_NO_SPARSE requires CERES_NO_CXSPARSE
+#endif
+#if !defined(CERES_NO_ACCELERATE_SPARSE)
+#error CERES_NO_SPARSE requires CERES_NO_ACCELERATE_SPARSE
+#endif
+#if defined(CERES_USE_EIGEN_SPARSE)
+#error CERES_NO_SPARSE requires !CERES_USE_EIGEN_SPARSE
+#endif
#endif
// A macro to signal which functions and classes are exported when
@@ -80,11 +80,11 @@
// Hence it is important that the check for CERES_BUILDING_SHARED_LIBRARY
// happens first.
#if defined(_MSC_VER) && defined(CERES_BUILDING_SHARED_LIBRARY)
-# define CERES_EXPORT __declspec(dllexport)
+#define CERES_EXPORT __declspec(dllexport)
#elif defined(_MSC_VER) && defined(CERES_USING_SHARED_LIBRARY)
-# define CERES_EXPORT __declspec(dllimport)
+#define CERES_EXPORT __declspec(dllimport)
#else
-# define CERES_EXPORT
+#define CERES_EXPORT
#endif
#endif // CERES_PUBLIC_INTERNAL_PORT_H_
diff --git a/include/ceres/internal/reenable_warnings.h b/include/ceres/internal/reenable_warnings.h
index 7e41025..2c5db06 100644
--- a/include/ceres/internal/reenable_warnings.h
+++ b/include/ceres/internal/reenable_warnings.h
@@ -32,7 +32,7 @@
#undef CERES_WARNINGS_DISABLED
#ifdef _MSC_VER
-#pragma warning( pop )
+#pragma warning(pop)
#endif
#endif // CERES_WARNINGS_DISABLED
diff --git a/include/ceres/internal/variadic_evaluate.h b/include/ceres/internal/variadic_evaluate.h
index 046832c..47ff6b1 100644
--- a/include/ceres/internal/variadic_evaluate.h
+++ b/include/ceres/internal/variadic_evaluate.h
@@ -46,8 +46,10 @@
// For fixed size cost functors
template <typename Functor, typename T, int... Indices>
-inline bool VariadicEvaluateImpl(const Functor& functor, T const* const* input,
- T* output, std::false_type /*is_dynamic*/,
+inline bool VariadicEvaluateImpl(const Functor& functor,
+ T const* const* input,
+ T* output,
+ std::false_type /*is_dynamic*/,
std::integer_sequence<int, Indices...>) {
static_assert(sizeof...(Indices),
"Invalid number of parameter blocks. At least one parameter "
@@ -57,26 +59,31 @@
// For dynamic sized cost functors
template <typename Functor, typename T>
-inline bool VariadicEvaluateImpl(const Functor& functor, T const* const* input,
- T* output, std::true_type /*is_dynamic*/,
+inline bool VariadicEvaluateImpl(const Functor& functor,
+ T const* const* input,
+ T* output,
+ std::true_type /*is_dynamic*/,
std::integer_sequence<int>) {
return functor(input, output);
}
// For ceres cost functors (not ceres::CostFunction)
template <typename ParameterDims, typename Functor, typename T>
-inline bool VariadicEvaluateImpl(const Functor& functor, T const* const* input,
- T* output, const void* /* NOT USED */) {
+inline bool VariadicEvaluateImpl(const Functor& functor,
+ T const* const* input,
+ T* output,
+ const void* /* NOT USED */) {
using ParameterBlockIndices =
std::make_integer_sequence<int, ParameterDims::kNumParameterBlocks>;
using IsDynamic = std::integral_constant<bool, ParameterDims::kIsDynamic>;
- return VariadicEvaluateImpl(functor, input, output, IsDynamic(),
- ParameterBlockIndices());
+ return VariadicEvaluateImpl(
+ functor, input, output, IsDynamic(), ParameterBlockIndices());
}
// For ceres::CostFunction
template <typename ParameterDims, typename Functor, typename T>
-inline bool VariadicEvaluateImpl(const Functor& functor, T const* const* input,
+inline bool VariadicEvaluateImpl(const Functor& functor,
+ T const* const* input,
T* output,
const CostFunction* /* NOT USED */) {
return functor.Evaluate(input, output, nullptr);
@@ -95,7 +102,8 @@
// blocks. The signature of the functor must have the following signature
// 'bool()(const T* i_1, const T* i_2, ... const T* i_n, T* output)'.
template <typename ParameterDims, typename Functor, typename T>
-inline bool VariadicEvaluate(const Functor& functor, T const* const* input,
+inline bool VariadicEvaluate(const Functor& functor,
+ T const* const* input,
T* output) {
return VariadicEvaluateImpl<ParameterDims>(functor, input, output, &functor);
}
diff --git a/include/ceres/jet.h b/include/ceres/jet.h
index c551d51..da49f32 100644
--- a/include/ceres/jet.h
+++ b/include/ceres/jet.h
@@ -580,14 +580,14 @@
// erf(x + h) = erf(x) + h * 2*exp(-x^2)/sqrt(pi)
template <typename T, int N>
inline Jet<T, N> erf(const Jet<T, N>& x) {
- return Jet<T, N>(erf(x.a), x.v * M_2_SQRTPI * exp(-x.a*x.a));
+ return Jet<T, N>(erf(x.a), x.v * M_2_SQRTPI * exp(-x.a * x.a));
}
// erfc(x) = 1-erf(x)
// erfc(x + h) = erfc(x) + h * (-2*exp(-x^2)/sqrt(pi))
template <typename T, int N>
inline Jet<T, N> erfc(const Jet<T, N>& x) {
- return Jet<T, N>(erfc(x.a), -x.v * M_2_SQRTPI * exp(-x.a*x.a));
+ return Jet<T, N>(erfc(x.a), -x.v * M_2_SQRTPI * exp(-x.a * x.a));
}
// Bessel functions of the first kind with integer order equal to 0, 1, n.
diff --git a/include/ceres/local_parameterization.h b/include/ceres/local_parameterization.h
index 1576e82..be4fb46 100644
--- a/include/ceres/local_parameterization.h
+++ b/include/ceres/local_parameterization.h
@@ -354,8 +354,8 @@
} // namespace ceres
+// clang-format off
#include "ceres/internal/reenable_warnings.h"
#include "ceres/internal/line_parameterization.h"
#endif // CERES_PUBLIC_LOCAL_PARAMETERIZATION_H_
-
diff --git a/include/ceres/problem.h b/include/ceres/problem.h
index 76d115b..add12ea 100644
--- a/include/ceres/problem.h
+++ b/include/ceres/problem.h
@@ -453,13 +453,15 @@
// problem.AddResidualBlock(new MyCostFunction, nullptr, &x);
//
// double cost = 0.0;
- // problem.Evaluate(Problem::EvaluateOptions(), &cost, nullptr, nullptr, nullptr);
+ // problem.Evaluate(Problem::EvaluateOptions(), &cost,
+ // nullptr, nullptr, nullptr);
//
// The cost is evaluated at x = 1. If you wish to evaluate the
// problem at x = 2, then
//
// x = 2;
- // problem.Evaluate(Problem::EvaluateOptions(), &cost, nullptr, nullptr, nullptr);
+ // problem.Evaluate(Problem::EvaluateOptions(), &cost,
+ // nullptr, nullptr, nullptr);
//
// is the way to do so.
//
diff --git a/include/ceres/solver.h b/include/ceres/solver.h
index 6263174..3f9f72f 100644
--- a/include/ceres/solver.h
+++ b/include/ceres/solver.h
@@ -360,7 +360,8 @@
//
// If Solver::Options::preconditioner_type == SUBSET, then
// residual_blocks_for_subset_preconditioner must be non-empty.
- std::unordered_set<ResidualBlockId> residual_blocks_for_subset_preconditioner;
+ std::unordered_set<ResidualBlockId>
+ residual_blocks_for_subset_preconditioner;
// Ceres supports using multiple dense linear algebra libraries
// for dense matrix factorizations. Currently EIGEN and LAPACK are
diff --git a/include/ceres/types.h b/include/ceres/types.h
index 3a19b73..5ee6fdc 100644
--- a/include/ceres/types.h
+++ b/include/ceres/types.h
@@ -50,7 +50,7 @@
// delete on it upon completion.
enum Ownership {
DO_NOT_TAKE_OWNERSHIP,
- TAKE_OWNERSHIP
+ TAKE_OWNERSHIP,
};
// TODO(keir): Considerably expand the explanations of each solver type.
@@ -185,19 +185,19 @@
enum DenseLinearAlgebraLibraryType {
EIGEN,
- LAPACK
+ LAPACK,
};
// Logging options
// The options get progressively noisier.
enum LoggingType {
SILENT,
- PER_MINIMIZER_ITERATION
+ PER_MINIMIZER_ITERATION,
};
enum MinimizerType {
LINE_SEARCH,
- TRUST_REGION
+ TRUST_REGION,
};
enum LineSearchDirectionType {
@@ -412,7 +412,7 @@
// specified for the number of residuals. If specified, then the
// number of residuas for that cost function can vary at runtime.
enum DimensionType {
- DYNAMIC = -1
+ DYNAMIC = -1,
};
// The differentiation method used to compute numerical derivatives in
@@ -433,7 +433,7 @@
enum LineSearchInterpolationType {
BISECTION,
QUADRATIC,
- CUBIC
+ CUBIC,
};
enum CovarianceAlgorithmType {
@@ -448,8 +448,7 @@
// did not write to that memory location.
const double kImpossibleValue = 1e302;
-CERES_EXPORT const char* LinearSolverTypeToString(
- LinearSolverType type);
+CERES_EXPORT const char* LinearSolverTypeToString(LinearSolverType type);
CERES_EXPORT bool StringToLinearSolverType(std::string value,
LinearSolverType* type);
@@ -459,25 +458,23 @@
CERES_EXPORT const char* VisibilityClusteringTypeToString(
VisibilityClusteringType type);
-CERES_EXPORT bool StringToVisibilityClusteringType(std::string value,
- VisibilityClusteringType* type);
+CERES_EXPORT bool StringToVisibilityClusteringType(
+ std::string value, VisibilityClusteringType* type);
CERES_EXPORT const char* SparseLinearAlgebraLibraryTypeToString(
SparseLinearAlgebraLibraryType type);
CERES_EXPORT bool StringToSparseLinearAlgebraLibraryType(
- std::string value,
- SparseLinearAlgebraLibraryType* type);
+ std::string value, SparseLinearAlgebraLibraryType* type);
CERES_EXPORT const char* DenseLinearAlgebraLibraryTypeToString(
DenseLinearAlgebraLibraryType type);
CERES_EXPORT bool StringToDenseLinearAlgebraLibraryType(
- std::string value,
- DenseLinearAlgebraLibraryType* type);
+ std::string value, DenseLinearAlgebraLibraryType* type);
CERES_EXPORT const char* TrustRegionStrategyTypeToString(
TrustRegionStrategyType type);
-CERES_EXPORT bool StringToTrustRegionStrategyType(std::string value,
- TrustRegionStrategyType* type);
+CERES_EXPORT bool StringToTrustRegionStrategyType(
+ std::string value, TrustRegionStrategyType* type);
CERES_EXPORT const char* DoglegTypeToString(DoglegType type);
CERES_EXPORT bool StringToDoglegType(std::string value, DoglegType* type);
@@ -487,41 +484,39 @@
CERES_EXPORT const char* LineSearchDirectionTypeToString(
LineSearchDirectionType type);
-CERES_EXPORT bool StringToLineSearchDirectionType(std::string value,
- LineSearchDirectionType* type);
+CERES_EXPORT bool StringToLineSearchDirectionType(
+ std::string value, LineSearchDirectionType* type);
CERES_EXPORT const char* LineSearchTypeToString(LineSearchType type);
-CERES_EXPORT bool StringToLineSearchType(std::string value, LineSearchType* type);
+CERES_EXPORT bool StringToLineSearchType(std::string value,
+ LineSearchType* type);
CERES_EXPORT const char* NonlinearConjugateGradientTypeToString(
NonlinearConjugateGradientType type);
CERES_EXPORT bool StringToNonlinearConjugateGradientType(
- std::string value,
- NonlinearConjugateGradientType* type);
+ std::string value, NonlinearConjugateGradientType* type);
CERES_EXPORT const char* LineSearchInterpolationTypeToString(
LineSearchInterpolationType type);
CERES_EXPORT bool StringToLineSearchInterpolationType(
- std::string value,
- LineSearchInterpolationType* type);
+ std::string value, LineSearchInterpolationType* type);
CERES_EXPORT const char* CovarianceAlgorithmTypeToString(
CovarianceAlgorithmType type);
CERES_EXPORT bool StringToCovarianceAlgorithmType(
- std::string value,
- CovarianceAlgorithmType* type);
+ std::string value, CovarianceAlgorithmType* type);
CERES_EXPORT const char* NumericDiffMethodTypeToString(
NumericDiffMethodType type);
-CERES_EXPORT bool StringToNumericDiffMethodType(
- std::string value,
- NumericDiffMethodType* type);
+CERES_EXPORT bool StringToNumericDiffMethodType(std::string value,
+ NumericDiffMethodType* type);
CERES_EXPORT const char* LoggingTypeToString(LoggingType type);
CERES_EXPORT bool StringtoLoggingType(std::string value, LoggingType* type);
CERES_EXPORT const char* DumpFormatTypeToString(DumpFormatType type);
-CERES_EXPORT bool StringtoDumpFormatType(std::string value, DumpFormatType* type);
+CERES_EXPORT bool StringtoDumpFormatType(std::string value,
+ DumpFormatType* type);
CERES_EXPORT bool StringtoDumpFormatType(std::string value, LoggingType* type);
CERES_EXPORT const char* TerminationTypeToString(TerminationType type);
diff --git a/include/ceres/version.h b/include/ceres/version.h
index 50aa212..a76cc10 100644
--- a/include/ceres/version.h
+++ b/include/ceres/version.h
@@ -41,8 +41,9 @@
#define CERES_TO_STRING(x) CERES_TO_STRING_HELPER(x)
// The Ceres version as a string; for example "1.9.0".
-#define CERES_VERSION_STRING CERES_TO_STRING(CERES_VERSION_MAJOR) "." \
- CERES_TO_STRING(CERES_VERSION_MINOR) "." \
- CERES_TO_STRING(CERES_VERSION_REVISION)
+#define CERES_VERSION_STRING \
+ CERES_TO_STRING(CERES_VERSION_MAJOR) \
+ "." CERES_TO_STRING(CERES_VERSION_MINOR) "." CERES_TO_STRING( \
+ CERES_VERSION_REVISION)
#endif // CERES_PUBLIC_VERSION_H_