Mercurial > octave
changeset 25501:5f355e5ff344
maint: merge stable to default.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 25 Jun 2018 13:50:04 -0700 |
parents | 18f5f91f7348 (current diff) b3c35a130f94 (diff) |
children | b1aefc73af6e |
files | |
diffstat | 1 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/optimization/fsolve.m Mon Jun 25 15:28:25 2018 -0400 +++ b/scripts/optimization/fsolve.m Mon Jun 25 13:50:04 2018 -0700 @@ -352,7 +352,9 @@ nfail += 1; delta *= decfac; decfac ^= 1.4142; - if (delta <= 1e1*macheps*xn) + if (fn <= tolf*n*xn) + info = 1; + elseif (delta <= 1e1*macheps*xn) ## Trust region became uselessly small. info = -3; break; @@ -594,6 +596,23 @@ %! assert (norm (f) < tol); %! assert (norm (x - x_opt, Inf) < tol); +%!test <*53991> +%! A = @(lam) [0 1 0 0; 0 0 1 0; 0 0 0 1; 0 0 -lam^2 0]; +%! C = [1 0 0 0; 0 0 1 0]; +%! B = @(lam) [C*expm(A(lam)*0); C*expm(A(lam)*1)]; +%! detB = @(lam) det (B(lam)); +%! +%! [x, fvec, info] = fsolve (detB, 0); +%! assert (x == 0); +%! assert (fvec == -1); +%! assert (info == -2); + +%!test <*53991> +%! [x, fvec, info] = fsolve (@(x) 5*x, 0); +%! assert (x == 0); +%! assert (fvec == 0); +%! assert (info == 1); + ## Solve the double dogleg trust-region least-squares problem: ## Minimize norm(r*x-b) subject to the constraint norm(d.*x) <= delta, ## x being a convex combination of the gauss-newton and scaled gradient.