14 #ifndef EIGEN_LMONESTEP_H
15 #define EIGEN_LMONESTEP_H
19 template<
typename FunctorType>
27 RealScalar pnorm, xnorm, fnorm1, actred, dirder, prered;
30 temp = 0.0; xnorm = 0.0;
32 Index df_ret = m_functor.df(
x, m_fjac);
42 m_wa2(
j) = m_fjac.col(
j).blueNorm();
49 m_rfactor = qrfac.matrixR();
50 m_permutation = (qrfac.colsPermutation());
55 if (!m_useExternalScaling)
57 m_diag[
j] = (m_wa2[
j]==0.)? 1. : m_wa2[
j];
61 xnorm = m_diag.cwiseProduct(
x).stableNorm();
62 m_delta = m_factor * xnorm;
70 m_wa4 = qrfac.matrixQ().adjoint() * m_fvec;
71 m_qtf = m_wa4.head(
n);
77 if (m_wa2[m_permutation.indices()[
j]] != 0.)
78 m_gnorm = (
std::max)(m_gnorm,
abs( m_rfactor.col(
j).head(
j+1).dot(m_qtf.head(
j+1)/m_fnorm) / m_wa2[m_permutation.indices()[
j]]));
81 if (m_gnorm <= m_gtol) {
87 if (!m_useExternalScaling)
88 m_diag = m_diag.cwiseMax(m_wa2);
97 pnorm = m_diag.cwiseProduct(m_wa1).stableNorm();
101 m_delta = (
std::min)(m_delta,pnorm);
104 if ( m_functor(m_wa2, m_wa4) < 0)
107 fnorm1 = m_wa4.stableNorm();
111 if (
Scalar(.1) * fnorm1 < m_fnorm)
116 m_wa3 = m_rfactor.template triangularView<Upper>() * (m_permutation.inverse() *m_wa1);
119 prered = temp1 + temp2 /
Scalar(.5);
120 dirder = -(temp1 + temp2);
126 ratio = actred / prered;
148 m_wa2 = m_diag.cwiseProduct(
x);
150 xnorm = m_wa2.stableNorm();
156 if (
abs(actred) <= m_ftol && prered <= m_ftol &&
Scalar(.5) *
ratio <= 1. && m_delta <= m_xtol * xnorm)
161 if (
abs(actred) <= m_ftol && prered <= m_ftol &&
Scalar(.5) *
ratio <= 1.)
166 if (m_delta <= m_xtol * xnorm)
173 if (m_nfev >= m_maxfev)
202 #endif // EIGEN_LMONESTEP_H