19 template <
typename QRSolver,
typename VectorType>
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;
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) {
138 wa1[
i] -= s.coeff(
i,j) * temp;
140 temp = wa1.blueNorm();
141 parc = fp / m_delta / temp / temp;
160 #endif // EIGEN_LMPAR_H
Matrix diag(const std::vector< Matrix > &Hs)
void lmpar2(const QRSolver &qr, const VectorType &diag, const VectorType &qtb, typename VectorType::Scalar m_delta, typename VectorType::Scalar &par, VectorType &x)
Namespace containing all symbols from the Eigen library.
iterator iter(handle obj)
HouseholderQR< MatrixXf > qr(A)
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)
Jet< T, N > sqrt(const Jet< T, N > &f)
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