21#ifndef LIBMV_NUMERIC_DERIVATIVE_H
22#define LIBMV_NUMERIC_DERIVATIVE_H
39template <
typename Function, NumericJacobianMode mode = CENTRAL>
43 typedef typename Function::XMatrixType::RealScalar
XScalar;
45 typedef Matrix<
typename Function::FMatrixType::RealScalar,
46 Function::FMatrixType::RowsAtCompileTime,
47 Function::XMatrixType::RowsAtCompileTime>
66 const int rows = fx.rows();
67 const int cols = x.rows();
70 for (
int c = 0; c < cols; ++c) {
74 x_plus_delta(c) =
x(c) +
eps(c);
75 jacobian.col(c) = f_(x_plus_delta);
79 x_plus_delta(c) =
x(c) -
eps(c);
80 jacobian.col(c) -= f_(x_plus_delta);
83 jacobian.col(c) -= fx;
85 x_plus_delta(c) =
x(c);
86 jacobian.col(c) = jacobian.col(c) * one_over_h;
95template <
typename Function,
typename Jacobian>
96bool CheckJacobian(
const Function& f,
const typename Function::XMatrixType& x) {
97 Jacobian j_analytic(f);
102 LG << J_numeric - J_analytic;
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
JMatrixType operator()(const Parameters &x)
Function::XMatrixType Parameters
Function::XMatrixType::RealScalar XScalar
Function::FMatrixType FMatrixType
NumericJacobian(const Function &f)
Matrix< typename Function::FMatrixType::RealScalar, Function::FMatrixType::RowsAtCompileTime, Function::XMatrixType::RowsAtCompileTime > JMatrixType
bool CheckJacobian(const Function &f, const typename Function::XMatrixType &x)