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) if(has_jac)[fvec | |
if (issparse(fjac)) updating | |
if (useqr)[q | |
Variables | |
function [x, fvec, info, output, fjac] | |
return | |
endif | xsiz = size (x0) |
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") | |
updating = strcmpi (optimget (options, "Updating", "on"), "on") | |
complexeqn = strcmpi (optimget (options, "ComplexEqn", "off"), "on") | |
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 = 1 | |
niter = 1 | |
nfev = 1 | |
x = x0(:) | |
info = 0 | |
fvec = fcn (reshape (x, xsiz)) | |
fsiz = size (fvec) | |
fn = norm (fvec) | |
m = length (fvec) | |
optimvalues | funccount = nfev |
optimvalues | fval = fn |
optimvalues | searchdirection = zeros (n, 1) |
state = 'init' | |
stop = outfcn (x, optimvalues, state) | |
break | |
endif endif | nsuciter = 0 |
fjac = fcn (reshape (x, xsiz)) | |
endif | useqr = updating && m >= n && n > 10 |
r = qr (fjac, 0) |
if | ( | useqr | ) |
if | ( | issparse(fjac) | ) |
if | ( | stop | ) |
if | ( | ! | isemptyoutfcn | ) |
if | ( | funvalchk | ) |
while | ( | ) | [new] |
break |
complexeqn = strcmpi (optimget (options, "ComplexEqn", "off"), "on") |
factor = 1 |
Initial value:
fsolve (fcn, x0, options = struct ()) if (nargin == 1 && ischar (fcn) && strcmp (fcn, 'defaults')) x = optimset ("MaxIter", 400, "MaxFunEvals", Inf, "Jacobian", "off", "TolX", 1.5e-8, "TolFun", 1.5e-8, "OutputFcn", [], "Updating", "on", "FunValCheck", "off", "ComplexEqn", "off", "FinDiffType", "central")
info = 0 |
m = length (fvec) |
n = numel (x0) |
nfev = 1 |
niter = 1 |
r = qr (fjac, 0) |
return |
optimvalues searchdirection = zeros (n, 1) |
state = 'init' |
x = x0(:) |