mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 00:50:37 +08:00
[modernize] Modernize internal autodiff and numeric_diff logic
Refactor the core automatic and numeric differentiation internal helpers to utilize C++17 features for improved readability and maintainability: - Added IntegerSequenceTraits to provide a uniform compile-time interface for accessing head and tail of std::integer_sequence. - Eliminated recursive template meta-programming in autodiff.h, replacing it with fold expressions and std::index_sequence. - Simplified core helper functions like Make1stOrderPerturbation into unrolled loops. - Refactored EvaluateJacobianForParameterBlocks from a recursive struct to a recursive function template using if constexpr. - Updated NumericDiffCostFunction and NumericDiffFirstOrderFunction to use the modernized internal helper API. Change-Id: I934034f7434fc05a8855565b2b534d325f920584
This commit is contained in:
@@ -266,14 +266,15 @@ class NumericDiffCostFunction final
|
||||
sizeof(double) * ParameterDims::GetDim(block));
|
||||
}
|
||||
|
||||
internal::EvaluateJacobianForParameterBlocks<ParameterDims>::
|
||||
template Apply<kMethod, kNumResiduals>(
|
||||
functor_.get(),
|
||||
residuals,
|
||||
options_,
|
||||
this->num_residuals(),
|
||||
parameters_reference_copy.data(),
|
||||
jacobians);
|
||||
internal::EvaluateJacobianForParameterBlocks<kMethod,
|
||||
kNumResiduals,
|
||||
ParameterDims>(
|
||||
functor_.get(),
|
||||
residuals,
|
||||
options_,
|
||||
this->num_residuals(),
|
||||
parameters_reference_copy.data(),
|
||||
jacobians);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user