chkder.h
Go to the documentation of this file.
1 #define chkder_log10e 0.43429448190325182765
2 #define chkder_factor 100.
3 
4 namespace Eigen {
5 
6 namespace internal {
7 
8 template<typename Scalar>
9 void chkder(
11  const Matrix< Scalar, Dynamic, 1 > &fvec,
14  const Matrix< Scalar, Dynamic, 1 > &fvecp,
15  int mode,
17  )
18 {
19  using std::sqrt;
20  using std::abs;
21  using std::log;
22 
23  typedef DenseIndex Index;
24 
25  const Scalar eps = sqrt(NumTraits<Scalar>::epsilon());
27  const Scalar epslog = chkder_log10e * log(eps);
28  Scalar temp;
29 
30  const Index m = fvec.size(), n = x.size();
31 
32  if (mode != 2) {
33  /* mode = 1. */
34  xp.resize(n);
35  for (Index j = 0; j < n; ++j) {
36  temp = eps * abs(x[j]);
37  if (temp == 0.)
38  temp = eps;
39  xp[j] = x[j] + temp;
40  }
41  }
42  else {
43  /* mode = 2. */
44  err.setZero(m);
45  for (Index j = 0; j < n; ++j) {
46  temp = abs(x[j]);
47  if (temp == 0.)
48  temp = 1.;
49  err += temp * fjac.col(j);
50  }
51  for (Index i = 0; i < m; ++i) {
52  temp = 1.;
53  if (fvec[i] != 0. && fvecp[i] != 0. && abs(fvecp[i] - fvec[i]) >= epsf * abs(fvec[i]))
54  temp = eps * abs((fvecp[i] - fvec[i]) / eps - err[i]) / (abs(fvec[i]) + abs(fvecp[i]));
55  err[i] = 1.;
56  if (temp > NumTraits<Scalar>::epsilon() && temp < eps)
57  err[i] = (chkder_log10e * log(temp) - epslog) / epslog;
58  if (temp >= eps)
59  err[i] = 0.;
60  }
61  }
62 }
63 
64 } // end namespace internal
65 
66 } // end namespace Eigen
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
log
const EIGEN_DEVICE_FUNC LogReturnType log() const
Definition: ArrayCwiseUnaryOps.h:128
Eigen::PlainObjectBase::resize
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:271
n
int n
Definition: BiCGSTAB_simple.cpp:1
epsilon
static double epsilon
Definition: testRot3.cpp:37
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
mode
static const DiscreteKey mode(modeKey, 2)
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
anyset::size
size_t size() const
Definition: pytypes.h:2220
chkder_log10e
#define chkder_log10e
Definition: chkder.h:1
Eigen::DenseIndex
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
Definition: Meta.h:66
Eigen::internal::chkder
void chkder(const Matrix< Scalar, Dynamic, 1 > &x, const Matrix< Scalar, Dynamic, 1 > &fvec, const Matrix< Scalar, Dynamic, Dynamic > &fjac, Matrix< Scalar, Dynamic, 1 > &xp, const Matrix< Scalar, Dynamic, 1 > &fvecp, int mode, Matrix< Scalar, Dynamic, 1 > &err)
Definition: chkder.h:9
Eigen::Matrix< Scalar, Dynamic, 1 >
abs
#define abs(x)
Definition: datatypes.h:17
internal
Definition: BandTriangularSolver.h:13
Eigen::PlainObjectBase::setZero
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:562
chkder_factor
#define chkder_factor
Definition: chkder.h:2
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:232
ceres::sqrt
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition: jet.h:418
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:05