5 template <
typename Scalar>
31 const Index
n = r.
cols();
42 for (j = 0; j <
n; ++
j) {
43 if (r(j,j) == 0. && nsing == n-1)
48 for (j = nsing; j>=0; --
j) {
51 for (i = 0; i <
j ; ++
i)
52 wa1[i] -= r(i,j) * temp;
55 for (j = 0; j <
n; ++
j)
62 wa2 = diag.cwiseProduct(x);
63 dxnorm = wa2.blueNorm();
65 if (fp <=
Scalar(0.1) * delta) {
75 for (j = 0; j <
n; ++
j) {
77 wa1[
j] = diag[
l] * (wa2[
l] / dxnorm);
81 for (j = 0; j <
n; ++
j) {
83 for (i = 0; i <
j; ++
i)
84 sum += r(i,j) * wa1[
i];
85 wa1[
j] = (wa1[
j] -
sum) / r(j,j);
87 temp = wa1.blueNorm();
88 parl = fp / delta / temp / temp;
92 for (j = 0; j <
n; ++
j)
93 wa1[j] = r.col(j).head(j+1).dot(qtb.head(j+1)) / diag[ipvt[j]];
95 gnorm = wa1.stableNorm();
105 par = gnorm / dxnorm;
117 qrsolv<Scalar>(r, ipvt, wa1, qtb,
x, sdiag);
119 wa2 = diag.cwiseProduct(x);
120 dxnorm = wa2.blueNorm();
127 if (
abs(fp) <=
Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10)
131 for (j = 0; j <
n; ++
j) {
133 wa1[
j] = diag[
l] * (wa2[
l] / dxnorm);
135 for (j = 0; j <
n; ++
j) {
138 for (i = j+1; i <
n; ++
i)
139 wa1[i] -= r(i,j) * temp;
141 temp = wa1.blueNorm();
142 parc = fp / delta / temp / temp;
163 template <
typename Scalar>
189 const Index
n =
qr.matrixQR().cols();
199 const Index rank =
qr.rank();
202 qr.matrixQR().topLeftCorner(rank, rank).template triangularView<Upper>().solveInPlace(wa1.head(rank));
204 x =
qr.colsPermutation()*wa1;
210 wa2 = diag.cwiseProduct(x);
211 dxnorm = wa2.blueNorm();
213 if (fp <=
Scalar(0.1) * delta) {
223 wa1 =
qr.colsPermutation().inverse() * diag.cwiseProduct(wa2)/dxnorm;
225 temp = wa1.blueNorm();
226 parl = fp / delta / temp / temp;
230 for (j = 0; j <
n; ++
j)
231 wa1[j] =
qr.matrixQR().col(j).head(j+1).dot(qtb.head(j+1)) / diag[
qr.colsPermutation().indices()(
j)];
233 gnorm = wa1.stableNorm();
234 paru = gnorm /
delta;
243 par = gnorm / dxnorm;
256 qrsolv<Scalar>(
s,
qr.colsPermutation().indices(), wa1, qtb,
x, sdiag);
258 wa2 = diag.cwiseProduct(x);
259 dxnorm = wa2.blueNorm();
266 if (
abs(fp) <=
Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10)
270 wa1 =
qr.colsPermutation().inverse() * diag.cwiseProduct(wa2/dxnorm);
273 for (j = 0; j <
n; ++
j) {
276 for (Index
i = j+1;
i <
n; ++
i)
277 wa1[
i] -=
s(
i,j) * temp;
279 temp = wa1.blueNorm();
280 parc = fp / delta / temp / temp;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index cols() const
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
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)
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Namespace containing all symbols from the Eigen library.
iterator iter(handle obj)
HouseholderQR< MatrixXf > qr(A)
static const Line3 l(Rot3(), 1, 1)
Householder rank-revealing QR decomposition of a matrix with column-pivoting.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
A triangularView< Lower >().adjoint().solveInPlace(B)
void lmpar(Matrix< Scalar, Dynamic, Dynamic > &r, const VectorXi &ipvt, const Matrix< Scalar, Dynamic, 1 > &diag, const Matrix< Scalar, Dynamic, 1 > &qtb, Scalar delta, Scalar &par, Matrix< Scalar, Dynamic, 1 > &x)
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