mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
further cleaning/ goto removing
This commit is contained in:
parent
92a5bb4539
commit
312ab1abb3
@ -39,13 +39,11 @@ void ei_dogleg(
|
||||
/* Computing MAX */
|
||||
temp = std::max(temp,ei_abs(r[l]));
|
||||
l = l + n - i;
|
||||
/* L30: */
|
||||
}
|
||||
temp = epsmch * temp;
|
||||
if (temp == 0.) {
|
||||
if (temp == 0.)
|
||||
temp = epsmch;
|
||||
}
|
||||
}
|
||||
x[j] = (qtb[j] - sum) / temp;
|
||||
}
|
||||
|
||||
@ -77,7 +75,7 @@ void ei_dogleg(
|
||||
sgnorm = 0.;
|
||||
alpha = delta / qnorm;
|
||||
if (gnorm == 0.)
|
||||
goto L120;
|
||||
goto algo_end;
|
||||
|
||||
/* calculate the point along the scaled gradient */
|
||||
/* at which the quadratic is minimized. */
|
||||
@ -100,9 +98,8 @@ void ei_dogleg(
|
||||
/* test whether the scaled gradient direction is acceptable. */
|
||||
|
||||
alpha = 0.;
|
||||
if (sgnorm >= delta) {
|
||||
goto L120;
|
||||
}
|
||||
if (sgnorm >= delta)
|
||||
goto algo_end;
|
||||
|
||||
/* the scaled gradient direction is not acceptable. */
|
||||
/* finally, calculate the point along the dogleg */
|
||||
@ -114,7 +111,7 @@ void ei_dogleg(
|
||||
temp = temp - delta / qnorm * ei_abs2(sgnorm / delta) + ei_sqrt(ei_abs2(temp - delta / qnorm) + (1.-ei_abs2(delta / qnorm)) * (1.-ei_abs2(sgnorm / delta)));
|
||||
/* Computing 2nd power */
|
||||
alpha = delta / qnorm * (1. - ei_abs2(sgnorm / delta)) / temp;
|
||||
L120:
|
||||
algo_end:
|
||||
|
||||
/* form appropriate convex combination of the gauss-newton */
|
||||
/* direction and the scaled gradient direction. */
|
||||
|
@ -62,16 +62,17 @@ void ei_lmpar(
|
||||
wa2 = diag.cwise() * x;
|
||||
dxnorm = wa2.blueNorm();
|
||||
fp = dxnorm - delta;
|
||||
if (fp <= Scalar(0.1) * delta)
|
||||
goto L220;
|
||||
if (fp <= Scalar(0.1) * delta) {
|
||||
par = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* if the jacobian is not rank deficient, the newton */
|
||||
/* step provides a lower bound, parl, for the zero of */
|
||||
/* the function. otherwise set this bound to zero. */
|
||||
|
||||
parl = 0.;
|
||||
if (nsing < n-1)
|
||||
goto L120;
|
||||
if (nsing >= n-1) {
|
||||
for (j = 0; j < n; ++j) {
|
||||
l = ipvt[j];
|
||||
wa1[j] = diag[l] * (wa2[l] / dxnorm);
|
||||
@ -84,7 +85,7 @@ void ei_lmpar(
|
||||
}
|
||||
temp = wa1.blueNorm();
|
||||
parl = fp / delta / temp / temp;
|
||||
L120:
|
||||
}
|
||||
|
||||
/* calculate an upper bound, paru, for the zero of the function. */
|
||||
|
||||
@ -97,9 +98,8 @@ L120:
|
||||
}
|
||||
gnorm = wa1.stableNorm();
|
||||
paru = gnorm / delta;
|
||||
if (paru == 0.) {
|
||||
if (paru == 0.)
|
||||
paru = dwarf / std::min(delta,Scalar(0.1));
|
||||
}
|
||||
|
||||
/* if the input par lies outside of the interval (parl,paru), */
|
||||
/* set par to the closer endpoint. */
|
||||
@ -111,7 +111,7 @@ L120:
|
||||
|
||||
/* beginning of an iteration. */
|
||||
|
||||
L150:
|
||||
while (true) {
|
||||
++iter;
|
||||
|
||||
/* evaluate the function at the current value of par. */
|
||||
@ -135,10 +135,8 @@ L150:
|
||||
/* of par. also test for the exceptional cases where parl */
|
||||
/* is zero or the number of iterations has reached 10. */
|
||||
|
||||
if (ei_abs(fp) <= Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) ||
|
||||
iter == 10) {
|
||||
goto L220;
|
||||
}
|
||||
if (ei_abs(fp) <= Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10)
|
||||
break;
|
||||
|
||||
/* compute the newton correction. */
|
||||
|
||||
@ -158,12 +156,10 @@ L150:
|
||||
|
||||
/* depending on the sign of the function, update parl or paru. */
|
||||
|
||||
if (fp > 0.) {
|
||||
if (fp > 0.)
|
||||
parl = std::max(parl,par);
|
||||
}
|
||||
if (fp < 0.) {
|
||||
if (fp < 0.)
|
||||
paru = std::min(paru,par);
|
||||
}
|
||||
|
||||
/* compute an improved estimate for par. */
|
||||
|
||||
@ -172,14 +168,12 @@ L150:
|
||||
|
||||
/* end of an iteration. */
|
||||
|
||||
goto L150;
|
||||
L220:
|
||||
}
|
||||
|
||||
/* termination. */
|
||||
|
||||
if (iter == 0) {
|
||||
if (iter == 0)
|
||||
par = 0.;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user