template<typename Functor_, NumericalDiffMode mode = Forward>
class Eigen::NumericalDiff< Functor_, mode >
This class allows you to add a method df() to your functor, which will use numerical differentiation to compute an approximate of the derivative for the functor. Of course, if you have an analytical form for the derivative, you should rather implement df() by yourself.
More information on http://en.wikipedia.org/wiki/Numerical_differentiation
Currently only "Forward" and "Central" scheme are implemented.
The step along coordinate j is
\[ h_j = \begin{cases} \max(|x_j|\,\mathrm{rel\_tol},\ \mathrm{abs\_tol}) & \text{if this is nonzero},\\
\mathrm{rel\_tol} & \text{otherwise.}
\end{cases}
\]
The forward difference is \((f(x + h_j e_j) - f(x))/h_j\) and the central difference is \((f(x + h_j e_j) - f(x - h_j e_j))/(2 h_j)\), each with the divisor replaced by the representable step actually applied. By default \(\mathrm{abs\_tol} = \mathrm{rel\_tol}\) (set by the constructors), so \(h_j \ge \mathrm{rel\_tol}\): this suits residuals with an offset of order 1 even when some \(|x_j|\) is tiny, where a step proportional to \(|x_j|\) would be lost in the rounding error of \(f\). For a function whose natural scale is \(|x_j|\) itself (parameters of tiny magnitude throughout), call setAbsTol(0): then \(h_j = \mathrm{rel\_tol}\,|x_j|\) as in MINPACK's fdjac2, and the second case applies only when this product is zero ( \(x_j = 0\), or \(|x_j|\,\mathrm{rel\_tol}\) underflows, so that \(x_j + h\) would equal \(x_j\)).
template<typename Functor_, NumericalDiffMode mode = Forward>
Computes the Jacobian of the functor at _x into jac and returns the number of functor evaluations.
The step along coordinate j is h = max(|x[j]| * rel_tol, abs_tol), or h = rel_tol when that is zero (possible only for abs_tol == 0), with rel_tol and abs_tol selected by the user. The rel_tol selected by the user must be greater than or equal to epsilon, and abs_tol must be nonnegative, where epsilon is the machine precision NumTraits<Scalar>::epsilon(); the difference quotient divides by the representable step fl(x[j] + h) - x[j] actually applied.
In forward mode, the default rel_tol is sqrt(NumTraits<Scalar>::epsilon()) and the default abs_tol is abs_tol = rel_tol. In central mode, the default rel_tol is cbrt(NumTraits<Scalar>::epsilon()) and the default abs_tol = rel_tol. Call setAbsTol(0) for a purely relative step, see the class documentation.