Mercurial > hg > octave-nkf
diff scripts/optimization/fsolve.m @ 10050:dc88a0b6472c
support old style jacobian for fsolve
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 02 Jan 2010 21:55:17 +0100 |
parents | 9f25290a35e8 |
children | 5c66978f3fdf |
line wrap: on
line diff
--- a/scripts/optimization/fsolve.m +++ b/scripts/optimization/fsolve.m @@ -136,6 +136,8 @@ if (ischar (fcn)) fcn = str2func (fcn, "global"); + elseif (iscell (fcn)) + fcn = @(x) make_fcn_jac (x, fcn{1}, fcn{2}); endif xsiz = size (x0); @@ -423,6 +425,13 @@ endif endfunction +function [fx, jx] = make_fcn_jac (x, fcn, fjac) + fx = fcn (x); + if (nargout == 2) + jx = fjac (x); + endif +endfunction + %!function retval = f (p) %! x = p(1); %! y = p(2);