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);
41 for (
int j = 0;
j < x.size(); ++
j)
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;
129 if (ratio <=
Scalar(.25)) {
139 }
else if (!(m_par != 0. && ratio <
RealScalar(.75))) {
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)
194 }
while (ratio <
Scalar(1
e-4));
202 #endif // EIGEN_LMONESTEP_H JacobianType::RealScalar RealScalar
LevenbergMarquardtSpace::Status minimizeOneStep(FVectorType &x)
void lmpar2(const QRSolver &qr, const VectorType &diag, const VectorType &qtb, typename VectorType::Scalar m_delta, typename VectorType::Scalar &par, VectorType &x)
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Namespace containing all symbols from the Eigen library.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size ratio
Array< double, 1, 3 > e(1./3., 0.5, 2.)
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
FunctorType::QRSolver QRSolver
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x