chkder.h
Go to the documentation of this file.
1 #define chkder_log10e 0.43429448190325182765
2 #define chkder_factor 100.
3 
4 // IWYU pragma: private
6 
7 namespace Eigen {
8 
9 namespace internal {
10 
11 template <typename Scalar>
14  const Matrix<Scalar, Dynamic, 1> &fvecp, int mode, Matrix<Scalar, Dynamic, 1> &err) {
15  using std::abs;
16  using std::log;
17  using std::sqrt;
18 
19  typedef DenseIndex Index;
20 
23  const Scalar epslog = chkder_log10e * log(eps);
24  Scalar temp;
25 
26  const Index m = fvec.size(), n = x.size();
27 
28  if (mode != 2) {
29  /* mode = 1. */
30  xp.resize(n);
31  for (Index j = 0; j < n; ++j) {
32  temp = eps * abs(x[j]);
33  if (temp == 0.) temp = eps;
34  xp[j] = x[j] + temp;
35  }
36  } else {
37  /* mode = 2. */
38  err.setZero(m);
39  for (Index j = 0; j < n; ++j) {
40  temp = abs(x[j]);
41  if (temp == 0.) temp = 1.;
42  err += temp * fjac.col(j);
43  }
44  for (Index i = 0; i < m; ++i) {
45  temp = 1.;
46  if (fvec[i] != 0. && fvecp[i] != 0. && abs(fvecp[i] - fvec[i]) >= epsf * abs(fvec[i]))
47  temp = eps * abs((fvecp[i] - fvec[i]) / eps - err[i]) / (abs(fvec[i]) + abs(fvecp[i]));
48  err[i] = 1.;
49  if (temp > NumTraits<Scalar>::epsilon() && temp < eps) err[i] = (chkder_log10e * log(temp) - epslog) / epslog;
50  if (temp >= eps) err[i] = 0.;
51  }
52  }
53 }
54 
55 } // end namespace internal
56 
57 } // end namespace Eigen
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
SCALAR Scalar
Definition: bench_gemm.cpp:45
#define chkder_log10e
Definition: chkder.h:1
#define chkder_factor
Definition: chkder.h:2
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:569
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:294
int * m
Definition: level2_cplx_impl.h:294
double eps
Definition: crbond_bessel.cc:24
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log(const bfloat16 &a)
Definition: BFloat16.h:618
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:12
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
Definition: Meta.h:75
Definition: Eigen_Colamd.h:49
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43
list x
Definition: plotDoE.py:28
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2