59 Scalar
run(
fun_t phi,
const Scalar phi0,
const Scalar dphi0,
73 }
catch (
const std::runtime_error &e) {
88 const Scalar dM = latest.phi - phi0;
111 if (previous.valid) {
118 "Unrecognized interpolation type in this context.\n");
127 if (std::isnan(alpha_try)) {
137 }
catch (
const std::runtime_error &e) {
151 Scalar max_step_size) {
157 const Scalar &phi0 = lower_bound.phi;
158 const Scalar &dphi0 = lower_bound.dphi;
168 Scalar a = (cand0.phi - phi0 - cand0.alpha * dphi0) /
169 (cand0.alpha * cand0.alpha);
170 coeffs.conservativeResize(3);
171 coeffs << a, dphi0, phi0;
173 anext = -dphi0 / (2. * a);
180 const Scalar &a0 = cand0.alpha;
181 const Scalar &a1 = cand1.alpha;
185 alph_mat(0, 0) = a0 * a0 * a0;
186 alph_mat(0, 1) = a0 * a0;
187 alph_mat(1, 0) = a1 * a1 * a1;
188 alph_mat(1, 1) = a1 * a1;
190 Vector2s alph_rhs{cand1.phi - phi0 - dphi0 * a1,
191 cand0.phi - phi0 - dphi0 * a0};
193 Eigen::HouseholderQR<Matrix2s> decomp(alph_mat);
194 coeffs_cubic_interpolant = decomp.solve(alph_rhs);
196 const Scalar c3 = coeffs_cubic_interpolant(0);
197 const Scalar c2 = coeffs_cubic_interpolant(1);
198 coeffs.conservativeResize(4);
199 coeffs << c3, c2, dphi0, phi0;
203 anext = (-c2 + std::sqrt(c2 * c2 - 3.0 * c3 * dphi0)) / (3.0 * c3);
210 if ((anext > max_step_size) || (anext < min_step_size)) {
214 if (pleft < pright) {
215 anext = min_step_size;
217 anext = max_step_size;