# HG changeset patch # User Jaroslav Hajek # Date 1252409979 -7200 # Node ID 5bcfa0b346e83b4d855355102570bb7f0be2ccf7 # Parent bccba774af8b78e3e8624fcf0e568c5b6ec7936f fix extra outputs in fminunc diff -r bccba774af8b -r 5bcfa0b346e8 scripts/ChangeLog --- a/scripts/ChangeLog Mon Sep 07 08:49:55 2009 +0200 +++ b/scripts/ChangeLog Tue Sep 08 13:39:39 2009 +0200 @@ -1,3 +1,7 @@ +2009-09-08 Jaroslav Hajek + + * optimization/fminunc.m: Correct extra output params handling. + 2009-09-06 Jaroslav Hajek * optimization/fsolve.m: Update initial factor. diff -r bccba774af8b -r 5bcfa0b346e8 scripts/optimization/fminunc.m --- a/scripts/optimization/fminunc.m Mon Sep 07 08:49:55 2009 +0200 +++ b/scripts/optimization/fminunc.m Tue Sep 08 13:39:39 2009 +0200 @@ -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