mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 00:50:37 +08:00
Let NumericDiffFirstOrderFunction take a dynamically sized parameter vector
Also fix a template naming lint along the way. Change-Id: Iabb98aeec2ff9609a19c3778b9ea2da37771c985
This commit is contained in:
committed by
Sameer Agarwal
parent
6c27ac6d50
commit
4cd257cf4a
@@ -106,6 +106,29 @@ inline bool VariadicEvaluate(const Functor& functor,
|
||||
return VariadicEvaluateImpl<ParameterDims>(functor, input, output, &functor);
|
||||
}
|
||||
|
||||
// When differentiating dynamically sized CostFunctions, VariadicEvaluate
|
||||
// expects a functor with the signature:
|
||||
//
|
||||
// bool operator()(double const* const* parameters, double* cost) const
|
||||
//
|
||||
// However for NumericDiffFirstOrderFunction, the functor has the signature
|
||||
//
|
||||
// bool operator()(double const* parameters, double* cost) const
|
||||
//
|
||||
// This thin wrapper adapts the latter to the former.
|
||||
template <typename Functor>
|
||||
class FirstOrderFunctorAdapter {
|
||||
public:
|
||||
explicit FirstOrderFunctorAdapter(const Functor& functor)
|
||||
: functor_(functor) {}
|
||||
bool operator()(double const* const* parameters, double* cost) const {
|
||||
return functor_(*parameters, cost);
|
||||
}
|
||||
|
||||
private:
|
||||
const Functor& functor_;
|
||||
};
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
#endif // CERES_PUBLIC_INTERNAL_VARIADIC_EVALUATE_H_
|
||||
|
||||
Reference in New Issue
Block a user