10 #ifndef EIGEN_FINITEDIFF_CHAIN_JACOBIAN_H_ 11 #define EIGEN_FINITEDIFF_CHAIN_JACOBIAN_H_ 20 template <
typename Functor, NumericalDiffMode mode = Forward>
26 typedef typename ValueType::Scalar
Scalar;
35 typedef Matrix<Scalar, ValuesAtCompileTime, JacobianInputsAtCompileTime>
JacobianType;
37 typedef typename JacobianType::Index
Index;
41 UpdateFunctionCallbackType
update_ = [](
const InputJacobianRowType &jx, InputType &
x) {
x = jx; };
48 #if EIGEN_HAS_VARIADIC_TEMPLATES 49 template <
typename... T>
53 template <
typename... T>
58 template <
typename T0>
62 template <
typename T0,
typename T1>
66 template <
typename T0,
typename T1,
typename T2>
71 template <
typename T0>
75 template <
typename T0,
typename T1>
76 FiniteDiffChainJacobian(UpdateFunctionCallbackType update, Scalar epsfcn = 0.,
const T0 &a0,
const T1 &a1) :
Functor(a0, a1), update_(update), epsfcn_(epsfcn)
79 template <
typename T0,
typename T1,
typename T2>
80 FiniteDiffChainJacobian(UpdateFunctionCallbackType update, Scalar epsfcn = 0.,
const T0 &a0,
const T1 &a1,
const T2 &a2) :
Functor(a0, a1, a2), update_(update), epsfcn_(epsfcn)
85 #if EIGEN_HAS_VARIADIC_TEMPLATES 89 int operator()(
const InputJacobianRowType &_jx, ValueType &v)
const 97 template <
typename... ParamsType>
98 int operator()(
const InputJacobianRowType &_jx, ValueType &v,
const ParamsType &... Params)
const 106 template <
typename... ParamsType>
107 int operator()(
const InputJacobianRowType &_jx, ValueType &v, JacobianType &jac,
const ParamsType &... Params)
const 110 int operator()(
const InputJacobianRowType &_jx, ValueType &v)
const 118 int operator()(
const InputJacobianRowType &_jx, ValueType &v, JacobianType &jac)
const 126 const typename InputJacobianRowType::Index
n = _jx.size();
127 const Scalar eps =
sqrt(((std::max)(epsfcn_, NumTraits<Scalar>::epsilon())));
128 ValueType val1, val2;
129 InputJacobianRowType jx = _jx;
133 val1.resize(v.rows());
134 val2.resize(v.rows());
137 #if EIGEN_HAS_VARIADIC_TEMPLATES 139 Functor::operator()(x, v, Params...);
143 Functor::operator()(x, v);
161 for (
int j = 0; j <
n; ++j)
163 h = eps *
abs(jx[j]);
172 #if EIGEN_HAS_VARIADIC_TEMPLATES 174 Functor::operator()(x, val2, Params...);
178 Functor::operator()(x, val2);
182 jac.col(j) = (val2 - val1) / h;
186 #if EIGEN_HAS_VARIADIC_TEMPLATES 188 Functor::operator()(x, val2, Params...);
192 Functor::operator()(x, val2);
196 #if EIGEN_HAS_VARIADIC_TEMPLATES 198 Functor::operator()(x, val1, Params...);
202 Functor::operator()(x, val1);
206 jac.col(j) = (val2 - val1) / (2 * h);
217 #endif // EIGEN_FINITEDIFF_CHAIN_JACOBIAN_H_ FiniteDiffChainJacobian(UpdateFunctionCallbackType update, Scalar epsfcn=0., const T0 &a0, const T1 &a1)
Functor::ValueType ValueType
std::function< void(const InputJacobianRowType &, InputType &)> UpdateFunctionCallbackType
Matrix< Scalar, ValuesAtCompileTime, JacobianInputsAtCompileTime > JacobianType
FunctorBase< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic > Functor
FiniteDiffChainJacobian(const T0 &a0, const T1 &a1, Scalar epsfcn=0.)
FiniteDiffChainJacobian(const T0 &a0, Scalar epsfcn=0.)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
FiniteDiffChainJacobian(const Functor &f, UpdateFunctionCallbackType update, Scalar epsfcn=0.)
FiniteDiffChainJacobian(const T0 &a0, const T1 &a1, const T2 &a2, Scalar epsfcn=0.)
EIGEN_STRONG_INLINE int operator()(const InputJacobianRowType &_jx, ValueType &v) const
FiniteDiffChainJacobian(Scalar epsfcn=0.)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
FiniteDiffChainJacobian(const Functor &f, Scalar epsfcn=0.)
INLINE Rall1d< T, V, S > abs(const Rall1d< T, V, S > &x)
int operator()(const InputJacobianRowType &_jx, ValueType &v, JacobianType &jac) const
FiniteDiffChainJacobian(UpdateFunctionCallbackType update, Scalar epsfcn=0., const T0 &a0)
JacobianType::Index Index
Matrix< Scalar, JacobianInputsAtCompileTime, 1 > InputJacobianRowType
FiniteDiffChainJacobian(UpdateFunctionCallbackType update, Scalar epsfcn=0., const T0 &a0, const T1 &a1, const T2 &a2)
UpdateFunctionCallbackType update_
Functor::InputType InputType