Mercurial > hg > octave-terminal
changeset 9627:5bcfa0b346e8
fix extra outputs in fminunc
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 08 Sep 2009 13:39:39 +0200 |
parents | bccba774af8b |
children | 73e6ad869f08 |
files | scripts/ChangeLog scripts/optimization/fminunc.m |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2009-09-08 Jaroslav Hajek <highegg@gmail.com> + + * optimization/fminunc.m: Correct extra output params handling. + 2009-09-06 Jaroslav Hajek <highegg@gmail.com> * optimization/fsolve.m: Update initial factor.
--- a/scripts/optimization/fminunc.m +++ b/scripts/optimization/fminunc.m @@ -20,7 +20,7 @@ ## -*- texinfo -*- ## @deftypefn{Function File} {} fminunc (@var{fcn}, @var{x0}, @var{options}) -## @deftypefnx{Function File} {[@var{x}, @var{fvec}, @var{info}, @var{output}, @var{fjac}]} = fminunc (@var{fcn}, @dots{}) +## @deftypefnx{Function File} {[@var{x}, @var{fvec}, @var{info}, @var{output}, @var{grad}, @var{hess}]} = fminunc (@var{fcn}, @dots{}) ## Solve a unconstrained optimization problem defined by the function @var{fcn}. ## @var{fcn} should accepts a vector (array) defining the unknown variables, ## and return the objective function value, optionally with gradient. @@ -60,6 +60,10 @@ ## The trust region radius became excessively small. ## @end table ## +## Optionally, fminunc can also yield a structure with convergence statistics +## (@var{output}), the output gradient (@var{grad}) and approximate hessian +## (@var{hess}). +## ## Note: If you only have a single nonlinear equation of one variable, using ## @code{fminbnd} is usually a much better idea. ## @seealso{fminbnd, optimset} @@ -308,6 +312,10 @@ output.successful = nsuciter; output.funcCount = nfev; + if (nargout > 5) + hess = hesr'*hesr; + endif + endfunction ## An assistant function that evaluates a function handle and checks for