Mercurial > hg > octave-lyh
diff scripts/optimization/fsolve.m @ 9212:6feb27c38da1
support central differences in fminunc and fsolve
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 18 May 2009 09:46:49 +0200 |
parents | 923c7cb7f13f |
children | e598248a060d |
line wrap: on
line diff
--- a/scripts/optimization/fsolve.m +++ b/scripts/optimization/fsolve.m @@ -126,7 +126,7 @@ x = optimset ("MaxIter", 400, "MaxFunEvals", Inf, \ "Jacobian", "off", "TolX", 1.5e-8, "TolFun", 1.5e-8, "OutputFcn", [], "Updating", "on", "FunValCheck", "off", - "ComplexEqn", "off"); + "ComplexEqn", "off", "FinDiffType", "central"); return; endif @@ -142,6 +142,7 @@ n = numel (x0); has_jac = strcmpi (optimget (options, "Jacobian", "off"), "on"); + cdif = strcmpi (optimget (options, "FinDiffType", "central"), "central"); maxiter = optimget (options, "MaxIter", 400); maxfev = optimget (options, "MaxFunEvals", Inf); outfcn = optimget (options, "OutputFcn"); @@ -208,8 +209,8 @@ fvec = fvec(:); nfev ++; else - fjac = __fdjac__ (fcn, reshape (x, xsiz), fvec); - nfev += length (x); + fjac = __fdjac__ (fcn, reshape (x, xsiz), fvec, cdif); + nfev += (1 + cdif) * length (x); endif ## For square and overdetermined systems, we update a QR