14 #ifndef EIGEN_LMONESTEP_H
15 #define EIGEN_LMONESTEP_H
21 template<
typename FunctorType>
29 RealScalar pnorm, xnorm, fnorm1, actred, dirder, prered;
32 temp = 0.0; xnorm = 0.0;
34 Index df_ret = m_functor.df(
x, m_fjac);
43 for (
int j = 0;
j <
x.size(); ++
j)
44 m_wa2(
j) = m_fjac.col(
j).blueNorm();
51 m_rfactor = qrfac.matrixR();
52 m_permutation = (qrfac.colsPermutation());
57 if (!m_useExternalScaling)
59 m_diag[
j] = (m_wa2[
j]==0.)? 1. : m_wa2[
j];
63 xnorm = m_diag.cwiseProduct(
x).stableNorm();
64 m_delta = m_factor * xnorm;
72 m_wa4 = qrfac.matrixQ().adjoint() * m_fvec;
73 m_qtf = m_wa4.head(
n);
79 if (m_wa2[m_permutation.indices()[
j]] != 0.)
80 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]]));
83 if (m_gnorm <= m_gtol) {
89 if (!m_useExternalScaling)
90 m_diag = m_diag.cwiseMax(m_wa2);
99 pnorm = m_diag.cwiseProduct(m_wa1).stableNorm();
103 m_delta = (
std::min)(m_delta,pnorm);
106 if ( m_functor(m_wa2, m_wa4) < 0)
109 fnorm1 = m_wa4.stableNorm();
113 if (
Scalar(.1) * fnorm1 < m_fnorm)
118 m_wa3 = m_rfactor.template triangularView<Upper>() * (m_permutation.inverse() *m_wa1);
121 prered = temp1 + temp2 /
Scalar(.5);
122 dirder = -(temp1 + temp2);
128 ratio = actred / prered;
131 if (ratio <=
Scalar(.25)) {
141 }
else if (!(m_par != 0. && ratio <
RealScalar(.75))) {
150 m_wa2 = m_diag.cwiseProduct(
x);
152 xnorm = m_wa2.stableNorm();
158 if (
abs(actred) <= m_ftol && prered <= m_ftol &&
Scalar(.5) * ratio <= 1. && m_delta <= m_xtol * xnorm)
163 if (
abs(actred) <= m_ftol && prered <= m_ftol &&
Scalar(.5) * ratio <= 1.)
168 if (m_delta <= m_xtol * xnorm)
175 if (m_nfev >= m_maxfev)
196 }
while (ratio <
Scalar(1
e-4));
Array< double, 1, 3 > e(1./3., 0.5, 2.)
JacobianType::Scalar Scalar
FunctorType::QRSolver QRSolver
LevenbergMarquardtSpace::Status minimizeOneStep(FVectorType &x)
JacobianType::RealScalar RealScalar
@ RelativeReductionTooSmall
@ TooManyFunctionEvaluation
@ ImproperInputParameters
@ RelativeErrorAndReductionTooSmall
void lmpar2(const QRSolver &qr, const VectorType &diag, const VectorType &qtb, typename VectorType::Scalar m_delta, typename VectorType::Scalar &par, VectorType &x)
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Eigen::internal::remove_all_t< DerType >, typename Eigen::internal::traits< Eigen::internal::remove_all_t< DerType >>::Scalar, product) > sqrt(const Eigen::AutoDiffScalar< DerType > &x)
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
CleanedUpDerType< DerType >::type() max(const AutoDiffScalar< DerType > &x, const T &y)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
adouble abs(const adouble &x)