14#ifndef EIGEN_LMONESTEP_H
15#define EIGEN_LMONESTEP_H
19template<
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;
137 m_delta = temp * (std::min)(m_delta, pnorm /
RealScalar(.1));
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)
int n
Definition BiCGSTAB_simple.cpp:1
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define eigen_assert(x)
Definition Macros.h:1037
SCALAR Scalar
Definition bench_gemm.cpp:46
NumTraits< Scalar >::Real RealScalar
Definition bench_gemm.cpp:47
FunctorType::QRSolver QRSolver
Definition LevenbergMarquardt.h:114
LevenbergMarquardtSpace::Status minimizeOneStep(FVectorType &x)
Definition LMonestep.h:21
JacobianType::RealScalar RealScalar
Definition LevenbergMarquardt.h:117
DenseIndex Index
Definition LevenbergMarquardt.h:58
#define abs(x)
Definition datatypes.h:17
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
Definition gnuplot_common_settings.hh:12
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
Definition gnuplot_common_settings.hh:44
@ NumericalIssue
Definition Constants.h:444
@ Success
Definition Constants.h:442
@ NoConvergence
Definition Constants.h:446
Status
Definition LevenbergMarquardt.h:25
@ RelativeReductionTooSmall
Definition LevenbergMarquardt.h:29
@ GtolTooSmall
Definition LevenbergMarquardt.h:36
@ UserAsked
Definition LevenbergMarquardt.h:37
@ Running
Definition LevenbergMarquardt.h:27
@ FtolTooSmall
Definition LevenbergMarquardt.h:34
@ TooManyFunctionEvaluation
Definition LevenbergMarquardt.h:33
@ XtolTooSmall
Definition LevenbergMarquardt.h:35
@ CosinusTooSmall
Definition LevenbergMarquardt.h:32
@ RelativeErrorTooSmall
Definition LevenbergMarquardt.h:30
@ ImproperInputParameters
Definition LevenbergMarquardt.h:28
@ RelativeErrorAndReductionTooSmall
Definition LevenbergMarquardt.h:31
void lmpar2(const QRSolver &qr, const VectorType &diag, const VectorType &qtb, typename VectorType::Scalar m_delta, typename VectorType::Scalar &par, VectorType &x)
Definition LMpar.h:20
EIGEN_DEVICE_FUNC bool abs2(bool x)
Definition MathFunctions.h:1292
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
std::ptrdiff_t j
Definition tut_arithmetic_redux_minmax.cpp:2