41 std::vector<std::pair<Key, Matrix> > jacobians;
45 const size_t rows = e.size();
48 const double one_over_2delta = 1.0 / (2.0 *
delta);
53 Matrix J = Matrix::Zero(rows, cols);
55 Eigen::VectorXd dx = Eigen::VectorXd::Zero(cols);
59 const Eigen::VectorXd
left = factor.whitenedError(eval_values);
62 eval_values = values.
retract(dX);
63 const Eigen::VectorXd
right = factor.whitenedError(eval_values);
64 J.col(
col) = (left -
right) * one_over_2delta;
66 jacobians.push_back(std::make_pair(
key,J));
83 boost::shared_ptr<JacobianFactor> actual =
85 if (!actual)
return false;
92 for (
size_t i = 0;
i < actual->size();
i++) {
94 (
Matrix) (actual->getA(actual->begin() +
i)), tolerance);
96 std::cout <<
"Mismatch in Jacobian " <<
i+1 <<
" (base 1), as shown above" << std::endl;
110 #define EXPECT_CORRECT_FACTOR_JACOBIANS(factor, values, numerical_derivative_step, tolerance) \ 111 { EXPECT(gtsam::internal::testFactorJacobians(name_, factor, values, numerical_derivative_step, tolerance)); } boost::shared_ptr< GaussianFactor > linearize(const Values &x) const override
VectorValues zeroVectors() const
Some functions to compute numerical derivatives.
Values retract(const VectorValues &delta) const
bool testFactorJacobians(const std::string &name_, const NoiseModelFactor &factor, const gtsam::Values &values, double delta, double tolerance)
JacobianFactor linearizeNumerically(const NoiseModelFactor &factor, const Values &values, double delta=1e-5)
const_iterator begin() const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
JacobiRotation< float > J
constABlock getA(const_iterator variable) const
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Non-linear factor base classes.
Vector whitenedError(const Values &c) const
bool equal(const T &obj1, const T &obj2, double tol)
std::uint64_t Key
Integer nonlinear key type.