30 double deltaSq = delta*
delta;
33 if(verbose) cout <<
"Steepest descent magnitude " <<
std::sqrt(x_u_norm_sq) <<
", Newton's method magnitude " <<
std::sqrt(x_n_norm_sq) << endl;
34 if(deltaSq < x_u_norm_sq) {
37 if(verbose) cout <<
"In steepest descent region with fraction " <<
std::sqrt(deltaSq / x_u_norm_sq) <<
" of steepest descent magnitude" << endl;
39 }
else if(deltaSq < x_n_norm_sq) {
41 return ComputeBlend(delta, dx_u, dx_n, verbose);
43 assert(deltaSq >= x_n_norm_sq);
44 if(verbose) cout <<
"In pure Newton's method region" << endl;
56 const double un =
dot(x_u, x_n);
57 const double uu =
dot(x_u, x_u);
58 const double nn =
dot(x_n, x_n);
61 const double a = uu - 2.*un +
nn;
62 const double b = 2. * (un - uu);
63 const double c = uu - delta*
delta;
64 double sqrt_b_m4ac =
std::sqrt(b*b - 4*a*c);
67 double tau1 = (-b + sqrt_b_m4ac) / (2.*a);
68 double tau2 = (-b - sqrt_b_m4ac) / (2.*a);
71 if(0.0 <= tau1 && tau1 <= 1.0) {
72 assert(!(0.0 <= tau2 && tau2 <= 1.0));
75 assert(0.0 <= tau2 && tau2 <= 1.0);
80 if(verbose) cout <<
"In blend region with fraction " << tau <<
" of Newton's method point" << endl;
Nonlinear factor graph optimizer using Powell's Dogleg algorithm (detail implementation) ...
Scalar EIGEN_BLAS_FUNC() dot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
double squaredNorm() const
Jet< T, N > sqrt(const Jet< T, N > &f)