diff --git a/gtsam_unstable/nonlinear/tests/testExpression.cpp b/gtsam_unstable/nonlinear/tests/testExpression.cpp index 252d2c73c..49f7f6f40 100644 --- a/gtsam_unstable/nonlinear/tests/testExpression.cpp +++ b/gtsam_unstable/nonlinear/tests/testExpression.cpp @@ -318,20 +318,19 @@ Matrix numericalDerivative(boost::function h, const X& x, double delta = 1e-5) { Y hx = h(x); double factor = 1.0 / (2.0 * delta); - static const size_t m = manifold_traits::dimension, n = - manifold_traits::dimension; - Eigen::Matrix d; - d.setZero(); - Matrix H = zeros(m, n); - for (size_t j = 0; j < n; j++) { - d(j) += delta; + static const size_t M = manifold_traits::dimension; + static const size_t N = manifold_traits::dimension; + Eigen::Matrix d; + Matrix H = zeros(M, N); + for (size_t j = 0; j < N; j++) { + d.setZero(); + d(j) = delta; Vector hxplus = manifold_traits::localCoordinates(hx, h(manifold_traits::retract(x, d))); - d(j) -= 2 * delta; + d(j) = -delta; Vector hxmin = manifold_traits::localCoordinates(hx, h(manifold_traits::retract(x, d))); - d(j) += delta; - H.block(0, j) << (hxplus - hxmin) * factor; + H.block(0, j) << (hxplus - hxmin) * factor; } return H; } @@ -339,13 +338,13 @@ Matrix numericalDerivative(boost::function h, const X& x, template Matrix numericalDerivative21(boost::function h, const X1& x1, const X2& x2, double delta = 1e-5) { - return numericalDerivative(boost::bind(h,_1,x2),x1,delta); + return numericalDerivative(boost::bind(h, _1, x2), x1, delta); } template Matrix numericalDerivative22(boost::function h, const X1& x1, const X2& x2, double delta = 1e-5) { - return numericalDerivative(boost::bind(h,x1,_1),x2,delta); + return numericalDerivative(boost::bind(h, x1, _1), x2, delta); } /* ************************************************************************* */