29 class VECTORLIKE,
class VECTORLIKE2,
class VECTORLIKE3,
class MATRIXLIKE,
33 const std::function<
void(
34 const VECTORLIKE& x,
const USERPARAM& y, VECTORLIKE3&
out)>& functor,
35 const VECTORLIKE2& increments,
const USERPARAM& userParam,
36 MATRIXLIKE& out_Jacobian)
39 ASSERT_(x.size() > 0 && increments.size() == x.size());
42 const size_t n = x.size();
44 for (
size_t j = 0; j < n; j++)
49 VECTORLIKE3 f_minus, f_plus;
53 for (
size_t j = 0; j < n; j++)
56 x_mod[j] = x[j] + increments[j];
57 functor(x_mod, userParam, f_plus);
59 x_mod[j] = x[j] - increments[j];
60 functor(x_mod, userParam, f_minus);
63 const double Ax_2_inv = 0.5 / increments[j];
69 out_Jacobian.resize(m, n);
72 for (
size_t i = 0; i < m; i++)
73 out_Jacobian(i, j) = Ax_2_inv * (f_plus[i] - f_minus[i]);
#define ASSERT_(f)
Defines an assertion mechanism.
This base provides a set of functions for maths stuff.
void estimateJacobian(const VECTORLIKE &x, const std::function< void(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out)> &functor, const VECTORLIKE2 &increments, const USERPARAM &userParam, MATRIXLIKE &out_Jacobian)
Estimate the Jacobian of a multi-dimensional function around a point "x", using finite differences of...
mrpt::vision::TStereoCalibResults out