comparison scripts/optimization/fsolve.m @ 10549:95c3e38098bf

Untabify .m scripts
author Rik <code@nomad.inbox5.com>
date Fri, 23 Apr 2010 11:28:50 -0700
parents 5c66978f3fdf
children fbd7843974fa
comparison
equal deleted inserted replaced
10548:479536c5bb10 10549:95c3e38098bf
382 ## FIXME -- why tolf*n*xn? If abs (e) ~ abs(x) * eps is a vector 382 ## FIXME -- why tolf*n*xn? If abs (e) ~ abs(x) * eps is a vector
383 ## of perturbations of x, then norm (fjac*e) <= eps*n*xn, i.e. by 383 ## of perturbations of x, then norm (fjac*e) <= eps*n*xn, i.e. by
384 ## tolf ~ eps we demand as much accuracy as we can expect. 384 ## tolf ~ eps we demand as much accuracy as we can expect.
385 if (fn <= tolf*n*xn) 385 if (fn <= tolf*n*xn)
386 info = 1; 386 info = 1;
387 ## The following tests done only after successful step. 387 ## The following tests done only after successful step.
388 elseif (ratio >= 1e-4) 388 elseif (ratio >= 1e-4)
389 ## This one is classic. Note that we use scaled variables again, 389 ## This one is classic. Note that we use scaled variables again,
390 ## but compare to scaled step, so nothing bad. 390 ## but compare to scaled step, so nothing bad.
391 if (sn <= tolx*xn) 391 if (sn <= tolx*xn)
392 info = 2; 392 info = 2;
393 ## Again a classic one. It seems weird to use the same tolf 393 ## Again a classic one. It seems weird to use the same tolf
394 ## for two different tests, but that's what M*b manual appears 394 ## for two different tests, but that's what M*b manual appears
395 ## to say. 395 ## to say.
396 elseif (actred < tolf) 396 elseif (actred < tolf)
397 info = 3; 397 info = 3;
398 endif 398 endif
399 endif 399 endif
400 400
579 s = (s / sn) ./ d; 579 s = (s / sn) ./ d;
580 ## Get the line minimizer in s direction. 580 ## Get the line minimizer in s direction.
581 tn = norm (r*s); 581 tn = norm (r*s);
582 snm = (sn / tn) / tn; 582 snm = (sn / tn) / tn;
583 if (snm < delta) 583 if (snm < delta)
584 ## Get the dogleg path minimizer. 584 ## Get the dogleg path minimizer.
585 bn = norm (b); 585 bn = norm (b);
586 dxn = delta/xn; snmd = snm/delta; 586 dxn = delta/xn; snmd = snm/delta;
587 t = (bn/sn) * (bn/xn) * snmd; 587 t = (bn/sn) * (bn/xn) * snmd;
588 t -= dxn * snmd^2 - sqrt ((t-dxn)^2 + (1-dxn^2)*(1-snmd^2)); 588 t -= dxn * snmd^2 - sqrt ((t-dxn)^2 + (1-dxn^2)*(1-snmd^2));
589 alpha = dxn*(1-snmd^2) / t; 589 alpha = dxn*(1-snmd^2) / t;