diff --git a/include/ceres/internal/numeric_diff.h b/include/ceres/internal/numeric_diff.h index 976b27f58..0fe4b8278 100644 --- a/include/ceres/internal/numeric_diff.h +++ b/include/ceres/internal/numeric_diff.h @@ -133,7 +133,7 @@ struct NumericDiff { for (int j = 0; j < parameter_block_size_internal; ++j) { const double delta = (std::max)(min_step_size, step_size(j)); - if (kMethod == RIDDERS) { + if constexpr (kMethod == RIDDERS) { if (!EvaluateRiddersJacobianColumn(functor, j, delta, @@ -453,50 +453,35 @@ struct EvaluateJacobianForParameterBlocks::EvaluateJacobianForParameterBlock(functor, - residuals_at_eval_point, - options, - num_residuals, - ParameterIdx, - N, - parameters, - jacobians[ParameterIdx])) { + if (!NumericDiff:: + EvaluateJacobianForParameterBlock(functor, + residuals_at_eval_point, + options, + num_residuals, + ParameterIdx, + N, + parameters, + jacobians[ParameterIdx])) { return false; } } - return EvaluateJacobianForParameterBlocks, - ParameterIdx + 1>:: - template Apply(functor, - residuals_at_eval_point, - options, - num_residuals, - parameters, - jacobians); - } -}; - -// End of 'recursion'. Nothing more to do. -template -struct EvaluateJacobianForParameterBlocks, - ParameterIdx> { - template - static bool Apply(const CostFunctor* /* NOT USED*/, - const double* /* NOT USED*/, - const NumericDiffOptions& /* NOT USED*/, - int /* NOT USED*/, - double** /* NOT USED*/, - double** /* NOT USED*/) { + if constexpr (sizeof...(Ns) > 0) { + return EvaluateJacobianForParameterBlocks< + ParameterDims, + std::integer_sequence, + ParameterIdx + 1>::template Apply(functor, + residuals_at_eval_point, + options, + num_residuals, + parameters, + jacobians); + } return true; } };