21 template <
typename QRSolver,
typename VectorType>
24 const VectorType &diag,
25 const VectorType &qtb,
26 typename VectorType::Scalar m_delta,
27 typename VectorType::Scalar &par,
33 typedef typename QRSolver::MatrixType
MatrixType;
34 typedef typename QRSolver::Scalar Scalar;
65 wa1.tail(
n-rank).setZero();
67 wa1.head(rank) = s.topLeftCorner(rank,rank).template triangularView<Upper>().solve(qtb.head(rank));
69 x =
qr.colsPermutation()*wa1;
75 wa2 = diag.cwiseProduct(
x);
76 dxnorm = wa2.blueNorm();
77 fp = dxnorm - m_delta;
78 if (fp <= Scalar(0.1) * m_delta) {
88 wa1 =
qr.colsPermutation().inverse() * diag.cwiseProduct(wa2)/dxnorm;
89 s.topLeftCorner(
n,
n).transpose().template triangularView<Lower>().solveInPlace(wa1);
90 temp = wa1.blueNorm();
91 parl = fp / m_delta / temp / temp;
95 for (
j = 0;
j <
n; ++
j)
96 wa1[
j] = s.col(
j).head(
j+1).dot(qtb.head(
j+1)) / diag[
qr.colsPermutation().indices()(
j)];
98 gnorm = wa1.stableNorm();
99 paru = gnorm / m_delta;
101 paru = dwarf / (
std::min)(m_delta,Scalar(0.1));
108 par = gnorm / dxnorm;
116 par = (
std::max)(dwarf,Scalar(.001) * paru);
117 wa1 =
sqrt(par)* diag;
120 lmqrsolv(s,
qr.colsPermutation(), wa1, qtb,
x, sdiag);
122 wa2 = diag.cwiseProduct(
x);
123 dxnorm = wa2.blueNorm();
125 fp = dxnorm - m_delta;
130 if (
abs(fp) <= Scalar(0.1) * m_delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10)
134 wa1 =
qr.colsPermutation().inverse() * diag.cwiseProduct(wa2/dxnorm);
136 for (
j = 0;
j <
n; ++
j) {
140 wa1[
i] -= s.coeff(
i,
j) * temp;
142 temp = wa1.blueNorm();
143 parc = fp / m_delta / temp / temp;
HouseholderQR< MatrixXf > qr(A)
Matrix< float, 1, Dynamic > MatrixType
void lmqrsolv(Matrix< Scalar, Rows, Cols > &s, const PermutationMatrix< Dynamic, Dynamic, PermIndex > &iPerm, const Matrix< Scalar, Dynamic, 1 > &diag, const Matrix< Scalar, Dynamic, 1 > &qtb, Matrix< Scalar, Dynamic, 1 > &x, Matrix< Scalar, Dynamic, 1 > &sdiag)
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)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
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)