Function navtk::filtering::calc_numerical_jacobian

Function Documentation

Matrix navtk::filtering::calc_numerical_jacobian(const std::function<Vector(const Vector&)> &f, const Vector &x, const Vector &eps)

Calculate the numerical Jacobian of a multivariate function.

Let $dx_i$ with 0 <= i < N be the unit vector whose $i$-th element is 1 and all others are zero. The $(j,i)$-th element of the Jacobian $J$ is computed as follows:

\(J_{j,i}=\frac{f_j(x+\epsilon{}dx_i) - f_j(x - \epsilon{}dx_i)}{2\epsilon{}dx_i}\)

Parameters
  • f – A function mapping a column vector of N inputs into a column vector of M outputs. If the function returns a matrix, then the matrix is converted to a column vector, and the function is treated as though this is the format of its output.

  • x – A N-element column vector at which to compute the Jacobian of f.

  • eps – A column vector of steps the same size as x with which to perturb the function f.

Throws

std::range_error – If x or eps are not Nx1 and the error mode is ErrorMode::DIE.

Returns

A MxN matrix of the Jacobian of f evaluated at x.