19 template <
typename QRSolver,
typename VectorType>
22 const VectorType &diag,
23 const VectorType &qtb,
51 const Index n = qr.matrixR().cols();
61 const Index rank = qr.rank();
63 wa1.tail(n-rank).setZero();
65 wa1.head(rank) = s.topLeftCorner(rank,rank).template triangularView<Upper>().solve(qtb.head(rank));
67 x = qr.colsPermutation()*wa1;
73 wa2 = diag.cwiseProduct(x);
74 dxnorm = wa2.blueNorm();
75 fp = dxnorm - m_delta;
76 if (fp <=
Scalar(0.1) * m_delta) {
86 wa1 = qr.colsPermutation().inverse() * diag.cwiseProduct(wa2)/dxnorm;
88 temp = wa1.blueNorm();
89 parl = fp / m_delta / temp / temp;
93 for (j = 0; j <
n; ++j)
94 wa1[j] = s.col(j).head(j+1).dot(qtb.head(j+1)) / diag[qr.colsPermutation().indices()(j)];
96 gnorm = wa1.stableNorm();
97 paru = gnorm / m_delta;
106 par = gnorm / dxnorm;
115 wa1 =
sqrt(par)* diag;
118 lmqrsolv(s, qr.colsPermutation(), wa1, qtb,
x, sdiag);
120 wa2 = diag.cwiseProduct(x);
121 dxnorm = wa2.blueNorm();
123 fp = dxnorm - m_delta;
128 if (
abs(fp) <=
Scalar(0.1) * m_delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10)
132 wa1 = qr.colsPermutation().inverse() * diag.cwiseProduct(wa2/dxnorm);
134 for (j = 0; j <
n; ++j) {
137 for (
Index i = j+1; i <
n; ++i)
138 wa1[i] -= s.coeff(i,j) * temp;
140 temp = wa1.blueNorm();
141 parc = fp / m_delta / temp / temp;
160 #endif // EIGEN_LMPAR_H
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
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
Map< Matrix< Scalar, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > MatrixType
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
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)
A triangularView< Lower >().adjoint().solveInPlace(B)