Mercurial > hg > octave-max
changeset 10050:dc88a0b6472c
support old style jacobian for fsolve
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 02 Jan 2010 21:55:17 +0100 |
parents | 44e889c67abe |
children | 4e6b245d4eb7 |
files | scripts/ChangeLog scripts/optimization/fsolve.m |
diffstat | 2 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-01-02 Jaroslav Hajek <highegg@gmail.com> + + * optimization/fsolve.m: Support old style jacobian passing. + 2010-01-01 Jaroslav Hajek <highegg@gmail.com> * set/powerset.m: New function.
--- 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);