Functions | |
endif | if (nargin< 2||nargin > 3||!ismatrix(x0)) print_usage() |
endif | if (ischar(fcn)) fcn |
if (funvalchk) fcn | |
if (!isempty(outfcn)) optimvalues.iter | |
if (stop) info | |
while (niter< maxiter &&nfev< maxfev &&!info) grad0 | |
if (has_grad)[fval | |
endif | if (niter==1) hesr |
if (info) hesr | |
Variables | |
function [x, fval, info, output, grad, hess] | |
return | |
endif | xsiz = size (x0) |
n = numel (x0) | |
has_grad = strcmpi (optimget (options, "GradObj", "off"), "on") | |
cdif = strcmpi (optimget (options, "FinDiffType", "central"), "central") | |
maxiter = optimget (options, "MaxIter", 400) | |
maxfev = optimget (options, "MaxFunEvals", Inf) | |
outfcn = optimget (options, "OutputFcn") | |
funvalchk = strcmpi (optimget (options, "FunValCheck", "off"), "on") | |
endif | macheps = eps (class (x0)) |
tolx = optimget (options, "TolX", sqrt (macheps)) | |
tolf = optimget (options, "TolFun", sqrt (macheps)) | |
factor = 0.1 | |
autodg = true | |
niter = 1 | |
nfev = 0 | |
x = x0(:) | |
info = 0 | |
fval = fcn (reshape (x, xsiz)) | |
optimvalues | funccount = nfev |
optimvalues | searchdirection = zeros (n, 1) |
state = 'init' | |
stop = outfcn (x, optimvalues, state) | |
break | |
endif endif | nsuciter = 0 |
lastratio = 0 | |
grad = [] | |
else | y = grad - grad0 |
sBs = sumsq (w) | |
Bs = hesr'*w | |
sy = y'*s | |
theta = 0.8 / max (1 - sy / sBs, 0.8) | |
r = theta * y + (1-theta) * Bs | |
hesr = cholupdate (hesr, r / sqrt (s'*r), "+") |
if | ( | info | ) |
if | ( | has_grad | ) |
if | ( | stop | ) |
if | ( | ! | isemptyoutfcn | ) |
if | ( | funvalchk | ) |
while | ( | ) |
autodg = true |
break |
factor = 0.1 |
info = 0 |
lastratio = 0 |
n = numel (x0) |
nfev = 0 |
niter = 1 |
return |
sBs = sumsq (w) |
optimvalues searchdirection = zeros (n, 1) |
state = 'init' |
sy = y'*s |
x = x0(:) |