8 template <
typename Scalar>
37 for (
j = 0;
j <
n; ++
j) {
38 if (
r(
j,
j) == 0. && nsing ==
n - 1) nsing =
j - 1;
39 if (nsing <
n - 1) wa1[
j] = 0.;
41 for (
j = nsing;
j >= 0; --
j) {
44 for (
i = 0;
i <
j; ++
i) wa1[
i] -=
r(
i,
j) * temp;
47 for (
j = 0;
j <
n; ++
j)
x[ipvt[
j]] = wa1[
j];
53 wa2 =
diag.cwiseProduct(
x);
54 dxnorm = wa2.blueNorm();
66 for (
j = 0;
j <
n; ++
j) {
68 wa1[
j] =
diag[l] * (wa2[l] / dxnorm);
72 for (
j = 0;
j <
n; ++
j) {
74 for (
i = 0;
i <
j; ++
i) sum +=
r(
i,
j) * wa1[
i];
75 wa1[
j] = (wa1[
j] - sum) /
r(
j,
j);
77 temp = wa1.blueNorm();
78 parl = fp /
delta / temp / temp;
82 for (
j = 0;
j <
n; ++
j) wa1[
j] =
r.col(
j).head(
j + 1).dot(qtb.head(
j + 1)) /
diag[ipvt[
j]];
84 gnorm = wa1.stableNorm();
92 if (
par == 0.)
par = gnorm / dxnorm;
103 qrsolv<Scalar>(
r, ipvt, wa1, qtb,
x, sdiag);
105 wa2 =
diag.cwiseProduct(
x);
106 dxnorm = wa2.blueNorm();
113 if (
abs(fp) <=
Scalar(0.1) *
delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10)
break;
116 for (
j = 0;
j <
n; ++
j) {
118 wa1[
j] =
diag[l] * (wa2[l] / dxnorm);
120 for (
j = 0;
j <
n; ++
j) {
123 for (
i =
j + 1;
i <
n; ++
i) wa1[
i] -=
r(
i,
j) * temp;
125 temp = wa1.blueNorm();
126 parc = fp /
delta / temp / temp;
140 if (iter == 0)
par = 0.;
144 template <
typename Scalar>
164 const Index n =
qr.matrixQR().cols();
177 qr.matrixQR().topLeftCorner(rank, rank).template triangularView<Upper>().solveInPlace(wa1.head(rank));
179 x =
qr.colsPermutation() * wa1;
185 wa2 =
diag.cwiseProduct(
x);
186 dxnorm = wa2.blueNorm();
198 wa1 =
qr.colsPermutation().inverse() *
diag.cwiseProduct(wa2) / dxnorm;
199 qr.matrixQR().topLeftCorner(
n,
n).transpose().template triangularView<Lower>().solveInPlace(wa1);
200 temp = wa1.blueNorm();
201 parl = fp /
delta / temp / temp;
205 for (
j = 0;
j <
n; ++
j)
206 wa1[
j] =
qr.matrixQR().col(
j).head(
j + 1).dot(qtb.head(
j + 1)) /
diag[
qr.colsPermutation().indices()(
j)];
208 gnorm = wa1.stableNorm();
209 paru = gnorm /
delta;
216 if (
par == 0.)
par = gnorm / dxnorm;
228 qrsolv<Scalar>(
s,
qr.colsPermutation().indices(), wa1, qtb,
x, sdiag);
230 wa2 =
diag.cwiseProduct(
x);
231 dxnorm = wa2.blueNorm();
238 if (
abs(fp) <=
Scalar(0.1) *
delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10)
break;
241 wa1 =
qr.colsPermutation().inverse() *
diag.cwiseProduct(wa2 / dxnorm);
244 for (
j = 0;
j <
n; ++
j) {
249 temp = wa1.blueNorm();
250 parc = fp /
delta / temp / temp;
259 if (iter == 0)
par = 0.;
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
HouseholderQR< MatrixXf > qr(A)
#define eigen_assert(x)
Definition: Macros.h:910
SCALAR Scalar
Definition: bench_gemm.cpp:45
Householder rank-revealing QR decomposition of a matrix with column-pivoting.
Definition: ColPivHouseholderQR.h:54
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:569
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
RealScalar s
Definition: level1_cplx_impl.h:130
const char const char const char * diag
Definition: level2_impl.h:86
void lmpar2(const QRSolver &qr, const VectorType &diag, const VectorType &qtb, typename VectorType::Scalar m_delta, typename VectorType::Scalar &par, VectorType &x)
Definition: LMpar.h:23
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)
Definition: lmpar.h:9
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
Definition: Meta.h:75
int delta
Definition: MultiOpt.py:96
string par
Definition: calibrate.py:135
Definition: Eigen_Colamd.h:49
list x
Definition: plotDoE.py:28
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2