Go to the documentation of this file.
10 #ifndef EIGEN_FINITEDIFF_CHAIN_HESSIAN_H_
11 #define EIGEN_FINITEDIFF_CHAIN_HESSIAN_H_
21 template <
typename Functor, NumericalDiffMode mode = Forward>
27 typedef typename ValueType::Scalar
Scalar;
36 typedef Matrix<Scalar, ValuesAtCompileTime, JacobianInputsAtCompileTime>
JacobianType;
39 typedef typename JacobianType::Index
Index;
50 #if EIGEN_HAS_VARIADIC_TEMPLATES
51 template <
typename... T>
55 template <
typename... T>
60 template <
typename T0>
64 template <
typename T0,
typename T1>
68 template <
typename T0,
typename T1,
typename T2>
73 template <
typename T0>
77 template <
typename T0,
typename T1>
81 template <
typename T0,
typename T1,
typename T2>
87 #if EIGEN_HAS_VARIADIC_TEMPLATES
99 template <
typename... ParamsType>
108 template <
typename... ParamsType>
112 return autoj(_jx, v, jac, Params...);
115 template <
typename... ParamsType>
130 return autoj(_jx, v, jac);
142 const typename InputJacobianRowType::Index n = _jx.size();
143 const typename ValueType::Index m = jac.rows();
144 const Scalar eps = sqrt(((std::max)(
epsfcn_, NumTraits<Scalar>::epsilon())));
145 JacobianType jac1(jac.rows(), jac.cols()), jac2(jac.rows(), jac.cols());
148 Index cols = jac.cols();
152 for (
Index i = 0; i < m; ++i)
154 hess[i].resize(cols, cols);
159 #if EIGEN_HAS_VARIADIC_TEMPLATES
160 nfev += autoj(_jx, v, jac, Params...);
162 nfev += autoj(_jx, v, jac);
179 for (
int j = 0; j < n; ++j)
181 h = eps * abs(jx[j]);
191 #if EIGEN_HAS_VARIADIC_TEMPLATES
192 nfev += autoj(jx, _v, jac2, Params...);
194 nfev += autoj(jx, _v, jac2);
197 for (
int l = 0; l < m; ++l)
199 hess[l].row(j) = (jac2.row(l) - jac1.row(l)) / h;
204 #if EIGEN_HAS_VARIADIC_TEMPLATES
205 nfev += autoj(jx, _v, jac2, Params...);
207 nfev += autoj(jx, _v, jac2);
210 #if EIGEN_HAS_VARIADIC_TEMPLATES
211 nfev += autoj(jx, _v, jac1, Params...);
213 nfev += autoj(jx, _v, jac1);
216 for (
int l = 0; l < m; ++l)
218 hess[l].col(j) = (jac2.row(l) - jac1.row(l)) / (2.0 * h);
230 #endif // EIGEN_FINITEDIFF_CHAIN_HESSIAN_H_
@ Forward
Definition: finitediff_common.h:37
@ Central
Definition: finitediff_common.h:38
Definition: autodiff_chain_hessian.h:16
@ ValuesAtCompileTime
Definition: finitediff_chain_hessian.h:32
int operator()(const InputJacobianRowType &_jx, ValueType &v, JacobianType &jac) const
Definition: finitediff_chain_hessian.h:127
@ JacobianInputsAtCompileTime
Definition: finitediff_chain_hessian.h:33
UpdateFunctionCallbackType update_
Definition: finitediff_chain_hessian.h:43
FunctorBase< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic > Functor
Definition: functor.h:49
FiniteDiffChainHessian(const T0 &a0, const T1 &a1, const T2 &a2, Scalar epsfcn=0.)
Definition: finitediff_chain_hessian.h:69
Functor::InputType InputType
Definition: finitediff_chain_hessian.h:25
EIGEN_STRONG_INLINE int operator()(const InputJacobianRowType &_jx, ValueType &v) const
Definition: finitediff_chain_hessian.h:119
FiniteDiffChainHessian(const T0 &a0, const T1 &a1, Scalar epsfcn=0.)
Definition: finitediff_chain_hessian.h:65
FiniteDiffChainHessian(UpdateFunctionCallbackType update, Scalar epsfcn=0., const T0 &a0)
Definition: finitediff_chain_hessian.h:74
ValueType::Scalar Scalar
Definition: finitediff_chain_hessian.h:27
FiniteDiffChainHessian(UpdateFunctionCallbackType update, Scalar epsfcn=0., const T0 &a0, const T1 &a1, const T2 &a2)
Definition: finitediff_chain_hessian.h:82
FiniteDiffChainHessian(Scalar epsfcn=0.)
Definition: finitediff_chain_hessian.h:46
Functor::ValueType ValueType
Definition: finitediff_chain_hessian.h:26
int operator()(const InputJacobianRowType &_jx, ValueType &v, JacobianType &jac, HessianType &hess) const
Definition: finitediff_chain_hessian.h:133
FiniteDiffChainHessian(const T0 &a0, Scalar epsfcn=0.)
Definition: finitediff_chain_hessian.h:61
Scalar epsfcn_
Definition: finitediff_chain_hessian.h:44
Array< Matrix< Scalar, JacobianInputsAtCompileTime, JacobianInputsAtCompileTime >, ValuesAtCompileTime, 1 > HessianType
Definition: finitediff_chain_hessian.h:38
Matrix< Scalar, JacobianInputsAtCompileTime, 1 > InputJacobianRowType
Definition: finitediff_chain_hessian.h:37
JacobianType::Index Index
Definition: finitediff_chain_hessian.h:39
FiniteDiffChainHessian(UpdateFunctionCallbackType update, Scalar epsfcn=0., const T0 &a0, const T1 &a1)
Definition: finitediff_chain_hessian.h:78
FiniteDiffChainHessian(const Functor &f, UpdateFunctionCallbackType update, Scalar epsfcn=0.)
Definition: finitediff_chain_hessian.h:48
std::function< void(const InputJacobianRowType &, InputType &)> UpdateFunctionCallbackType
Definition: finitediff_chain_hessian.h:41
@ InputsAtCompileTime
Definition: finitediff_chain_hessian.h:31
Definition: finitediff_chain_hessian.h:22
Definition: finitediff_chain_jacobian.h:21
Matrix< Scalar, ValuesAtCompileTime, JacobianInputsAtCompileTime > JacobianType
Definition: finitediff_chain_hessian.h:36
FiniteDiffChainHessian(const Functor &f, Scalar epsfcn=0.)
Definition: finitediff_chain_hessian.h:47