4#ifndef EIGEN_NONLINEAROPTIMIZATION_CHKDER_H
5#define EIGEN_NONLINEAROPTIMIZATION_CHKDER_H
7#define chkder_log10e 0.43429448190325182765
8#define chkder_factor 100.
11#include "./InternalHeaderCheck.h"
17template <
typename Scalar>
18void chkder(
const Matrix<Scalar, Dynamic, 1> &x,
const Matrix<Scalar, Dynamic, 1> &fvec,
19 const Matrix<Scalar, Dynamic, Dynamic> &fjac, Matrix<Scalar, Dynamic, 1> &xp,
20 const Matrix<Scalar, Dynamic, 1> &fvecp,
int mode, Matrix<Scalar, Dynamic, 1> &err) {
25 typedef DenseIndex Index;
27 const Scalar eps = sqrt(NumTraits<Scalar>::epsilon());
28 const Scalar epsf = chkder_factor * NumTraits<Scalar>::epsilon();
29 const Scalar epslog = chkder_log10e * log(eps);
32 const Index m = fvec.size(), n = x.size();
37 for (Index j = 0; j < n; ++j) {
38 temp = eps * abs(x[j]);
39 if (temp == 0.) temp = eps;
45 for (Index j = 0; j < n; ++j) {
47 if (temp == 0.) temp = 1.;
48 err += temp * fjac.col(j);
50 for (Index i = 0; i < m; ++i) {
52 if (fvec[i] != 0. && fvecp[i] != 0. && abs(fvecp[i] - fvec[i]) >= epsf * abs(fvec[i]))
53 temp = eps * abs((fvecp[i] - fvec[i]) / eps - err[i]) / (abs(fvec[i]) + abs(fvecp[i]));
55 if (temp > NumTraits<Scalar>::epsilon() && temp < eps) err[i] = (chkder_log10e * log(temp) - epslog) / epslog;
56 if (temp >= eps) err[i] = 0.;
Namespace containing all symbols from the Eigen library.