28 #ifndef CHECK_DERIVATIVES_H 29 #define CHECK_DERIVATIVES_H 99 template<
typename Der1,
typename Der2,
typename fnType,
typename ErrorStream>
102 fnType fn, Eigen::Index valdims,
116 const Eigen::Index xdims = derivatives.cols();
124 ValVector val0(valdims);
125 ValVector dval1(valdims);
126 ValVector dvalFromDer(valdims);
128 XVector pt2(point.rows());
139 for (i = 0; i < xdims; ++i) {
150 dvalFromDer = delta * derivatives.
matrix().col(i);
152 XScalar thediff = (dval1 - dvalFromDer).norm();
154 if (thediff/delta > tol ) {
158 XVector dir = XVector::Zero(xdims);
163 <<
"Error in derivative check: Derivative wrong in direction\n" 164 <<
"dir = " << dir.transpose() <<
" [basis vector #"<<i<<
"]\n" 165 <<
"\tpoint = \t" << point.
transpose() <<
"\n" 166 <<
"\tval0 = \t" << val0.transpose() <<
"\n" 167 <<
"\tdval1 = \t" << dval1.transpose() <<
"\n" 168 <<
"\tdvalFromDer = \t"<<dvalFromDer.transpose() <<
"\n" 169 <<
"\tderivative in this direction =\n\t\t\t\t" << derivatives.
transpose().block(i,0,1,valdims) <<
"\n" 170 <<
"--> difference in p2-points: \t" << thediff <<
"\n" 171 <<
"--> difference in derivatives: \t" << thediff/delta <<
"\n\n";
Base namespace for the Tomographer project.
#define TOMO_STATIC_ASSERT_EXPR(...)
Tool for static assertions without message.
Some C++ utilities, with a tad of C++11 tricks.
Eigen::Transpose< Derived > transpose()
MatrixWrapper< Derived > matrix()
#define tomographer_assert(...)
Assertion test macro.